44 instantiations of Optional
Microsoft.CodeAnalysis (2)
Microsoft.CodeAnalysis.CodeStyle (14)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (14)
27parseValue: str => int.TryParse(str, out var result) ? result : new Optional<int>(),
39=> bool.TryParse(str, out var result) ? result : new Optional<bool>();
48return new Optional<bool?>(null);
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
92=> new(parseValue: str => CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(str, defaultValue, out var result) ? result : new Optional<CodeStyleOption2<bool>>(),
96=> new(parseValue: str => CodeStyleHelpers.TryParseStringEditorConfigCodeStyleOption(str, defaultValue, out var result) ? result : new Optional<CodeStyleOption2<string>>(),
104parseValue: str => TryParseEnum<T>(str, out var result) ? new Optional<T>(result) : new Optional<T>(),
118=> new(parseValue: str => map.TryGetValue(str, out var result) || alternative.TryGetValue(str, out result) ? new Optional<T>(result) : new Optional<T>(),
144return new Optional<T?>(null);
149return new Optional<T?>(parsedValue);
152return new Optional<T?>();
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.Test.Utilities (1)
Microsoft.CodeAnalysis.Workspaces (19)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (14)
27parseValue: str => int.TryParse(str, out var result) ? result : new Optional<int>(),
39=> bool.TryParse(str, out var result) ? result : new Optional<bool>();
48return new Optional<bool?>(null);
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
92=> new(parseValue: str => CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(str, defaultValue, out var result) ? result : new Optional<CodeStyleOption2<bool>>(),
96=> new(parseValue: str => CodeStyleHelpers.TryParseStringEditorConfigCodeStyleOption(str, defaultValue, out var result) ? result : new Optional<CodeStyleOption2<string>>(),
104parseValue: str => TryParseEnum<T>(str, out var result) ? new Optional<T>(result) : new Optional<T>(),
118=> new(parseValue: str => map.TryGetValue(str, out var result) || alternative.TryGetValue(str, out result) ? new Optional<T>(result) : new Optional<T>(),
144return new Optional<T?>(null);
149return new Optional<T?>(parsedValue);
152return new Optional<T?>();
Microsoft.Interop.SourceGeneration (5)
Microsoft.VisualStudio.LanguageServices (1)
413 references to Optional
ILLink.RoslynAnalyzer (1)
Microsoft.AspNetCore.App.Analyzers (4)
Microsoft.AspNetCore.Mvc.Api.Analyzers (1)
Microsoft.CodeAnalysis (27)
Microsoft.CodeAnalysis.CodeStyle (24)
Microsoft.CodeAnalysis.CodeStyle.Fixes (18)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationContext.cs (14)
180Optional<Location> contextLocation = default,
181Optional<Location?> afterThisLocation = default,
182Optional<Location?> beforeThisLocation = default,
183Optional<bool> addImports = default,
184Optional<IEnumerable<INamespaceSymbol>> additionalImports = default,
185Optional<bool> generateMembers = default,
186Optional<bool> mergeNestedNamespaces = default,
187Optional<bool> mergeAttributes = default,
188Optional<bool> generateDefaultAccessibility = default,
189Optional<bool> generateMethodBodies = default,
190Optional<bool> generateDocumentationComments = default,
191Optional<bool> autoInsertionLocation = default,
192Optional<bool> sortMembers = default,
193Optional<bool> reuseSyntax = default)
Microsoft.CodeAnalysis.CSharp (28)
FlowAnalysis\NullableWalker.cs (8)
104public readonly Optional<LocalState> StateForLambda;
120public VisitResult(TypeWithState rValueType, TypeWithAnnotations lValueType, Optional<LocalState> stateForLambda)
247/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression, Conversion, TypeWithAnnotations, TypeWithState, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, bool, Optional<LocalState>,bool, Location, ArrayBuilder<VisitResult>)"/>.
1817Analyze(walker, symbol, diagnostics, initialState is null ? (Optional<LocalState>)default : LocalState.Create(initialState.VariableNullableStates), snapshotBuilderOpt, requiresAnalysis);
1834Optional<LocalState> initialState,
8005var lambdaState = visitResult.StateForLambda;
8850Optional<LocalState> stateForLambda = default,
9924private void VisitLambda(BoundLambda node, NamedTypeSymbol? delegateTypeOpt, Optional<LocalState> initialState = default)
Microsoft.CodeAnalysis.CSharp.CodeStyle (7)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Features (12)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (3)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (12)
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Microsoft.CodeAnalysis.ExternalAccess.Razor (8)
Remote\RazorRemoteHostClient.cs (4)
46public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
60public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
74public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
88public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
Remote\RazorRemoteServiceConnectionWrapper.cs (4)
28public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
38public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
51public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
65public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, RazorPinnedSolutionInfoWrapper, RazorRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Features (42)
Completion\CompletionItem.cs (12)
345Optional<TextSpan> span = default,
346Optional<string> displayText = default,
347Optional<string> filterText = default,
348Optional<string> sortText = default,
349Optional<ImmutableArray<KeyValuePair<string, string>>> properties = default,
350Optional<ImmutableArray<string>> tags = default,
351Optional<CompletionItemRules> rules = default,
352Optional<string> displayTextPrefix = default,
353Optional<string> displayTextSuffix = default,
354Optional<string> inlineDescription = default,
355Optional<bool> isComplexTextEdit = default,
356Optional<ImmutableArray<string>> additionalFilterTexts = default)
Microsoft.CodeAnalysis.Remote.Workspaces (22)
BrokeredServiceConnection.cs (6)
114public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
147public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, RemoteServiceCallbackId, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
181public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(SolutionCompilationState compilationState, Func<TService, Checksum, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
214public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(SolutionCompilationState compilationState, ProjectId projectId, Func<TService, Checksum, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
250public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(SolutionCompilationState compilationState, Func<TService, Checksum, RemoteServiceCallbackId, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
288public override async ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(SolutionCompilationState compilationState, ProjectId projectId, Func<TService, Checksum, RemoteServiceCallbackId, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
ExternalAccess\Pythia\Api\PythiaRemoteHostClient.cs (4)
46public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
60public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, PythiaRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
74public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, PythiaPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
88public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, PythiaPinnedSolutionInfoWrapper, PythiaRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
ExternalAccess\Pythia\Api\PythiaRemoteServiceConnectionWrapper.cs (4)
28public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
38public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, PythiaRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
51public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, PythiaPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
65public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, PythiaPinnedSolutionInfoWrapper, PythiaRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
ExternalAccess\UnitTesting\Api\UnitTestingRemoteHostClient.cs (4)
46public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
60public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Func<TService, UnitTestingRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
74public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, UnitTestingPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken) where TService : class
88public async ValueTask<Optional<TResult>> TryInvokeAsync<TService, TResult>(Solution solution, Func<TService, UnitTestingPinnedSolutionInfoWrapper, UnitTestingRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, object callbackTarget, CancellationToken cancellationToken) where TService : class
ExternalAccess\UnitTesting\Api\UnitTestingRemoteServiceConnectionWrapper.cs (4)
28public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
38public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Func<TService, UnitTestingRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
51public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, UnitTestingPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
65public ValueTask<Optional<TResult>> TryInvokeAsync<TResult>(Solution solution, Func<TService, UnitTestingPinnedSolutionInfoWrapper, UnitTestingRemoteServiceCallbackIdWrapper, CancellationToken, ValueTask<TResult>> invocation, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Test.Utilities (9)
Microsoft.CodeAnalysis.VisualBasic (8)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (1)
Microsoft.CodeAnalysis.Workspaces (142)
CodeRefactorings\FixAllOccurences\FixAllProvider.cs (4)
58public static FixAllProvider Create(Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync)
78Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync,
94Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync,
97protected override Task<Document?> FixAllAsync(FixAllContext context, Document document, Optional<ImmutableArray<TextSpan>> fixAllSpans)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationContext.cs (14)
180Optional<Location> contextLocation = default,
181Optional<Location?> afterThisLocation = default,
182Optional<Location?> beforeThisLocation = default,
183Optional<bool> addImports = default,
184Optional<IEnumerable<INamespaceSymbol>> additionalImports = default,
185Optional<bool> generateMembers = default,
186Optional<bool> mergeNestedNamespaces = default,
187Optional<bool> mergeAttributes = default,
188Optional<bool> generateDefaultAccessibility = default,
189Optional<bool> generateMethodBodies = default,
190Optional<bool> generateDocumentationComments = default,
191Optional<bool> autoInsertionLocation = default,
192Optional<bool> sortMembers = default,
193Optional<bool> reuseSyntax = default)
Storage\SQLite\v2\SQLitePersistentStorage.Accessor.cs (9)
127var optional = ReadColumn(
145var optional = ReadColumn(
156private Optional<T> ReadColumn<T, TData>(
159Func<TData, SqlConnection, Database, long, Optional<T>> readColumn,
187var optional = ReadColumnHelper(connection, Database.WriteCache, databaseKey, dataNameId);
204Optional<T> ReadColumnHelper(SqlConnection connection, Database database, TDatabaseKey databaseKey, int dataNameID)
262private Optional<Stream> ReadDataBlob(
295private Optional<Checksum> ReadChecksum(
314var storedChecksum = connection.ReadChecksum_MustRunInTransaction(database, Table, rowId);
Workspace\Solution\ProjectInfo.cs (14)
286Optional<CompilationOptions?> compilationOptions = default,
287Optional<ParseOptions?> parseOptions = default,
294Optional<Type?> hostObjectType = default)
537Optional<string?> filePath = default,
538Optional<string?> outputPath = default,
539Optional<string?> outputRefPath = default,
540Optional<CompilationOutputInfo> compilationOutputInfo = default,
541Optional<string?> defaultNamespace = default,
542Optional<SourceHashAlgorithm> checksumAlgorithm = default,
543Optional<bool> isSubmission = default,
544Optional<bool> hasAllInformation = default,
545Optional<bool> runAnalyzers = default,
546Optional<Guid> telemetryId = default,
547Optional<bool> hasSdkCodeStyleAnalyzers = default)
Microsoft.Interop.SourceGeneration (5)
Microsoft.VisualStudio.LanguageServices (12)
Options\VisualStudioSettingsOptionPersister.cs (9)
65var result = TryReadAndMonitorOptionValue(optionKey, storageKey, storageKey, optionKey.Option.Type, optionKey.Option.DefaultValue);
74var fallbackResult = lazyReadFallback.Value.TryRead(
89public Optional<object?> TryReadAndMonitorOptionValue(OptionKey2 primaryOptionKey, string primaryStorageKey, string storageKey, Type storageType, object? defaultValue)
96internal static Optional<object?> TryReadOptionValue(ISettingsManager manager, string storageKey, Type storageType, object? defaultValue)
108return manager.TryGetValue(storageKey, out int value) == GetValueResult.Success ? Enum.ToObject(storageType, value) : default(Optional<object?>);
187Optional<object?> Read<T>()
188=> manager.TryGetValue(storageKey, out T value) == GetValueResult.Success ? value : default(Optional<object?>);
190Optional<object?> ReadImmutableArray<T>()
191=> manager.TryGetValue(storageKey, out T[] value) == GetValueResult.Success ? (value is null ? default : value.ToImmutableArray()) : default(Optional<object?>);
Microsoft.VisualStudio.LanguageServices.CSharp (6)
Roslyn.VisualStudio.Next.UnitTests (14)
Options\VisualStudioSettingsOptionPersisterTests.cs (6)
186var result = VisualStudioSettingsOptionPersister.TryReadOptionValue(mockManager, "key", optionType, defaultValue);
225var result = VisualStudioSettingsOptionPersister.TryReadOptionValue(mockManager, "key", optionType, optionValue);
241Optional<object?> newValue = default;
250var result = VisualStudioSettingsOptionPersister.TryReadOptionValue(mockManager, "key", type, defaultValue: null);
279Optional<object?> newValue = default;
288var result = VisualStudioSettingsOptionPersister.TryReadOptionValue(mockManager, "key", type, defaultValue);
Options\VisualStudioStorageReadFallbackTests.cs (8)
25Assert.Equal(default(Optional<object?>), fallback.TryRead(language, (_, _, _) => default(Optional<object?>)));
32fallback.TryRead(language, (storageKey, _, _) => storageKey == "TextEditor.CSharp.Specific.SpaceWithinExpressionParentheses" ? false : default(Optional<object?>)).Value,
37fallback.TryRead(language, (storageKey, _, _) => storageKey == "TextEditor.CSharp.Specific.SpaceWithinExpressionParentheses" ? true : default(Optional<object?>)).Value,
49Assert.Equal(default(Optional<object?>), fallback.TryRead(language, (_, _, _) => default(Optional<object?>)));
56fallback.TryRead(language, (storageKey, _, _) => storageKey == "TextEditor.CSharp.Specific.NewLinesForBracesInObjectCollectionArrayInitializers" ? false : default(Optional<object?>)).Value,
61fallback.TryRead(language, (storageKey, _, _) => storageKey == "TextEditor.CSharp.Specific.NewLinesForBracesInObjectCollectionArrayInitializers" ? true : default(Optional<object?>)).Value,