-
Notifications
You must be signed in to change notification settings - Fork 261
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
Refactor how options are registered #5675
Refactor how options are registered #5675
Conversation
// public static void RegisterLibraryCheck(Option option, OptionCompatibility.OptionCheck check) { | ||
// if (NoChecksNeeded.Contains(option)) { | ||
// throw new ArgumentException($"Option already registered as not needing a library check: {option.Name}"); | ||
// } | ||
// OptionChecks.Add(option, check); | ||
// } | ||
// | ||
// public static void RegisterLibraryChecks(IDictionary<Option, OptionCompatibility.OptionCheck> checks) { | ||
// foreach (var (option, check) in checks) { | ||
// RegisterLibraryCheck(option, check); | ||
// } | ||
// } | ||
// | ||
// public static void RegisterNoChecksNeeded(Option option, bool semantic) { | ||
// if (semantic) { | ||
// RegisterLibraryCheck(option, OptionCompatibility.NoOpOptionCheck); | ||
// } else { | ||
// if (OptionChecks.ContainsKey(option)) { | ||
// throw new ArgumentException($"Option already registered as needing a library check: {option.Name}"); | ||
// } | ||
// NoChecksNeeded.Add(option); | ||
// } | ||
// } |
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.
nit: unused
// public static void RegisterLibraryCheck(Option option, OptionCompatibility.OptionCheck check) { | |
// if (NoChecksNeeded.Contains(option)) { | |
// throw new ArgumentException($"Option already registered as not needing a library check: {option.Name}"); | |
// } | |
// OptionChecks.Add(option, check); | |
// } | |
// | |
// public static void RegisterLibraryChecks(IDictionary<Option, OptionCompatibility.OptionCheck> checks) { | |
// foreach (var (option, check) in checks) { | |
// RegisterLibraryCheck(option, check); | |
// } | |
// } | |
// | |
// public static void RegisterNoChecksNeeded(Option option, bool semantic) { | |
// if (semantic) { | |
// RegisterLibraryCheck(option, OptionCompatibility.NoOpOptionCheck); | |
// } else { | |
// if (OptionChecks.ContainsKey(option)) { | |
// throw new ArgumentException($"Option already registered as needing a library check: {option.Name}"); | |
// } | |
// NoChecksNeeded.Add(option); | |
// } | |
// } |
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.
Woops! Sorry
@@ -216,7 +215,8 @@ public class ManifestData { | |||
result.Options.OptionArguments[option] = libraryValue; | |||
result.ApplyBinding(option); | |||
var prefix = $"cannot load {options.GetPrintPath(libraryFile.LocalPath)}"; | |||
success = success && check(reporter, origin, prefix, option, localValue, libraryValue); | |||
var checkpasses = OptionRegistry.GlobalCheck(option)?.Invoke(reporter, origin, prefix, option, localValue, libraryValue) ?? true; |
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.
The CI warns that libraryValue
is possibly null, is that intended?
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.
Fixed
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.
LGTM
Description
Refactor how options are registered. Replaces the various ways of registering options by these four types:
ModuleDecl.Options
program.Compilation.AlreadyTranslatedRecord.OptionsByModule
Follow-up
ModuleDecl.Options
and replace usages ofCompilationData.AlreadyTranslatedRecord
withModuleDecl.Options
,How has this been tested?
It's a refactoring so no additional tests are needed.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.