2 types derived from Option
Microsoft.Interop.ComInterfaceGenerator (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
59 references to Option
Microsoft.Interop.ComInterfaceGenerator (59)
Analyzers\AddGeneratedComClassFixer.cs (10)
43
protected override Func<DocumentEditor, CancellationToken, Task> CreateFixForSelectedOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> selectedOptions)
48
protected override string GetDiagnosticTitle(ImmutableDictionary<string,
Option
> selectedOptions)
50
bool allowUnsafe = selectedOptions.TryGetValue(
Option
.AllowUnsafe, out
var
allowUnsafeOption) && allowUnsafeOption is
Option
.Bool(true);
57
protected override ImmutableDictionary<string,
Option
> ParseOptionsFromDiagnostic(Diagnostic diagnostic)
59
return ImmutableDictionary<string,
Option
>.Empty;
62
protected override ImmutableDictionary<string,
Option
> CombineOptions(ImmutableDictionary<string,
Option
> fixAllOptions, ImmutableDictionary<string,
Option
> diagnosticOptions) => fixAllOptions;
Analyzers\ConvertComImportToGeneratedComInterfaceFixer.cs (23)
28
protected override string GetDiagnosticTitle(ImmutableDictionary<string,
Option
> selectedOptions)
30
return selectedOptions.TryGetValue(
Option
.AllowUnsafe, out
Option
allowUnsafeOption) && allowUnsafeOption is
Option
.Bool(true)
35
protected override Func<DocumentEditor, CancellationToken, Task> CreateFixForSelectedOptions(SyntaxNode node, ImmutableDictionary<string,
Option
> selectedOptions)
37
bool mayRequireAdditionalWork = selectedOptions.TryGetValue(
Option
.MayRequireAdditionalWork, out
Option
mayRequireAdditionalWorkOption) && mayRequireAdditionalWorkOption is
Option
.Bool(true);
38
bool addStringMarshalling = selectedOptions.TryGetValue(AddStringMarshallingOption, out
Option
addStringMarshallingOption) && addStringMarshallingOption is
Option
.Bool(true);
43
protected override ImmutableDictionary<string,
Option
> ParseOptionsFromDiagnostic(Diagnostic diagnostic)
45
var optionsBuilder = ImmutableDictionary.CreateBuilder<string,
Option
>();
49
optionsBuilder.Add(
Option
.MayRequireAdditionalWork, new
Option
.Bool(true));
53
optionsBuilder.Add(AddStringMarshallingOption, new
Option
.Bool(true));
58
protected override ImmutableDictionary<string,
Option
> CombineOptions(ImmutableDictionary<string,
Option
> fixAllOptions, ImmutableDictionary<string,
Option
> diagnosticOptions)
60
ImmutableDictionary<string,
Option
> combinedOptions = fixAllOptions;
61
if (fixAllOptions.TryGetValue(AddStringMarshallingOption, out
Option
fixAllAddStringMarshallingOption)
62
&& fixAllAddStringMarshallingOption is
Option
.Bool(true)
63
&& (!diagnosticOptions.TryGetValue(AddStringMarshallingOption, out
Option
addStringMarshallingOption)
64
|| addStringMarshallingOption is
Option
.Bool(false)))
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)