380 references to HasValue
ILLink.RoslynAnalyzer (3)
DataFlow\FeatureChecksVisitor.cs (1)
90 if (!constantValue.HasValue || constantValue.Value is not bool value)
TrimAnalysis\TrimAnalysisVisitor.cs (2)
185 if (!operation.ConstantValue.HasValue && // Optimization - if there is already a constant value available, rely on the Visit(IOperation) instead 427 if (operation.ConstantValue.HasValue) {
Microsoft.Analyzers.Extra (2)
CallAnalysis\Fixers\LegacyLoggingFixer.FixDetails.cs (1)
48if (children[0].ConstantValue.HasValue)
CallAnalysis\StartsEndsWith.cs (1)
50if (op.Arguments.Length > 1 && op.Arguments[1].Value.ConstantValue.HasValue)
Microsoft.AspNetCore.Analyzers (1)
OptionsAnalyzer.cs (1)
28operation.Value.ConstantValue.HasValue &&
Microsoft.AspNetCore.App.Analyzers (4)
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)
234if (operation.ConstantValue is { HasValue: true } constant)
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (1)
170if (!constantValue.HasValue ||
Microsoft.CodeAnalysis (12)
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
1598if (!optionalEvent.HasValue)
DiagnosticAnalyzer\AsyncQueue.cs (3)
238return result.HasValue 248if (!result.HasValue) 259/// <see cref="Optional{T}.HasValue"/> will be <see langword="false"/>.
Operations\IOperation.cs (2)
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 (2)
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 (4)
10/// Combines a value, <see cref="Value"/>, and a flag, <see cref="HasValue"/>, 39/// Gets the value of the current object. Not meaningful unless <see cref="HasValue"/> returns <see langword="true"/>. 43/// <see cref="HasValue"/> is <see langword="false"/>.</para> 46/// <para>The value if <see cref="HasValue"/> is <see langword="true"/>; otherwise, the default value for type
Microsoft.CodeAnalysis.CodeStyle (32)
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 (3)
89if (value.ConstantValue is { HasValue: true, Value: null }) 119if (value is null || !value.ConstantValue.HasValue) 197case ISingleValueCaseClauseOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } }:
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (1)
127ConstantValue: { HasValue: true, Value: bool constValue }
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
139value.ConstantValue.HasValue &&
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
311if (!initializer.Value.ConstantValue.HasValue)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (2)
192value.ConstantValue.HasValue) 659if (assignmentValue.ConstantValue.HasValue)
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 (3)
90if (invocation.Arguments[0].Value is ILiteralOperation { ConstantValue: { HasValue: true, Value: string value } } literal && 211? alignmentOp is { ConstantValue.HasValue: true } 248=> argument.Value.ConstantValue is { HasValue: true, 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)
265return operation.ConstantValue.HasValue &&
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\Options\EditorConfigValueSerializer.cs (1)
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
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)
307name.HasValue ? name.Value : parameter.Name, 310defaultValue.HasValue 540returnTypeAttributes: 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 (14)
FlowAnalysis\AbstractFlowPass.cs (5)
443this.State = initialState.HasValue ? initialState.Value : TopState(); 1917if (oldTryState.HasValue) 1946if (oldTryState.HasValue) 1991if (oldTryState.HasValue) 2578if (oldState.HasValue)
FlowAnalysis\AbstractFlowPass_LocalFunctions.cs (1)
164if (NonMonotonicState.HasValue)
FlowAnalysis\DefiniteAssignment.cs (1)
1791if (NonMonotonicState.HasValue)
FlowAnalysis\DefiniteAssignment.LocalFunctions.cs (1)
203if (NonMonotonicState.HasValue)
FlowAnalysis\NullableWalker.cs (6)
147Debug.Assert(!StateForLambda.HasValue); 1843if (initialState.HasValue) 2752if (newState != NullableFlowState.NotNull && NonMonotonicState.HasValue) 3611if (shouldMakeNotNullRvalue(node) && _visitResult.NestedVisitResults is null && !_visitResult.StateForLambda.HasValue) 8008Debug.Assert(lambdaState.HasValue); 9938initialState.HasValue ? initialState.Value : State.Clone(),
Microsoft.CodeAnalysis.CSharp.CodeStyle (9)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
625=> semanticModel.GetConstantValue(expression, cancellationToken).HasValue &&
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
335=> operation.ConstantValue.HasValue &&
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\CSharpUsePatternCombinatorsAnalyzer.cs (1)
164: operation.ConstantValue.HasValue;
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (3)
97if (!constantValue.HasValue) 140if (!constantValue.HasValue) 154if (!constantValue.HasValue)
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
269return constantValue.HasValue;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (2)
145return constantValue.HasValue && 976=> operation.ConstantValue.HasValue && operation.ConstantValue.Value is null;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (3)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
706ConstantValue.HasValue: true, 890ConstantValue.HasValue: true,
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
100else if (semanticModel.GetConstantValue(defaultLiteral, cancellationToken) is var constant && constant.HasValue)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
CodeGeneration\SyntaxGeneratorTests.cs (1)
95Assert.True(constantValue.HasValue);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (1)
CodeGen\CodeGenTupleEqualityTests.cs (1)
692Assert.False(model.GetConstantValue(tuple2).HasValue);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\PatternMatchingTests.cs (1)
6577Assert.False(model.GetConstantValue(caseDefault.Pattern).HasValue);
Microsoft.CodeAnalysis.CSharp.Features (14)
CodeRefactorings\UseRecursivePatterns\UseRecursivePatternsCodeRefactoringProvider.cs (2)
373var (left, right) when model.GetConstantValue(left).HasValue => (right, left, Flipped: true), 374var (left, right) when model.GetConstantValue(right).HasValue => (left, right, Flipped: false),
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (1)
121if (checkIdObject.HasValue && checkIdObject.Value is string checkId)
ReverseForStatement\CSharpReverseForStatementCodeRefactoringProvider.cs (1)
109=> valueOpt.HasValue && IsIntegral(valueOpt.Value) && ToUInt64(valueOpt.Value) == value;
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
625=> semanticModel.GetConstantValue(expression, cancellationToken).HasValue &&
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
335=> operation.ConstantValue.HasValue &&
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\CSharpUsePatternCombinatorsAnalyzer.cs (1)
164: operation.ConstantValue.HasValue;
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (3)
97if (!constantValue.HasValue) 140if (!constantValue.HasValue) 154if (!constantValue.HasValue)
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
269return constantValue.HasValue;
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
706ConstantValue.HasValue: true, 890ConstantValue.HasValue: true,
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
100else if (semanticModel.GetConstantValue(defaultLiteral, cancellationToken) is var constant && constant.HasValue)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (37)
Semantics\ConstantTests.cs (1)
2926Assert.True(constantValue.HasValue);
Semantics\ImplicitObjectCreationTests.cs (7)
1872Assert.False(model.GetConstantValue(def).HasValue); 1902Assert.False(model.GetConstantValue(def).HasValue); 1932Assert.False(model.GetConstantValue(def).HasValue); 2043Assert.False(model.GetConstantValue(@new).HasValue); 2078Assert.False(model.GetConstantValue(@new).HasValue); 2224Assert.False(model.GetConstantValue(def).HasValue); 2572Assert.False(model.GetConstantValue(def).HasValue);
Semantics\InterpolationTests.cs (1)
4617Assert.False(semanticInfo.ConstantValue.HasValue);
Semantics\LambdaTests.cs (1)
8062Assert.True(constantValue.HasValue);
Semantics\RawInterpolationTests_Handler.cs (1)
2918Assert.False(semanticInfo.ConstantValue.HasValue);
Semantics\TargetTypedDefaultTests.cs (16)
249Assert.True(model.GetConstantValue(def).HasValue); 286Assert.True(model.GetConstantValue(def).HasValue); 525Assert.False(model.GetConstantValue(def).HasValue); 571Assert.False(model.GetConstantValue(def).HasValue); 614Assert.False(model.GetConstantValue(def).HasValue); 672Assert.False(model.GetConstantValue(def).HasValue); 753Assert.False(model.GetConstantValue(def).HasValue); 841Assert.False(model.GetConstantValue(def).HasValue); 870Assert.False(model.GetConstantValue(def).HasValue); 3059Assert.False(model.GetConstantValue(def).HasValue); 3579Assert.False(model.GetConstantValue(default1).HasValue); 3587Assert.False(model.GetConstantValue(default2).HasValue); 3594Assert.False(model.GetConstantValue(default3).HasValue); 3601Assert.True(model.GetConstantValue(default4).HasValue); 3677Assert.False(model.GetConstantValue(value).HasValue); 3718Assert.False(model.GetConstantValue(defaultValue).HasValue);
Semantics\UnsafeTests.cs (10)
8888Assert.False(summary.ConstantValue.HasValue); 8923Assert.False(summary.ConstantValue.HasValue); 9350Assert.False(summary.ConstantValue.HasValue); 10642Assert.False(typeSummary.ConstantValue.HasValue); 10704Assert.False(typeSummary.ConstantValue.HasValue); 10764Assert.False(typeSummary.ConstantValue.HasValue); 10777Assert.False(sizeOfSummary.ConstantValue.HasValue); 11320Assert.False(stackAllocSummary.ConstantValue.HasValue); 11332Assert.False(typeSummary.ConstantValue.HasValue); 11346Assert.True(countSummary.ConstantValue.HasValue);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (27)
Compilation\GetSemanticInfoTests.cs (3)
2737Assert.False(model.GetConstantValue(expr).HasValue); 2808Assert.False(model.GetConstantValue(expr).HasValue); 4298Assert.False(info.ConstantValue.HasValue);
Compilation\SemanticModelAPITests.cs (18)
1438Assert.True(constantInfo.HasValue, "must be a constant"); 1476Assert.True(constantInfo.HasValue, "must be a constant"); 1524Assert.True(constantInfo.HasValue, "must be a constant"); 1612Assert.True(constantInfo.HasValue, "must be a constant"); 1697Assert.True(constantInfo.HasValue, "must be a constant"); 2786Assert.True(constantVal.HasValue); 3914Assert.True(value0.HasValue); 3924Assert.False(value1.HasValue); 3931Assert.False(value2.HasValue); 4108Assert.True(model.GetConstantValue(actual[0]).HasValue); 4110Assert.False(model.GetConstantValue(actual[1]).HasValue); 4151Assert.False(model.GetConstantValue(actual[2]).HasValue); 4188Assert.True(model.GetConstantValue(actual[0]).HasValue); 4191Assert.False(model.GetConstantValue(actual[1]).HasValue); 4213Assert.True(model.GetConstantValue(actual[0]).HasValue); 4217Assert.True(model.GetConstantValue(actual[1]).HasValue); 4241Assert.True(model.GetConstantValue(actual[0]).HasValue); 4286Assert.False(model.GetConstantValue(actual[2]).HasValue);
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (5)
4276Assert.True(constantInfo.HasValue, "must be constant"); 4291Assert.True(constantInfo.HasValue, "must be constant"); 4337Assert.True(constantInfo.HasValue, "must be constant"); 4360Assert.True(constantInfo.HasValue, "must be constant"); 4382Assert.True(constantInfo.HasValue, "must be constant");
Symbols\EnumTests.cs (1)
355Assert.False(value.HasValue);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
217public bool IsCompileTimeConstant { get { return ConstantValue.HasValue; } }
Microsoft.CodeAnalysis.CSharp.Workspaces (4)
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (2)
266if (!nameofValueOpt.HasValue) 386semanticModel.GetConstantValue(invocationExpr).HasValue &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (2)
145return constantValue.HasValue && 976=> operation.ConstantValue.HasValue && operation.ConstantValue.Value is null;
Microsoft.CodeAnalysis.Features (54)
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;
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (1)
446: operation.ConstantValue.HasValue;
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 (3)
89if (value.ConstantValue is { HasValue: true, Value: null }) 119if (value is null || !value.ConstantValue.HasValue) 197case ISingleValueCaseClauseOperation { Value: IConversionOperation { ConstantValue: { HasValue: true, Value: null } } }:
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (1)
127ConstantValue: { HasValue: true, Value: bool constValue }
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\SuppressMessageAttributeState.cs (1)
139value.ConstantValue.HasValue &&
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
311if (!initializer.Value.ConstantValue.HasValue)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (2)
192value.ConstantValue.HasValue) 659if (assignmentValue.ConstantValue.HasValue)
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 (3)
90if (invocation.Arguments[0].Value is ILiteralOperation { ConstantValue: { HasValue: true, Value: string value } } literal && 211? alignmentOp is { ConstantValue.HasValue: true } 248=> argument.Value.ConstantValue is { HasValue: true, 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)
265return operation.ConstantValue.HasValue &&
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 (26)
Compilation\OperationTreeVerifier.cs (2)
110if (operation.ConstantValue.HasValue) 220if (constant.HasValue)
Compilation\TestOperationVisitor.cs (6)
1362Assert.False(pattern.ConstantValue.HasValue); 1550Assert.False(operation.ConstantValue.HasValue); 1560Assert.False(operation.ConstantValue.HasValue); 1723if (!operation.Value.ConstantValue.HasValue || operation.Value.ConstantValue.Value != null) 1801Assert.False(operation.ConstantValue.HasValue); 1827Assert.False(operation.ConstantValue.HasValue);
Diagnostics\EmptyArrayAnalyzer.cs (1)
79if (arrayLength.HasValue &&
Diagnostics\LocalCouldBeConstAnalyzer.cs (1)
92if (initializer != null && initializer.Value.ConstantValue.HasValue)
Diagnostics\OperationTestAnalyzer.cs (15)
158if (conditionRight.ConstantValue.HasValue && 175setupAssignment.Value.ConstantValue.HasValue && 193if (advanceIncrementOpt.HasValue && advanceOperationCode.HasValue) 249advanceOperation.RightOperand.ConstantValue.HasValue && 264advanceAssignment.Value.ConstantValue.HasValue && 356singleValueExpression.ConstantValue.HasValue && 376rangeMinExpression.ConstantValue.HasValue && 379rangeMaxExpression.ConstantValue.HasValue && 399relationalValueExpression.ConstantValue.HasValue && 587if (argumentValue.HasValue && argument.Type.SpecialType == SpecialType.System_Int32) 632literal.ConstantValue.HasValue && 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)
677If Me._tryState.HasValue Then 1457If oldTryState.HasValue Then 1478If oldTryState.HasValue Then 1512If oldTryState.HasValue Then
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (7)
Compilation\SemanticModelAPITests.vb (7)
623Assert.True(initializerConstantVal.HasValue, "must be a constant") 676Assert.True(constantInfo.HasValue, "must be a constant") 729Assert.True(constantInfo.HasValue, "must be a constant") 1250Assert.True(constantInfo.HasValue, "must be constant") 1267Assert.True(constantInfo.HasValue, "must be constant") 1315Assert.True(constantInfo.HasValue, "must be constant") 1351Assert.True(constantInfo.HasValue, "must be constant")
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
Simplification\Simplifiers\AbstractVisualBasicSimplifier.vb (1)
157If Not nameofValueOpt.HasValue Then
Microsoft.CodeAnalysis.Workspaces (77)
Classification\AbstractClassificationService.cs (2)
97if (classifiedSpans.HasValue) 130if (!cachedSpans.HasValue || cachedSpans.Value == null)
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)
47if (!result.HasValue)
FindSymbols\Declarations\DeclarationFinder_SourceDeclarations.cs (4)
51if (!result.HasValue) 89if (!result.HasValue) 122if (!result.HasValue) 155if (!result.HasValue)
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\Options\EditorConfigValueSerializer.cs (1)
52return optionalBool.HasValue ? new Optional<bool?>(optionalBool.Value) : new Optional<bool?>();
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)
307name.HasValue ? name.Value : parameter.Name, 310defaultValue.HasValue 540returnTypeAttributes: 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 (6)
133return optional.HasValue && checksum == optional.Value; 152Contract.ThrowIfTrue(optional.HasValue && optional.Value == null); 153return optional.HasValue ? optional.Value : null; 188if (optional.HasValue) 192if (optional.HasValue) 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 (1)
src\libraries\System.Runtime.InteropServices\gen\Common\OperationExtensions.cs (1)
47return operation is { ConstantValue: { HasValue: true, Value: null } };
Microsoft.Interop.LibraryImportGenerator (1)
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 (5)
StubEnvironment.cs (5)
26if (_lcidConversionAttrType.HasValue) 40if (_suppressGCTransitionAttrType.HasValue) 54if (_unmanagedCallConvAttrType.HasValue) 68if (_defaultDllImportSearchPathsAttrType.HasValue) 82if (_wasmImportLinkageAttrType.HasValue)
Microsoft.VisualStudio.LanguageServices (2)
Options\VisualStudioSettingsOptionPersister.cs (2)
66if (result.HasValue) 78if (fallbackResult.HasValue)
Microsoft.VisualStudio.LanguageServices.CSharp (2)
CodeModel\MethodXml\MethodXmlBuilder.cs (2)
250if (!constantValue.HasValue) 292if (!constantValue.HasValue)
Microsoft.VisualStudio.LanguageServices.VisualBasic (2)
CodeModel\MethodXML\MethodXmlBuilder.vb (2)
233If Not constantValue.HasValue Then 530If Not constantValue.HasValue Then
Roslyn.VisualStudio.Next.UnitTests (6)
Options\VisualStudioSettingsOptionPersisterTests.cs (6)
187Assert.True(result.HasValue); 228Assert.False(result.HasValue); 251Assert.True(result.HasValue); 258Assert.True(newValue.HasValue); 289Assert.True(result.HasValue); 296Assert.True(newValue.HasValue);
System.Text.RegularExpressions.Generator (3)
UpgradeToGeneratedRegexAnalyzer.cs (2)
183if (!argument.Value.ConstantValue.HasValue) 206if (!argument.Value.ConstantValue.HasValue)
UpgradeToGeneratedRegexCodeFixer.cs (1)
270return optionsArgument is null || !optionsArgument.Value.ConstantValue.HasValue ?