2 types derived from Option
Microsoft.Interop.LibraryImportGenerator (2)
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
49
public sealed record Bool(bool Value) :
Option
54
public sealed record String(string Value) :
Option
54 references to Option
Microsoft.Interop.LibraryImportGenerator (54)
Analyzers\ConvertToLibraryImportFixer.cs (28)
37
protected override string GetDiagnosticTitle(ImmutableDictionary<string,
Option
> selectedOptions)
39
bool allowUnsafe = selectedOptions.TryGetValue(
Option
.AllowUnsafe, out
Option
? allowUnsafeOption) && allowUnsafeOption is
Option
.Bool(true);
42
if (selectedOptions.TryGetValue(SelectedSuffixOption, out
Option
? suffixOption) && suffixOption is
Option
.String(string suffixValue))
56
protected override ImmutableDictionary<string,
Option
> ParseOptionsFromDiagnostic(Diagnostic diagnostic)
58
var optionsBuilder = ImmutableDictionary.CreateBuilder<string,
Option
>();
62
optionsBuilder.Add(
Option
.MayRequireAdditionalWork, new
Option
.Bool(true));
66
optionsBuilder.Add(CharSetOption, new
Option
.String(diagnostic.Properties[ConvertToLibraryImportAnalyzer.CharSet]));
71
protected override ImmutableDictionary<string,
Option
> CombineOptions(ImmutableDictionary<string,
Option
> fixAllOptions, ImmutableDictionary<string,
Option
> diagnosticOptions)
76
protected override IEnumerable<ConvertToSourceGeneratedInteropFix> CreateAllFixesForDiagnosticOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> options)
78
bool warnForAdditionalWork = options.TryGetValue(
Option
.MayRequireAdditionalWork, out
Option
mayRequireAdditionalWork) && mayRequireAdditionalWork is
Option
.Bool(true);
80
CharSet? charSet = options.TryGetValue(CharSetOption, out
Option
charSetOption) && charSetOption is
Option
.String(string charSetString) && Enum.TryParse<CharSet>(charSetString, out CharSet result) ? result : null;
112
selectedOptions.Add(SelectedSuffixOption, new
Option
.String("A")));
124
selectedOptions.Add(SelectedSuffixOption, new
Option
.String("W")));
129
protected override Func<DocumentEditor, CancellationToken, Task> CreateFixForSelectedOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> selectedOptions)
131
bool warnForAdditionalWork = selectedOptions.TryGetValue(
Option
.MayRequireAdditionalWork, out
Option
mayRequireAdditionalWork) && mayRequireAdditionalWork is
Option
.Bool(true);
132
char? suffix = selectedOptions.TryGetValue(SelectedSuffixOption, out
Option
selectedSuffixOption) && selectedSuffixOption is
Option
.String(string selectedSuffix) ? selectedSuffix[0] : null;
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (26)
27
protected virtual IEnumerable<ConvertToSourceGeneratedInteropFix> CreateAllFixesForDiagnosticOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> options)
33
protected abstract Func<DocumentEditor, CancellationToken, Task> CreateFixForSelectedOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> selectedOptions);
35
protected abstract string GetDiagnosticTitle(ImmutableDictionary<string,
Option
> selectedOptions);
59
public static ImmutableDictionary<string,
Option
> ParseOptionsFromEquivalenceKey(string equivalenceKey)
61
ImmutableDictionary<string,
Option
>.Builder options = ImmutableDictionary.CreateBuilder<string,
Option
>();
86
public static string CreateEquivalenceKeyFromOptions(string baseEquivalenceKey, ImmutableDictionary<string,
Option
> options)
97
protected abstract ImmutableDictionary<string,
Option
> ParseOptionsFromDiagnostic(Diagnostic diagnostic);
99
protected abstract ImmutableDictionary<string,
Option
> CombineOptions(ImmutableDictionary<string,
Option
> fixAllOptions, ImmutableDictionary<string,
Option
> diagnosticOptions);
101
private ImmutableDictionary<string,
Option
> GetOptionsForIndividualFix(ImmutableDictionary<string,
Option
> fixAllOptions, Diagnostic diagnostic)
135
var selectedOptions = fix.SelectedOptions.Add(
Option
.AllowUnsafe, new
Option
.Bool(true));
141
Option
.CreateEquivalenceKeyFromOptions(BaseEquivalenceKey, selectedOptions)),
157
Option
.CreateEquivalenceKeyFromOptions(BaseEquivalenceKey, fix.SelectedOptions)),
164
protected record struct ConvertToSourceGeneratedInteropFix(Func<DocumentEditor, CancellationToken, Task> ApplyFix, ImmutableDictionary<string,
Option
> SelectedOptions);
171
var options =
Option
.ParseOptionsFromEquivalenceKey(fixAllContext.CodeActionEquivalenceKey);
174
bool addUnsafe = options.TryGetValue(
Option
.AllowUnsafe, out
Option
allowUnsafeOption) && allowUnsafeOption is
Option
.Bool(true);
176
bool includeFixesWithAdditionalWork = options.TryGetValue(
Option
.MayRequireAdditionalWork, out
Option
includeFixesWithAdditionalWorkOption) && includeFixesWithAdditionalWorkOption is
Option
.Bool(true);
188
bool mayRequireAdditionalWork = diagnostic.Properties.TryGetValue(
Option
.MayRequireAdditionalWork, out string mayRequireAdditionalWorkString)