6 writes to Value
Microsoft.CodeAnalysis.VisualBasic (6)
Analysis\FlowAnalysis\DataFlowPass.vb (6)
1455Me.IntersectWith(_tryState, Me._tryState.Value) 1459Me.IntersectWith(tryState, oldTryState.Value) 1476Me.IntersectWith(finallyState, Me._tryState.Value) 1480Me.IntersectWith(tryState, oldTryState.Value) 1510Me.IntersectWith(unsetInFinally, Me._tryState.Value) 1514Me.IntersectWith(tryState, oldTryState.Value)
395 references to Value
ILLink.RoslynAnalyzer (2)
DataFlow\FeatureChecksVisitor.cs (1)
90 if (!constantValue.HasValue || constantValue.Value is not bool value)
TrimAnalysis\TrimAnalysisVisitor.cs (1)
428 object? constantValue = operation.ConstantValue.Value;
Microsoft.Analyzers.Extra (6)
CallAnalysis\Fixers\LegacyLoggingFixer.FixDetails.cs (4)
50Message = children[0].ConstantValue.Value as string ?? string.Empty; 66_ = sb.Append(stringOp.ChildOperations.First().ConstantValue.Value as string); 110value = lit.ConstantValue.Value; 114value = fieldRef.ConstantValue.Value;
CallAnalysis\StartsEndsWith.cs (2)
46var s = op.Arguments[0].Value.ConstantValue.Value as string; 52var comp = (StringComparison)op.Arguments[1].Value.ConstantValue.Value!;
Microsoft.AspNetCore.Analyzers (1)
OptionsAnalyzer.cs (1)
33options.Add(new OptionsItem(property.Property, operation.Value.ConstantValue.Value));
Microsoft.AspNetCore.App.Analyzers (5)
Http\HeaderDictionaryIndexerAnalyzer.cs (1)
36literalOperation.ConstantValue.Value is string indexerValue)
Infrastructure\EmbeddedSyntax\EmbeddedSyntaxToken.cs (4)
52kind.HasValue ? kind.Value : Kind, 53virtualChars.HasValue ? virtualChars.Value : VirtualChars, 54diagnostics.HasValue ? diagnostics.Value : Diagnostics, 55value.HasValue ? value.Value : Value);
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
ActualApiResponseMetadataFactory.cs (1)
238statusCode = (int)constant.Value;
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (1)
171!(constantValue.Value is bool boolConstantValue) ||
Microsoft.CodeAnalysis (7)
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
1607compilationEvent = optionalEvent.Value;
DiagnosticAnalyzer\AsyncQueue.cs (2)
239? Task.FromResult(result.Value) 251return result.Value;
Operations\IOperation.cs (1)
43/// If the operation is an expression that evaluates to a constant value, <see cref="Optional{Object}.HasValue"/> is true and <see cref="Optional{Object}.Value"/> is the value of the expression. Otherwise, <see cref="Optional{Object}.HasValue"/> is false.
Operations\Operation.cs (1)
92/// If the operation is an expression that evaluates to a constant value, <see cref="Optional{Object}.HasValue"/> is true and <see cref="Optional{Object}.Value"/> is the value of the expression. Otherwise, <see cref="Optional{Object}.HasValue"/> is false.
Optional.cs (2)
10/// Combines a value, <see cref="Value"/>, and a flag, <see cref="HasValue"/>, 30/// Returns <see langword="true"/> if the <see cref="Value"/> will return a meaningful value.
Microsoft.CodeAnalysis.CodeStyle (34)
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
128=> constantValue.HasValue && Equals(constantValue.Value, value);
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchExpressionHelpers.cs (3)
44if (arm.Pattern is IConstantPatternOperation { Value.ConstantValue: { HasValue: true, Value: null } }) 78if (operation is IConstantPatternOperation { Value.ConstantValue: { HasValue: true, Value: not null and var value } }) 120if (pattern is IConstantPatternOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } })
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (5)
44if (patternCaseClause.Guard.ConstantValue.Value is true) 89if (value.ConstantValue is { HasValue: true, Value: null }) 129if (value.ConstantValue.Value is null) 132var caseValue = IntegerUtilities.ToInt64(value.ConstantValue.Value); 197case ISingleValueCaseClauseOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } }:
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
39if (operation.Pattern is not IConstantPatternOperation { Value.ConstantValue.Value: true or false } constantPattern) 127ConstantValue: { HasValue: true, Value: bool constValue }
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
140value.ConstantValue.Value is string stringValue)
src\Analyzers\Core\Analyzers\SimplifyBooleanExpression\AbstractSimplifyConditionalDiagnosticAnalyzer.cs (1)
165return constantValue.HasValue && constantValue.Value is bool b && b == value;
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (2)
90if (invocation.Arguments[0].Value is ILiteralOperation { ConstantValue: { HasValue: true, Value: string value } } literal && 248=> argument.Value.ConstantValue is { HasValue: true, Value: ' ' };
src\Analyzers\Core\Analyzers\UseCompoundAssignment\AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs (1)
145var constant = semanticModel.GetConstantValue(binaryRight, cancellationToken).Value;
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
105=> trueValue is ILiteralOperation { ConstantValue: { HasValue: true, Value: bool value } } && value == val;
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (1)
266operation.ConstantValue.Value == null;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxToken.cs (6)
65kind.HasValue ? kind.Value : Kind, 66leadingTrivia.HasValue ? leadingTrivia.Value : LeadingTrivia, 67virtualChars.HasValue ? virtualChars.Value : VirtualChars, 68trailingTrivia.HasValue ? trailingTrivia.Value : TrailingTrivia, 69diagnostics.HasValue ? diagnostics.Value : Diagnostics, 70value.HasValue ? value.Value : Value);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
378=> operand is ILiteralOperation { ConstantValue: { HasValue: true, Value: null } };
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (1)
149if (current.BranchValue.ConstantValue.HasValue && current.BranchValue.ConstantValue.Value is bool constant)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (1)
485if (currentOperation.ConstantValue.Value is null)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (1)
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (1)
12=> optional.Value;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.cs (5)
114var newDistinguishRefFromOut = distinguishRefFromOut.HasValue ? distinguishRefFromOut.Value : _distinguishRefFromOut; 115var newTupleNamesMustMatch = tupleNamesMustMatch.HasValue ? tupleNamesMustMatch.Value : _tupleNamesMustMatch; 116var newIgnoreNullableAnnotations = ignoreNullableAnnotations.HasValue ? ignoreNullableAnnotations.Value : _ignoreNullableAnnotations; 117var newObjectAndDynamicCompareEqually = objectAndDynamicCompareEqually.HasValue ? objectAndDynamicCompareEqually.Value : _objectAndDynamicCompareEqually; 118var newArrayAndReadOnlySpanCompareEqually = arrayAndReadOnlySpanCompareEqually.HasValue ? arrayAndReadOnlySpanCompareEqually.Value : _arrayAndReadOnlySpanCompareEqually;
Microsoft.CodeAnalysis.CodeStyle.Fixes (20)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationContext.cs (14)
195var newContextLocation = contextLocation.HasValue ? contextLocation.Value : this.ContextLocation; 196var newAfterThisLocation = afterThisLocation.HasValue ? afterThisLocation.Value : this.AfterThisLocation; 197var newBeforeThisLocation = beforeThisLocation.HasValue ? beforeThisLocation.Value : this.BeforeThisLocation; 198var newAddImports = addImports.HasValue ? addImports.Value : this.AddImports; 199var newAdditionalImports = additionalImports.HasValue ? additionalImports.Value : this.AdditionalImports; 200var newGenerateMembers = generateMembers.HasValue ? generateMembers.Value : this.GenerateMembers; 201var newMergeNestedNamespaces = mergeNestedNamespaces.HasValue ? mergeNestedNamespaces.Value : this.MergeNestedNamespaces; 202var newMergeAttributes = mergeAttributes.HasValue ? mergeAttributes.Value : this.MergeAttributes; 203var newGenerateDefaultAccessibility = generateDefaultAccessibility.HasValue ? generateDefaultAccessibility.Value : this.GenerateDefaultAccessibility; 204var newGenerateMethodBodies = generateMethodBodies.HasValue ? generateMethodBodies.Value : this.GenerateMethodBodies; 205var newGenerateDocumentationComments = generateDocumentationComments.HasValue ? generateDocumentationComments.Value : this.GenerateDocumentationComments; 206var newAutoInsertionLocation = autoInsertionLocation.HasValue ? autoInsertionLocation.Value : this.AutoInsertionLocation; 207var newSortMembers = sortMembers.HasValue ? sortMembers.Value : this.SortMembers; 208var newReuseSyntax = reuseSyntax.HasValue ? reuseSyntax.Value : this.ReuseSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (3)
306name.HasValue ? name.Value : parameter.Name, 310? defaultValue.Value 539returnTypeAttributes: returnTypeAttributes.HasValue ? returnTypeAttributes.Value : method.GetReturnTypeAttributes(),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (3)
441if (numericValue.HasValue && numericValue.Value is 0) 479if (operation?.Kind == OperationKind.Literal && operation.ConstantValue.HasValue && operation.ConstantValue.Value is true) 483else if (operation?.Kind == OperationKind.Literal && operation.ConstantValue.HasValue && operation.ConstantValue.Value is false)
Microsoft.CodeAnalysis.CSharp (16)
FlowAnalysis\AbstractFlowPass.cs (9)
443this.State = initialState.HasValue ? initialState.Value : TopState(); 1915var tempTryStateValue = NonMonotonicState.Value; 1919var oldTryStateValue = oldTryState.Value; 1944var tempTryStateValue = NonMonotonicState.Value; 1948var oldTryStateValue = oldTryState.Value; 1989var tempTryStateValue = NonMonotonicState.Value; 1993var oldTryStateValue = oldTryState.Value; 2574var tempStateValue = NonMonotonicState.Value; 2578var oldStateValue = oldState.Value;
FlowAnalysis\AbstractFlowPass_LocalFunctions.cs (1)
166var value = NonMonotonicState.Value;
FlowAnalysis\DefiniteAssignment.cs (1)
1793var state = NonMonotonicState.Value;
FlowAnalysis\DefiniteAssignment.LocalFunctions.cs (1)
205var state = NonMonotonicState.Value;
FlowAnalysis\NullableWalker.cs (4)
1784Debug.Assert(walker._variables.Id == initialState.Value.Id); 2693var tryState = NonMonotonicState.Value; 7951return getUnboundLambda((BoundLambda)argument, GetVariableState(_variables, lambdaState.Value)); 9877initialState.HasValue ? initialState.Value : State.Clone(),
Microsoft.CodeAnalysis.CSharp.CodeStyle (14)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (3)
402semanticModel.GetConstantValue(size, cancellationToken).Value is 0) 759if (semanticModel.GetConstantValue(size, cancellationToken).Value is not int sizeValue) 815if (semanticModel.GetConstantValue(elementArgument.Expression, cancellationToken).Value is not int indexValue ||
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
147if (constant.Value is int value)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
273operation.ConstantValue.Value is int i &&
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (1)
88if (constantValue.Value is not string stringValue)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (4)
104if (constantValue.Value is null) 114if (constantValue.Value is not null) 145if (constantValue.Value is null) 159if (constantValue.Value is not null)
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
207if (element.ConstantValue.Value is not byte b)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (3)
139IntegerUtilities.IsIntegral(constantValue.Value) && 140IntegerUtilities.ToInt64(constantValue.Value) == 0; 956=> operation.ConstantValue.HasValue && operation.ConstantValue.Value is null;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (4)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
707ConstantValue.Value: false, 891ConstantValue.Value: true,
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
102var newLiteral = generator.LiteralExpression(constant.Value);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseRangeOperatorCodeFixProvider.cs (1)
210=> (int)operation.ConstantValue.Value!; // Safe as we already confirmed this was an int when making the result.
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.cs (1)
96Assert.Equal("M", constantValue.Value);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (1)
CodeGen\CodeGenTupleEqualityTests.cs (1)
693Assert.Equal(1, model.GetConstantValue(tuple2.Arguments[1].Expression).Value);
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Emit\NumericIntPtrTests.cs (1)
2890Assert.Equal(expectedValue, value.Value);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
FieldKeywordTests.cs (1)
9479return (model.GetConstantValue(value).Value, typeInfo.Type.ToTestDisplayString(), typeInfo.ConvertedType.ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Features (18)
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (1)
121if (checkIdObject.HasValue && checkIdObject.Value is string checkId)
ReverseForStatement\CSharpReverseForStatementCodeRefactoringProvider.cs (2)
109=> valueOpt.HasValue && IsIntegral(valueOpt.Value) && ToUInt64(valueOpt.Value) == value;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (3)
402semanticModel.GetConstantValue(size, cancellationToken).Value is 0) 759if (semanticModel.GetConstantValue(size, cancellationToken).Value is not int sizeValue) 815if (semanticModel.GetConstantValue(elementArgument.Expression, cancellationToken).Value is not int indexValue ||
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
147if (constant.Value is int value)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
273operation.ConstantValue.Value is int i &&
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (1)
88if (constantValue.Value is not string stringValue)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (4)
104if (constantValue.Value is null) 114if (constantValue.Value is not null) 145if (constantValue.Value is null) 159if (constantValue.Value is not null)
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
207if (element.ConstantValue.Value is not byte b)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
707ConstantValue.Value: false, 891ConstantValue.Value: true,
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
102var newLiteral = generator.LiteralExpression(constant.Value);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseRangeOperatorCodeFixProvider.cs (1)
210=> (int)operation.ConstantValue.Value!; // Safe as we already confirmed this was an int when making the result.
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (12)
Semantics\ConstantTests.cs (1)
2927Assert.Equal(6, constantValue.Value);
Semantics\ImplicitObjectCreationTests.cs (1)
243Assert.Equal(constant, model.GetConstantValue(@new).Value?.ToString());
Semantics\LambdaTests.cs (1)
8063Assert.Equal(1, constantValue.Value);
Semantics\NativeIntegerTests.cs (1)
7054Assert.Equal(expectedValue, value.Value);
Semantics\NullableReferenceTypesTests.cs (2)
1869Assert.Equal(3, model.GetConstantValue(suppressions[0]).Value); 1870Assert.Null(model.GetConstantValue(suppressions[1]).Value);
Semantics\TargetTypedDefaultTests.cs (5)
48Assert.Equal("0", model.GetConstantValue(def).Value.ToString()); 148Assert.Equal("0", model.GetConstantValue(def).Value.ToString()); 1147Assert.Equal("0", model.GetConstantValue(def).Value.ToString()); 3521Assert.Equal((short)0, model.GetConstantValue(def).Value); 3528Assert.Equal((short)0, model.GetConstantValue(conversionSyntax).Value);
Semantics\UnsafeTests.cs (1)
11347Assert.Equal((short)20, countSummary.ConstantValue.Value);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (41)
Compilation\GetSemanticInfoTests.cs (3)
1428Assert.Null(bindInfo.ConstantValue.Value); 1469Assert.Null(bindInfo.ConstantValue.Value); 1503Assert.Null(bindInfo.ConstantValue.Value);
Compilation\SemanticModelAPITests.cs (26)
1439Assert.Equal("Hello", constantInfo.Value); 1477Assert.Equal((short)0, constantInfo.Value); 1525Assert.Equal((short)0, constantInfo.Value); 1613Assert.Equal((short)0, constantInfo.Value); 1698Assert.Equal("Hello", constantInfo.Value); 2787Assert.Equal(1, constantVal.Value); 3915Assert.Equal(0, (short)value0.Value); 4109Assert.Equal("Hello, world!", model.GetConstantValue(actual[0]).Value); 4146Assert.Equal("Number 3", model.GetConstantValue(actual[0]).Value); 4149Assert.Equal("Level 5 Number 3", model.GetConstantValue(actual[1]).Value); 4154Assert.Equal("Testing", model.GetConstantValue(actual[3]).Value); 4157Assert.Equal("ConstantInterpolatedString", model.GetConstantValue(actual[4]).Value); 4160Assert.Equal("Level 5", model.GetConstantValue(actual[5]).Value); 4163Assert.Equal("Radio Noise", model.GetConstantValue(actual[6]).Value); 4166Assert.Equal("Level 5", model.GetConstantValue(actual[7]).Value); 4189Assert.Equal("Hello, world!", model.GetConstantValue(actual[0]).Value); 4214Assert.Equal(0, model.GetConstantValue(actual[0]).Value); 4218Assert.Equal(true, model.GetConstantValue(actual[1]).Value); 4242Assert.Null(model.GetConstantValue(actual[0]).Value); 4279Assert.Equal("Number 3", model.GetConstantValue(actual[0]).Value); 4283Assert.Equal("Level 5 Number 3", model.GetConstantValue(actual[1]).Value); 4290Assert.Equal("Testing", model.GetConstantValue(actual[3]).Value); 4294Assert.Equal("ConstantInterpolatedString", model.GetConstantValue(actual[4]).Value); 4298Assert.Equal("Level 5", model.GetConstantValue(actual[5]).Value); 4302Assert.Equal("Radio Noise", model.GetConstantValue(actual[6]).Value); 4306Assert.Equal("Level 5", model.GetConstantValue(actual[7]).Value);
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (6)
4277Assert.Equal(4, constantInfo.Value); 4292Assert.Equal("hello", constantInfo.Value); 4338Assert.Equal("hello", constantInfo.Value); 4361Assert.Equal("hello", constantInfo.Value); 4383Assert.Equal("hello", constantInfo.Value); 5665Assert.Equal(expectedConstant, actualConstant.Value);
Compilation\SemanticModelGetSemanticInfoTests.cs (6)
1759Assert.Null(semanticInfo.ConstantValue.Value); 3948Assert.Null(semanticInfo.ConstantValue.Value); 6211Assert.Equal(5, (int)semanticInfo.ConstantValue.Value); 8572Assert.Null(semanticInfo.ConstantValue.Value); 8780Assert.Null(semanticInfo.ConstantValue.Value); 11509Assert.Null(semanticInfo.ConstantValue.Value);
Microsoft.CodeAnalysis.CSharp.Workspaces (4)
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (1)
275if (nameofValueOpt.Value is string existingVal &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (3)
139IntegerUtilities.IsIntegral(constantValue.Value) && 140IntegerUtilities.ToInt64(constantValue.Value) == 0; 956=> operation.ConstantValue.HasValue && operation.ConstantValue.Value is null;
Microsoft.CodeAnalysis.Features (56)
Completion\CompletionItem.cs (12)
358var newSpan = span.HasValue ? span.Value : Span; 359var newDisplayText = displayText.HasValue ? displayText.Value : DisplayText; 360var newFilterText = filterText.HasValue ? filterText.Value : FilterText; 361var newSortText = sortText.HasValue ? sortText.Value : SortText; 362var newInlineDescription = inlineDescription.HasValue ? inlineDescription.Value : InlineDescription; 363var newProperties = properties.HasValue ? properties.Value : _properties; 364var newTags = tags.HasValue ? tags.Value : Tags; 365var newRules = rules.HasValue ? rules.Value : Rules; 366var newDisplayTextPrefix = displayTextPrefix.HasValue ? displayTextPrefix.Value : DisplayTextPrefix; 367var newDisplayTextSuffix = displayTextSuffix.HasValue ? displayTextSuffix.Value : DisplayTextSuffix; 368var newIsComplexTextEdit = isComplexTextEdit.HasValue ? isComplexTextEdit.Value : IsComplexTextEdit; 369var newAdditionalFilterTexts = additionalFilterTexts.HasValue ? additionalFilterTexts.Value.NullToEmpty() : AdditionalFilterTexts;
Completion\CompletionItemRules.cs (6)
180var newFilterRules = filterRules.HasValue ? filterRules.Value : FilterCharacterRules; 181var newCommitRules = commitRules.HasValue ? commitRules.Value : CommitCharacterRules; 182var newEnterKeyRule = enterKeyRule.HasValue ? enterKeyRule.Value : EnterKeyRule; 183var newFormatOnCommit = formatOnCommit.HasValue ? formatOnCommit.Value : FormatOnCommit; 184var newMatchPriority = matchPriority.HasValue ? matchPriority.Value : MatchPriority; 185var newSelectionBehavior = selectionBehavior.HasValue ? selectionBehavior.Value : SelectionBehavior;
Completion\CompletionList.cs (4)
128var newSpan = span.HasValue ? span.Value : Span; 129var newItemsList = itemsList.HasValue ? itemsList.Value : ItemsList; 130var newRules = rules.HasValue ? rules.Value : Rules; 131var newSuggestionModeItem = suggestionModeItem.HasValue ? suggestionModeItem.Value : SuggestionModeItem;
Completion\CompletionRules.cs (5)
103var newDismissIfEmpty = dismissIfEmpty.HasValue ? dismissIfEmpty.Value : DismissIfEmpty; 104var newDismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted.HasValue ? dismissIfLastCharacterDeleted.Value : DismissIfLastCharacterDeleted; 105var newDefaultCommitCharacters = defaultCommitCharacters.HasValue ? defaultCommitCharacters.Value : DefaultCommitCharacters; 106var newDefaultEnterKeyRule = defaultEnterKeyRule.HasValue ? defaultEnterKeyRule.Value : DefaultEnterKeyRule; 107var newSnippetsRule = snippetsRule.HasValue ? snippetsRule.Value : SnippetsRule;
EmbeddedLanguages\Json\LanguageServices\JsonLanguageDetector.cs (2)
187semanticModel.GetConstantValue(initExpr).Value is true) 192semanticModel.GetConstantValue(initExpr).Value is (byte)JsonCommentHandling.Allow or (byte)JsonCommentHandling.Skip)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexLanguageDetector.cs (1)
189if (constVal.Value is int intValue)
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
128=> constantValue.HasValue && Equals(constantValue.Value, value);
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchExpressionHelpers.cs (3)
44if (arm.Pattern is IConstantPatternOperation { Value.ConstantValue: { HasValue: true, Value: null } }) 78if (operation is IConstantPatternOperation { Value.ConstantValue: { HasValue: true, Value: not null and var value } }) 120if (pattern is IConstantPatternOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } })
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (5)
44if (patternCaseClause.Guard.ConstantValue.Value is true) 89if (value.ConstantValue is { HasValue: true, Value: null }) 129if (value.ConstantValue.Value is null) 132var caseValue = IntegerUtilities.ToInt64(value.ConstantValue.Value); 197case ISingleValueCaseClauseOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } }:
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
39if (operation.Pattern is not IConstantPatternOperation { Value.ConstantValue.Value: true or false } constantPattern) 127ConstantValue: { HasValue: true, Value: bool constValue }
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
140value.ConstantValue.Value is string stringValue)
src\Analyzers\Core\Analyzers\SimplifyBooleanExpression\AbstractSimplifyConditionalDiagnosticAnalyzer.cs (1)
165return constantValue.HasValue && constantValue.Value is bool b && b == value;
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (2)
90if (invocation.Arguments[0].Value is ILiteralOperation { ConstantValue: { HasValue: true, Value: string value } } literal && 248=> argument.Value.ConstantValue is { HasValue: true, Value: ' ' };
src\Analyzers\Core\Analyzers\UseCompoundAssignment\AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs (1)
145var constant = semanticModel.GetConstantValue(binaryRight, cancellationToken).Value;
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
105=> trueValue is ILiteralOperation { ConstantValue: { HasValue: true, Value: bool value } } && value == val;
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (1)
266operation.ConstantValue.Value == null;
Structure\BlockSpan.cs (8)
105var newIsCollapsible = isCollapsible.HasValue ? isCollapsible.Value : IsCollapsible; 106var newTextSpan = textSpan.HasValue ? textSpan.Value : TextSpan; 107var newHintSpan = hintSpan.HasValue ? hintSpan.Value : HintSpan; 108var newPrimarySpans = subHeadings.HasValue ? subHeadings.Value : SubHeadings; 109var newType = type.HasValue ? type.Value : Type; 110var newBannerText = bannerText.HasValue ? bannerText.Value : BannerText; 111var newAutoCollapse = autoCollapse.HasValue ? autoCollapse.Value : AutoCollapse; 112var newIsDefaultCollapsed = isDefaultCollapsed.HasValue ? isDefaultCollapsed.Value : IsDefaultCollapsed;
Microsoft.CodeAnalysis.Test.Utilities (19)
Compilation\OperationTreeVerifier.cs (1)
222LogConstant(constant.Value, header);
Compilation\TestOperationVisitor.cs (1)
1723if (!operation.Value.ConstantValue.HasValue || operation.Value.ConstantValue.Value != null)
Diagnostics\EmptyArrayAnalyzer.cs (2)
80arrayLength.Value is int && 81(int)arrayLength.Value == 0)
Diagnostics\OperationTestAnalyzer.cs (14)
164int testValue = (int)conditionRight.ConstantValue.Value; 180int initialValue = (int)setupAssignment.Value.ConstantValue.Value; 195var incrementValue = (int)advanceIncrementOpt.Value; 359int singleValue = (int)singleValueExpression.ConstantValue.Value; 382int rangeMinValue = (int)rangeMinExpression.ConstantValue.Value; 383int rangeMaxValue = (int)rangeMaxExpression.ConstantValue.Value; 404int relationalValue = (int)relationalValueExpression.ConstantValue.Value; 589int integerArgument = (int)argumentValue.Value; 633(int)literal.ConstantValue.Value == 17) 668if (argument.Value.ConstantValue.HasValue && argument.Value.ConstantValue.Value == null) 1109if (dimensionSize.HasValue && IntegralValue(dimensionSize.Value) > 3) 1136if (dimensionSize.HasValue && IntegralValue(dimensionSize.Value) > 3) 1623if (rightValue.HasValue && rightValue.Value is int && (int)rightValue.Value == 10)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (1)
149if (current.BranchValue.ConstantValue.HasValue && current.BranchValue.ConstantValue.Value is bool constant)
Microsoft.CodeAnalysis.VisualBasic (4)
Analysis\FlowAnalysis\DataFlowPass.vb (4)
678Dim tryState = Me._tryState.Value 1458Dim tryState = Me._tryState.Value 1479Dim tryState = Me._tryState.Value 1513Dim tryState = Me._tryState.Value
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (7)
Compilation\SemanticModelAPITests.vb (7)
624Assert.Equal(3, initializerConstantVal.Value) 677Assert.Equal("hi", constantInfo.Value) 730Assert.Equal(CType(0, System.Int16), constantInfo.Value) 1251Assert.Equal(4, constantInfo.Value) 1268Assert.Equal("hello", constantInfo.Value) 1316Assert.Equal("hello", constantInfo.Value) 1352Assert.Equal("hello", constantInfo.Value)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
Simplification\Simplifiers\AbstractVisualBasicSimplifier.vb (1)
161Dim existingValue = TryCast(nameofValueOpt.Value, String)
Microsoft.CodeAnalysis.Workspaces (78)
Classification\AbstractClassificationService.cs (3)
98classifiedSpans.Value.Rehydrate(result); 130if (!cachedSpans.HasValue || cachedSpans.Value == null) 133cachedSpans.Value.Rehydrate(result);
CodeFixes\FixAllOccurrences\FixAllContext.cs (1)
340var newCancellationToken = cancellationToken.HasValue ? cancellationToken.Value : this.CancellationToken;
CodeFixesAndRefactorings\CommonFixAllState.cs (3)
51var (newDocument, newProject) = documentAndProject.HasValue ? documentAndProject.Value : (Document, Project); 52var newScope = scope.HasValue ? scope.Value : Scope; 53var newCodeActionEquivalenceKey = codeActionEquivalenceKey.HasValue ? codeActionEquivalenceKey.Value : CodeActionEquivalenceKey;
CodeRefactorings\FixAllOccurences\FixAllContext.cs (1)
106var newCancellationToken = cancellationToken.HasValue ? cancellationToken.Value : this.CancellationToken;
CodeRefactorings\SyntaxEditorBasedCodeRefactoringProvider.cs (1)
60var spans = fixAllSpans.HasValue ? fixAllSpans.Value : [editor.OriginalRoot.FullSpan];
FindSymbols\Declarations\DeclarationFinder_AllDeclarations.cs (1)
52return await RehydrateAsync(solution, result.Value, cancellationToken).ConfigureAwait(false);
FindSymbols\Declarations\DeclarationFinder_SourceDeclarations.cs (4)
56return await RehydrateAsync(solution, result.Value, cancellationToken).ConfigureAwait(false); 94return await RehydrateAsync(project.Solution, result.Value, cancellationToken).ConfigureAwait(false); 127return await RehydrateAsync(solution, result.Value, cancellationToken).ConfigureAwait(false); 160return await RehydrateAsync(project.Solution, result.Value, cancellationToken).ConfigureAwait(false);
Shared\TestHooks\AsynchronousOperationListenerProvider.cs (1)
137if (isCompleted.HasValue && !isCompleted.Value)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxToken.cs (6)
65kind.HasValue ? kind.Value : Kind, 66leadingTrivia.HasValue ? leadingTrivia.Value : LeadingTrivia, 67virtualChars.HasValue ? virtualChars.Value : VirtualChars, 68trailingTrivia.HasValue ? trailingTrivia.Value : TrailingTrivia, 69diagnostics.HasValue ? diagnostics.Value : Diagnostics, 70value.HasValue ? value.Value : Value);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
378=> operand is ILiteralOperation { ConstantValue: { HasValue: true, Value: null } };
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (1)
149if (current.BranchValue.ConstantValue.HasValue && current.BranchValue.ConstantValue.Value is bool constant)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (1)
485if (currentOperation.ConstantValue.Value is null)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (1)
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\OptionalExtensions.cs (1)
12=> optional.Value;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.cs (5)
114var newDistinguishRefFromOut = distinguishRefFromOut.HasValue ? distinguishRefFromOut.Value : _distinguishRefFromOut; 115var newTupleNamesMustMatch = tupleNamesMustMatch.HasValue ? tupleNamesMustMatch.Value : _tupleNamesMustMatch; 116var newIgnoreNullableAnnotations = ignoreNullableAnnotations.HasValue ? ignoreNullableAnnotations.Value : _ignoreNullableAnnotations; 117var newObjectAndDynamicCompareEqually = objectAndDynamicCompareEqually.HasValue ? objectAndDynamicCompareEqually.Value : _objectAndDynamicCompareEqually; 118var newArrayAndReadOnlySpanCompareEqually = arrayAndReadOnlySpanCompareEqually.HasValue ? arrayAndReadOnlySpanCompareEqually.Value : _arrayAndReadOnlySpanCompareEqually;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationContext.cs (14)
195var newContextLocation = contextLocation.HasValue ? contextLocation.Value : this.ContextLocation; 196var newAfterThisLocation = afterThisLocation.HasValue ? afterThisLocation.Value : this.AfterThisLocation; 197var newBeforeThisLocation = beforeThisLocation.HasValue ? beforeThisLocation.Value : this.BeforeThisLocation; 198var newAddImports = addImports.HasValue ? addImports.Value : this.AddImports; 199var newAdditionalImports = additionalImports.HasValue ? additionalImports.Value : this.AdditionalImports; 200var newGenerateMembers = generateMembers.HasValue ? generateMembers.Value : this.GenerateMembers; 201var newMergeNestedNamespaces = mergeNestedNamespaces.HasValue ? mergeNestedNamespaces.Value : this.MergeNestedNamespaces; 202var newMergeAttributes = mergeAttributes.HasValue ? mergeAttributes.Value : this.MergeAttributes; 203var newGenerateDefaultAccessibility = generateDefaultAccessibility.HasValue ? generateDefaultAccessibility.Value : this.GenerateDefaultAccessibility; 204var newGenerateMethodBodies = generateMethodBodies.HasValue ? generateMethodBodies.Value : this.GenerateMethodBodies; 205var newGenerateDocumentationComments = generateDocumentationComments.HasValue ? generateDocumentationComments.Value : this.GenerateDocumentationComments; 206var newAutoInsertionLocation = autoInsertionLocation.HasValue ? autoInsertionLocation.Value : this.AutoInsertionLocation; 207var newSortMembers = sortMembers.HasValue ? sortMembers.Value : this.SortMembers; 208var newReuseSyntax = reuseSyntax.HasValue ? reuseSyntax.Value : this.ReuseSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (3)
306name.HasValue ? name.Value : parameter.Name, 310? defaultValue.Value 539returnTypeAttributes: returnTypeAttributes.HasValue ? returnTypeAttributes.Value : method.GetReturnTypeAttributes(),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (3)
441if (numericValue.HasValue && numericValue.Value is 0) 479if (operation?.Kind == OperationKind.Literal && operation.ConstantValue.HasValue && operation.ConstantValue.Value is true) 483else if (operation?.Kind == OperationKind.Literal && operation.ConstantValue.HasValue && operation.ConstantValue.Value is false)
Storage\SQLite\v2\SQLitePersistentStorage.Accessor.cs (4)
133return optional.HasValue && checksum == optional.Value; 152Contract.ThrowIfTrue(optional.HasValue && optional.Value == null); 153return optional.HasValue ? optional.Value : null; 315return storedChecksum.HasValue && checksum == storedChecksum.Value;
Workspace\Solution\DocumentInfo.cs (6)
104var newLoader = loader.HasValue ? loader.Value : TextLoader; 105var newDocumentServiceProvider = documentServiceProvider.HasValue ? documentServiceProvider.Value : DocumentServiceProvider; 207var newSourceCodeKind = sourceCodeKind.HasValue ? sourceCodeKind.Value : SourceCodeKind; 208var newFilePath = filePath.HasValue ? filePath.Value : FilePath; 209var newIsGenerated = isGenerated.HasValue ? isGenerated.Value : IsGenerated; 210var newDesignTimeOnly = designTimeOnly.HasValue ? designTimeOnly.Value : DesignTimeOnly;
Workspace\Solution\ProjectInfo.cs (14)
297var newCompilationOptions = compilationOptions.HasValue ? compilationOptions.Value : CompilationOptions; 298var newParseOptions = parseOptions.HasValue ? parseOptions.Value : ParseOptions; 305var newHostObjectType = hostObjectType.HasValue ? hostObjectType.Value : HostObjectType; 553var newFilePath = filePath.HasValue ? filePath.Value : FilePath; 554var newOutputPath = outputPath.HasValue ? outputPath.Value : OutputFilePath; 555var newOutputRefPath = outputRefPath.HasValue ? outputRefPath.Value : OutputRefFilePath; 556var newCompilationOutputPaths = compilationOutputInfo.HasValue ? compilationOutputInfo.Value : CompilationOutputInfo; 557var newDefaultNamespace = defaultNamespace.HasValue ? defaultNamespace.Value : DefaultNamespace; 558var newChecksumAlgorithm = checksumAlgorithm.HasValue ? checksumAlgorithm.Value : ChecksumAlgorithm; 559var newIsSubmission = isSubmission.HasValue ? isSubmission.Value : IsSubmission; 560var newHasAllInformation = hasAllInformation.HasValue ? hasAllInformation.Value : HasAllInformation; 561var newRunAnalyzers = runAnalyzers.HasValue ? runAnalyzers.Value : RunAnalyzers; 562var newTelemetryId = telemetryId.HasValue ? telemetryId.Value : TelemetryId; 563var newHasSdkCodeStyleAnalyzers = hasSdkCodeStyleAnalyzers.HasValue ? hasSdkCodeStyleAnalyzers.Value : HasSdkCodeStyleAnalyzers;
Workspace\Solution\SolutionCompilationState.cs (1)
124var newFrozenSourceGeneratedDocumentStates = frozenSourceGeneratedDocumentStates.HasValue ? frozenSourceGeneratedDocumentStates.Value : FrozenSourceGeneratedDocumentStates;
Workspace\Solution\SolutionInfo.cs (2)
148var newFilePath = filePath.HasValue ? filePath.Value : FilePath; 149var newTelemetryId = telemetryId.HasValue ? telemetryId.Value : TelemetryId;
Microsoft.Interop.ComInterfaceGenerator (2)
Analyzers\ComHostingDoesNotSupportGeneratedComInterfaceAnalyzer.cs (1)
46|| ctor.Arguments[0].Value.ConstantValue.Value is not true)
src\libraries\System.Runtime.InteropServices\gen\Common\OperationExtensions.cs (1)
47return operation is { ConstantValue: { HasValue: true, Value: null } };
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\CustomMarshallerAttributeAnalyzer.cs (1)
689if (marshalModeArgument.Value is not IFieldReferenceOperation { ConstantValue.Value: var marshalMode }
src\libraries\System.Runtime.InteropServices\gen\Common\OperationExtensions.cs (1)
47return operation is { ConstantValue: { HasValue: true, Value: null } };
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
src\libraries\System.Runtime.InteropServices\gen\Common\OperationExtensions.cs (1)
47return operation is { ConstantValue: { HasValue: true, Value: null } };
Microsoft.Interop.SourceGeneration (10)
StubEnvironment.cs (10)
28return _lcidConversionAttrType.Value; 31return _lcidConversionAttrType.Value; 42return _suppressGCTransitionAttrType.Value; 45return _suppressGCTransitionAttrType.Value; 56return _unmanagedCallConvAttrType.Value; 59return _unmanagedCallConvAttrType.Value; 70return _defaultDllImportSearchPathsAttrType.Value; 73return _defaultDllImportSearchPathsAttrType.Value; 84return _wasmImportLinkageAttrType.Value; 87return _wasmImportLinkageAttrType.Value;
Microsoft.VisualStudio.LanguageServices (2)
Options\VisualStudioSettingsOptionPersister.cs (2)
68value = result.Value; 80value = fallbackResult.Value;
Microsoft.VisualStudio.LanguageServices.CSharp (4)
CodeModel\MethodXml\MethodXmlBuilder.cs (4)
265GenerateNumber(constantValue.Value, type); 269GenerateString((string)constantValue.Value); 274GenerateBoolean((bool)constantValue.Value); 297var ch = (char)constantValue.Value;
Microsoft.VisualStudio.LanguageServices.VisualBasic (6)
CodeModel\MethodXML\MethodXmlBuilder.vb (6)
245GenerateNumber(constantValue.Value, type) 249GenerateChar(CChar(constantValue.Value)) 253GenerateString(CStr(constantValue.Value)) 258GenerateBoolean(CBool(constantValue.Value)) 534If Not TypeOf constantValue.Value Is Integer Then 538Dim upperBound = CInt(constantValue.Value) + 1
Roslyn.Compilers.VisualBasic.IOperation.UnitTests (1)
IOperation\IOperationTests.vb (1)
75Assert.Equal(CInt(literal1.ConstantValue.Value), 10)
Roslyn.VisualStudio.Next.UnitTests (5)
Options\VisualStudioSettingsOptionPersisterTests.cs (5)
188Assert.Equal(optionValue, result.Value); 252Assert.True(IsDefaultImmutableArray(result.Value!)); 259Assert.Equal(serializedValue, newValue.Value); 290Assert.Equal(value, result.Value); 297Assert.Equal(serializedValue, newValue.Value);
System.Text.RegularExpressions.Generator (7)
UpgradeToGeneratedRegexAnalyzer.cs (2)
190_ = RegexParser.ParseOptionsInPattern((string)argument.Value.ConstantValue.Value!, RegexOptions.None); 211RegexOptions value = (RegexOptions)(int)argument.Value.ConstantValue.Value!;
UpgradeToGeneratedRegexCodeFixer.cs (5)
263return patternArgument.Value.ConstantValue.Value as string; 272(RegexOptions)(int)optionsArgument.Value.ConstantValue.Value!; 287string optionsLiteral = Literal(((RegexOptions)(int)argument.Value.ConstantValue.Value!).ToString()); 299else if (argument.Value.ConstantValue.Value is string str && str.Contains('\\')) 305return generator.LiteralExpression(argument.Value.ConstantValue.Value);