Skip to content

Fix documentation examples of new UseCompatible* rules #1225

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

Merged
merged 3 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RuleDocumentation/UseCompatibleCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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:

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);
}

'ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core'
'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework'
'MyProfile'
'another_custom_profile_in_the_profiles_directory.json'
'D:\My Profiles\profile1.json'
Expand Down
2 changes: 1 addition & 1 deletion RuleDocumentation/UseCompatibleSyntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ due to those PowerShell versions not being able to parse the incompatible syntax
@{
Rules = @{
UseCompatibleCommmands = @{
Enabled = $true
Enable = $true
TargetedVersions = @(
"6.0",
"5.1",
Expand Down
6 changes: 3 additions & 3 deletions RuleDocumentation/UseCompatibleTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ An example configuration might look like:
@{
Rules = @{
UseCompatibleTypes = @{
Enabled = $true
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'
'ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core'
'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework'
'MyProfile'
'another_custom_profile_in_the_profiles_directory.json'
'D:\My Profiles\profile1.json'
Expand Down