-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix documentation examples of new UseCompatible* rules #1225
Fix documentation examples of new UseCompatible* rules #1225
Conversation
- Enabled is not a valid key for the settings - Use profile string name that is available in the shipped version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catches
@@ -75,8 +75,8 @@ An example configuration might look like: | |||
UseCompatibleCommmands = @{ | |||
Enable = $true | |||
TargetProfiles = @( | |||
'ubuntu_x64_18.04_6.1.2_x64_4.0.30319.42000_core' | |||
'win-4_x64_10.0.18312.0_6.1.1_x64_4.0.30319.42000_framework' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these are valid profile names, but not ones we ship now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I thought I could just create my own profile and name the file foo
and it would to file name based matching like the old UseCompatibleCmdlets
rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you put it in the profile directory, that should work, yes. There's a method that takes a profile and turns it into a path:
PSScriptAnalyzer/Rules/CompatibilityRules/CompatibilityRule.cs
Lines 174 to 206 in 4f8e34e
private string NormalizeProfileNameToAbsolutePath(string profileName) | |
{ | |
// Reject null or empty paths | |
if (string.IsNullOrEmpty(profileName)) | |
{ | |
throw new ArgumentException($"{nameof(profileName)} cannot be null or empty"); | |
} | |
// Accept absolute paths verbatim. There may be issues with paths like "/here" in Windows | |
if (Path.IsPathRooted(profileName)) | |
{ | |
return profileName; | |
} | |
// Reject relative paths | |
if (profileName.Contains("\\") | |
|| profileName.Contains("/") | |
|| profileName.Equals(".") | |
|| profileName.Equals("..")) | |
{ | |
throw new ArgumentException($"Compatibility profile specified as '{profileName}'. Compatibility profiles cannot be specified by relative path."); | |
} | |
// Profiles might be given by pure name, in which case tack ".json" onto the end | |
string extension = Path.GetExtension(profileName); | |
if (string.IsNullOrEmpty(extension) || s_falseProfileExtensionPattern.IsMatch(extension)) | |
{ | |
profileName = profileName + ".json"; | |
} | |
// Names get looked for in the known profile directory | |
return Path.Combine(_profileDir.FullName, profileName); | |
} |
PR Summary
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.