Skip to content
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

Merged
merged 3 commits into from
Apr 24, 2019

Conversation

bergmeister
Copy link
Collaborator

PR Summary

  • Enabled is not a valid key for the settings, therefore examples using settings file did not work
  • Use profile string name that is available in the shipped version so that examples work better out of the box

PR Checklist

- Enabled is not a valid key for the settings
- Use profile string name that is available in the shipped version
Copy link
Contributor

@rjmholt rjmholt left a 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'
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);
}

@bergmeister bergmeister merged commit 54a4bb2 into PowerShell:development Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants