130 implementations of Type
Microsoft.CodeAnalysis (129)
Generated\Operations.Generated.cs (126)
4050public override ITypeSymbol? Type => null; 4105public override ITypeSymbol? Type => null; 4175public override ITypeSymbol? Type => null; 4281public override ITypeSymbol? Type => null; 4373public override ITypeSymbol? Type => null; 4485public override ITypeSymbol? Type => null; 4509public override ITypeSymbol? Type => null; 4562public override ITypeSymbol? Type => null; 4582public override ITypeSymbol? Type => null; 4596public override ITypeSymbol? Type => null; 4648public override ITypeSymbol? Type => null; 4712public override ITypeSymbol? Type => null; 4791public override ITypeSymbol? Type => null; 4859public override ITypeSymbol? Type => null; 4910public override ITypeSymbol? Type => null; 4974public override ITypeSymbol? Type => null; 4988public override ITypeSymbol? Type => null; 5002public override ITypeSymbol? Type => null; 5068public override ITypeSymbol? Type => null; 5086public override ITypeSymbol? Type { get; } 5146public override ITypeSymbol? Type { get; } 5219public override ITypeSymbol? Type { get; } 5286public override ITypeSymbol? Type { get; } 5308public override ITypeSymbol? Type { get; } 5327public override ITypeSymbol? Type { get; } 5392public override ITypeSymbol? Type { get; } 5448public override ITypeSymbol? Type { get; } 5517public override ITypeSymbol? Type { get; } 5571public override ITypeSymbol? Type { get; } 5634public override ITypeSymbol? Type { get; } 5712public override ITypeSymbol? Type { get; } 5789public override ITypeSymbol? Type { get; } 5856public override ITypeSymbol? Type { get; } 5909public override ITypeSymbol? Type => null; 5979public override ITypeSymbol? Type { get; } 6031public override ITypeSymbol? Type { get; } 6098public override ITypeSymbol? Type { get; } 6117public override ITypeSymbol? Type { get; } 6173public override ITypeSymbol? Type { get; } 6225public override ITypeSymbol? Type { get; } 6298public override ITypeSymbol? Type { get; } 6373public override ITypeSymbol? Type { get; } 6426public override ITypeSymbol? Type { get; } 6491public override ITypeSymbol? Type { get; } 6554public override ITypeSymbol? Type { get; } 6571public override ITypeSymbol? Type { get; } 6628public override ITypeSymbol? Type { get; } 6684public override ITypeSymbol? Type { get; } 6740public override ITypeSymbol? Type { get; } 6803public override ITypeSymbol? Type { get; } 6856public override ITypeSymbol? Type { get; } 6914public override ITypeSymbol? Type { get; } 6972public override ITypeSymbol? Type { get; } 7024public override ITypeSymbol? Type { get; } 7076public override ITypeSymbol? Type { get; } 7094public override ITypeSymbol? Type { get; } 7113public override ITypeSymbol? Type { get; } 7133public override ITypeSymbol? Type { get; } 7185public override ITypeSymbol? Type { get; } 7248public override ITypeSymbol? Type { get; } 7311public override ITypeSymbol? Type { get; } 7363public override ITypeSymbol? Type { get; } 7422public override ITypeSymbol? Type { get; } 7474public override ITypeSymbol? Type { get; } 7491public override ITypeSymbol? Type { get; } 7553public override ITypeSymbol? Type => null; 7600public override ITypeSymbol? Type => null; 7651public override ITypeSymbol? Type => null; 7702public override ITypeSymbol? Type => null; 7757public override ITypeSymbol? Type => null; 7825public override ITypeSymbol? Type => null; 7906public override ITypeSymbol? Type => null; 7967public override ITypeSymbol? Type => null; 8044public override ITypeSymbol? Type => null; 8118public override ITypeSymbol? Type => null; 8142public override ITypeSymbol? Type => null; 8205public override ITypeSymbol? Type => null; 8267public override ITypeSymbol? Type => null; 8320public override ITypeSymbol? Type => null; 8371public override ITypeSymbol? Type => null; 8427public override ITypeSymbol? Type => null; 8500public override ITypeSymbol? Type => null; 8562public override ITypeSymbol? Type => null; 8584public override ITypeSymbol? Type => null; 8649public override ITypeSymbol? Type { get; } 8716public override ITypeSymbol? Type => null; 8787public override ITypeSymbol? Type => null; 8806public override ITypeSymbol? Type { get; } 8859public override ITypeSymbol? Type => null; 8881public override ITypeSymbol? Type { get; } 8934public override ITypeSymbol? Type { get; } 8951public override ITypeSymbol? Type { get; } 8970public override ITypeSymbol? Type { get; } 9029public override ITypeSymbol? Type { get; } 9096public override ITypeSymbol? Type { get; } 9153public override ITypeSymbol? Type => null; 9219public override ITypeSymbol? Type => null; 9295public override ITypeSymbol? Type => null; 9309public override ITypeSymbol? Type => null; 9378public override ITypeSymbol? Type { get; } 9453public override ITypeSymbol? Type => null; 9515public override ITypeSymbol? Type => null; 9578public override ITypeSymbol? Type { get; } 9642public override ITypeSymbol? Type => null; 9694public override ITypeSymbol? Type { get; } 9713public override ITypeSymbol? Type { get; } 9775public override ITypeSymbol? Type => null; 9830public override ITypeSymbol? Type => null; 9881public override ITypeSymbol? Type => null; 9945public override ITypeSymbol? Type => null; 9963public override ITypeSymbol? Type => null; 10016public override ITypeSymbol? Type => null; 10081public override ITypeSymbol? Type { get; } 10148public override ITypeSymbol? Type { get; } 10210public override ITypeSymbol? Type => null; 10262public override ITypeSymbol? Type => null; 10282public override ITypeSymbol? Type => null; 10349public override ITypeSymbol? Type { get; } 10410public override ITypeSymbol? Type => null; 10463public override ITypeSymbol? Type => null; 10530public override ITypeSymbol? Type { get; } 10549public override ITypeSymbol? Type { get; } 10600public override ITypeSymbol? Type => null; 10663public override ITypeSymbol? Type { get; } 10721public override ITypeSymbol? Type { get; } 10777public override ITypeSymbol? Type => null;
Operations\Operation.cs (1)
75public abstract ITypeSymbol? Type { get; }
Operations\OperationNodes.cs (2)
135public override ITypeSymbol? Type { get; } 169public override ITypeSymbol? Type => null;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\CollectionExpressionTests.cs (1)
29427ITypeSymbol IOperation.Type => throw null;
937 references to Type
ConfigurationSchemaGenerator (3)
RuntimeSource\Configuration.Binder\Parser\ConfigurationBinder.cs (3)
107IInstanceReferenceOperation i => i.Type, 110IPropertyReferenceOperation o => o.Type, 115IObjectCreationOperation o => o.Type,
ILLink.RoslynAnalyzer (5)
TrimAnalysis\TrimAnalysisVisitor.cs (5)
96if (operation.Type is not null) 197(operation.Type?.TypeKind == TypeKind.Enum || operation.Type?.SpecialType == SpecialType.System_Int32)) 507else if (operation.Type?.TypeKind == TypeKind.Enum && constantValue is int enumConstantValue) 514switch (operation.Type?.SpecialType)
Metrics (11)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Metrics.Legacy (11)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Microsoft.Analyzers.Extra (13)
AsyncCallInsideUsingBlockAnalyzer.cs (1)
130var returnType = operation.Type?.OriginalDefinition;
CallAnalysis\Arrays.cs (1)
103static void HandleConstructor(OperationAnalysisContext context, IObjectCreationOperation op) => HandleSuspectType(context, (INamedTypeSymbol)op.Type!, op.Syntax.GetLocation());
CallAnalysis\Fixers\LegacyLoggingFixer.cs (7)
366var t = invocationOp.Arguments[0].Value.Type!; 386parameters.Add(gen.ParameterDeclaration("exception", gen.TypeExpression(invocationOp.Arguments[details.ExceptionParamIndex].Value.Type!))); 394parameters.Add(gen.ParameterDeclaration(details.MessageArgs[index++], gen.TypeExpression(o.Type!))); 431invocationOp.Arguments[0].Value.Type! 436args.Add(invocationOp.Arguments[details.ExceptionParamIndex].Value.Type!); 443args.Add(a.Type!); 455args.Add(d.Type!);
CoalesceAnalyzer.cs (2)
34var type = op.Target.Type; 61var type = op.Value.Type;
ConditionalAccessAnalyzer.cs (2)
72type = op.Operation.Type; 78type = op.Operation.Type;
Microsoft.Analyzers.Local (5)
CallAnalysis\CallAnalyzer.Handlers.cs (2)
120if (creationOp.Type != null) 122if (_state.ExceptionTypes.TryGetValue(creationOp.Type, out var handlers))
CallAnalysis\Throws.cs (3)
33if (creationOp?.Type != null) 40$"Microsoft.Shared.Diagnostics.Throws.{creationOp.Type.Name}"); 46if (creationOp.Type.Name == "ArgumentNullException")
Microsoft.AspNetCore.App.Analyzers (6)
Http\HeaderDictionaryAddAnalyzer.cs (1)
36&& SymbolEqualityComparer.Default.Equals(wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_IHeaderDictionary), invocation.Instance?.Type))
Http\RequestDelegateReturnTypeAnalyzer.cs (3)
33SymbolEqualityComparer.Default.Equals(parent.Type, wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_RequestDelegate))) 49SymbolEqualityComparer.Default.Equals(parent.Type, wellKnownTypes.Get(WellKnownType.Microsoft_AspNetCore_Http_RequestDelegate))) 59var returnType = resolvedOperation.Type;
Kestrel\ListenOnIPv6AnyAnalyzer.cs (1)
113Instance.Type:
RouteHandlers\DisallowReturningActionResultFromMapMethods.cs (1)
67var type = returnedValue.Type;
Microsoft.AspNetCore.Mvc.Api.Analyzers (4)
ActualApiResponseMetadataFactory.cs (3)
79var statementReturnType = returnedValue.Type; 184typeSymbol = assignmentOperation.Type; 217typeSymbol = operation.Type;
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (1)
97!symbolCache.IActionResult.IsAssignableFrom(returnValue.Type))
Microsoft.CodeAnalysis (199)
Generated\Operations.Generated.cs (1)
1835/// Natural type can be different from <see cref="IOperation.Type" /> depending on the
Operations\ControlFlowGraphBuilder.cs (192)
1412return result ?? MakeInvalidOperation(originalOperation.Syntax, originalOperation.Type, ImmutableArray<IOperation>.Empty); 2104return PopStackFrame(frame, new SimpleAssignmentOperation(operation.IsRef, PopOperand(), value, null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 2116syntax: operation.Syntax, type: operation.Type, isImplicit: IsImplicit(operation))); 2127operation.Syntax, operation.Type, IsImplicit(operation)); 2138operation.Syntax, operation.Type, IsImplicit(operation)); 2149operation.Syntax, operation.Type, IsImplicit(operation)); 2170if (ITypeSymbolHelpers.IsBooleanType(operation.Type) && 2171ITypeSymbolHelpers.IsBooleanType(operation.LeftOperand.Type) && 2172ITypeSymbolHelpers.IsBooleanType(operation.RightOperand.Type)) 2178ITypeSymbolHelpers.IsNullableOfBoolean(operation.Type) && 2179ITypeSymbolHelpers.IsNullableOfBoolean(operation.LeftOperand.Type) && 2180ITypeSymbolHelpers.IsNullableOfBoolean(operation.RightOperand.Type)) 2185else if (ITypeSymbolHelpers.IsObjectType(operation.Type) && 2186ITypeSymbolHelpers.IsObjectType(operation.LeftOperand.Type) && 2187ITypeSymbolHelpers.IsObjectType(operation.RightOperand.Type)) 2191else if (ITypeSymbolHelpers.IsDynamicType(operation.Type) && 2192(ITypeSymbolHelpers.IsDynamicType(operation.LeftOperand.Type) || 2193ITypeSymbolHelpers.IsDynamicType(operation.RightOperand.Type))) 2232semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 2246semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 2258semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 2265ITypeSymbolHelpers.IsBooleanType(operation.Type) && 2266ITypeSymbolHelpers.IsBooleanType(operation.Operand.Type); 2402semanticModel: null, operand.Syntax, operand.Type, constantValue: null, isImplicit: true); 2451Debug.Assert(binOp.Type is not null); 2452return new ConversionOperation(condition, _compilation.ClassifyConvertibleConversion(condition, binOp.Type, out _), isTryCast: false, isChecked: false, 2453semanticModel: null, binOp.Syntax, binOp.Type, binOp.GetConstantValue(), isImplicit: true); 2465Debug.Assert(binOp.Type is not null); 2488if (ITypeSymbolHelpers.IsBooleanType(left.Type)) 2493else if (ITypeSymbolHelpers.IsDynamicType(left.Type) || unaryOperatorMethod != null) 2499(ITypeSymbolHelpers.IsNullableType(left.Type) || !ITypeSymbolHelpers.IsNullableType(unaryOperatorMethod.Parameters[0].Type)))) 2525if (!ITypeSymbolHelpers.IsDynamicType(left.Type)) 2527resultFromLeft = CreateConversion(resultFromLeft, binOp.Type); 2550binOp.Type, 2585if (ITypeSymbolHelpers.IsNullableType(left.Type)) 2640binOp.Type, 2694AddStatement(new FlowCaptureOperation(captureId, leftSyntax, new LiteralOperation(semanticModel: null, leftSyntax, condition.Type, constantValue, isImplicit: true))); 2704Debug.Assert(ITypeSymbolHelpers.IsBooleanType(condition.Type)); 2740lastUnary.Type, lastUnary.GetConstantValue(), IsImplicit(lastUnary)) 2743condition.Type, constantValue: null, isImplicit: true); 2753ITypeSymbolHelpers.IsBooleanType(binOp.Type) && 2754ITypeSymbolHelpers.IsBooleanType(binOp.LeftOperand.Type) && 2755ITypeSymbolHelpers.IsBooleanType(binOp.RightOperand.Type); 2866if (ITypeSymbolHelpers.IsBooleanType(condition.Type)) 2871if (ITypeSymbolHelpers.IsBooleanType(conditional.WhenTrue.Type) && 2872ITypeSymbolHelpers.IsBooleanType(conditional.WhenFalse.Type)) 2891if (ITypeSymbolHelpers.IsBooleanType(condition.Type)) 2895if (ITypeSymbolHelpers.IsBooleanType(coalesce.WhenNull.Type)) 2988ITypeSymbol? valueTypeOpt = operationValue.Type; 3008(!testConversion.IsIdentity || !ITypeSymbolHelpers.IsNullableType(operation.Type))) 3026isTryCast: false, isChecked: false, semanticModel: null, valueSyntax, operation.Type, 3034convertedTestExpression = MakeInvalidOperation(operation.Type, capturedValue); 3129if (operation.Target?.Type?.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T && 3130((INamedTypeSymbol)operation.Target.Type!).TypeArguments[0].Equals(operation.Type)) 3232value: CreateConversion(whenNullValue, operation.Target.Type), 3235type: operation.Target.Type, 3268operation.Syntax, operation.Type, constantValue: operation.GetConstantValue(), isImplicit: true); 3330ITypeSymbol? valueType = value.Type; 3355Debug.Assert(ITypeSymbolHelpers.IsNullableType(value.Type)); 3357MakeInvalidOperation(ITypeSymbolHelpers.GetNullableUnderlyingType(value.Type), value); 3430if (ITypeSymbolHelpers.IsNullableType(operation.Type) && !ITypeSymbolHelpers.IsNullableType(currentConditionalAccess.WhenNotNull.Type)) 3434MakeNullable(access, operation.Type))); 3454Debug.Assert(operation.Type is not null); 3457new DefaultValueOperation(semanticModel: null, defaultValueSyntax, operation.Type, 3458(operation.Type.IsReferenceType && !ITypeSymbolHelpers.IsNullableType(operation.Type)) 3531ITypeSymbol? testExpressionType = testExpression.Type; 4027return resource.Type == null || resource.Type.Kind == SymbolKind.DynamicType; 4115Debug.Assert(resource.Type is not null); 4126Debug.Assert(!isNotNullableValueType(resource.Type)); 4131Debug.Assert(resource.Type is not null); 4134if (requiresRuntimeConversion || !isNotNullableValueType(resource.Type)) 4141if (!iDisposable.Equals(resource.Type) && disposeMethod is null) 4143if (resource.Type.IsReferenceType) 4147else if (ITypeSymbolHelpers.IsNullableType(resource.Type)) 4169((value.Type!.Equals(iDisposable) || (!value.Type.IsReferenceType && !ITypeSymbolHelpers.IsNullableType(value.Type))) && disposeArguments.IsDefaultOrEmpty)); 4223if (operation.LockedValue.Type?.IsWellKnownTypeLock() == true) 4225if (operation.LockedValue.Type.TryFindLockTypeInfo() is { } lockTypeInfo) 4317if (!objectType.Equals(lockedValue.Type)) 4587collection = new FlowCaptureReferenceOperation(localCopyCaptureId, operation.Collection.Syntax, collection.Type, constantValue: null); 4684operation.LoopControlVariable.Syntax, operation.LoopControlVariable.Type, 4690operation.LoopControlVariable.Type, 4755ITypeSymbol? stepEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(operation.StepValue.Type); 4920if (ITypeSymbolHelpers.IsNullableType(stepValue.Type)) 4926ITypeSymbol? stepValueEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(stepValue.Type); 4956IOperation literal = new LiteralOperation(semanticModel: null, stepValue.Syntax, stepValue.Type, 5149if (ITypeSymbolHelpers.IsNullableType(operation.LimitValue.Type)) 5257operation.StepValue.Type, 5272operand.Type, 5320bool isNullable = ITypeSymbolHelpers.IsNullableType(operation.StepValue.Type); 5361controlVariableReferenceForAssignment.Type, 5380Debug.Assert(ITypeSymbolHelpers.IsNullableType(controlVariableReferenceForIncrement.Type)); 5396controlVariableReferenceForIncrement.Type, 5404Debug.Assert(controlVariableReferenceForAssignment.Type != null); 5405increment = MakeNullable(increment, controlVariableReferenceForAssignment.Type); 5446return new FlowCaptureReferenceOperation(id, underlying.Syntax, underlying.Type, underlying.GetConstantValue()); 5553bool leftIsNullable = ITypeSymbolHelpers.IsNullableType(operation.Value.Type); 5554bool rightIsNullable = ITypeSymbolHelpers.IsNullableType(compareWith.Type); 5566if (leftOperand.Type != null) 5568Debug.Assert(compareWith.Type != null); 5569leftOperand = MakeNullable(leftOperand, compareWith.Type); 5572else if (!rightIsNullable && rightOperand.Type != null) 5574Debug.Assert(operation.Value.Type != null); 5575rightOperand = MakeNullable(rightOperand, operation.Value.Type); 5665Debug.Assert(ITypeSymbolHelpers.GetNullableUnderlyingType(type).Equals(operand.Type)); 5934operation.Type, IsImplicit(operation)); 5944operation.Type, IsImplicit(operation)); 5976IOperation initializedInstance = new NoPiaObjectCreationOperation(initializer: null, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 5988operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 5996var initializedInstance = new TypeParameterObjectCreationOperation(initializer: null, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6010operation.Type, IsImplicit(operation)); 6097assignmentOperation.Type, assignmentOperation.GetConstantValue(), IsImplicit(assignmentOperation)); 6234fieldReference.Syntax, fieldReference.Type, fieldReference.GetConstantValue(), IsImplicit(fieldReference)); 6239eventReference.Type, IsImplicit(eventReference)); 6245propertyReference.Type, IsImplicit(propertyReference)); 6250return new ArrayElementReferenceOperation(instance, indices, semanticModel: null, originalTarget.Syntax, originalTarget.Type, IsImplicit(originalTarget)); 6257semanticModel: null, originalTarget.Syntax, originalTarget.Type, IsImplicit(originalTarget)); 6270dynamicReference.Type, IsImplicit(dynamicReference)); 6360return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6366return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6374operation.Syntax, operation.Type, IsImplicit(operation)); 6378Debug.Assert(operation.Type is not null); 6379_currentImplicitInstance = new ImplicitInstanceInfo((INamedTypeSymbol)operation.Type); 6399propertyReference.Instance.Syntax, propertyReference.Instance.Type, IsImplicit(propertyReference.Instance)); 6401semanticModel: null, propertyReference.Syntax, propertyReference.Type, IsImplicit(propertyReference)); 6404semanticModel: null, simpleAssignment.Syntax, simpleAssignment.Type, simpleAssignment.GetConstantValue(), IsImplicit(simpleAssignment)); 6418operation.Syntax, operation.Type, IsImplicit(operation)); 6492operation.Syntax, operation.Type, IsImplicit(operation)); 6571operation.Type, 6596return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 6601return new FlowCaptureReferenceOperation(_currentInterpolatedStringHandlerCreationContext.HandlerPlaceholder, operation.Syntax, operation.Type, operation.GetConstantValue()); 6604return new InstanceReferenceOperation(operation.ReferenceKind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6633dynamicMemberReference.ContainingType, semanticModel: null, dynamicMemberReference.Syntax, dynamicMemberReference.Type, IsImplicit(dynamicMemberReference)); 6642((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6653((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6659operation.ContainingType, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6665return new DeconstructionAssignmentOperation(visitedTarget, visitedValue, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6703return new TupleOperation(elementBuilder.ToImmutableAndFree(), tuple.NaturalType, semanticModel: null, tuple.Syntax, tuple.Type, IsImplicit(tuple)); 6713return new DeclarationExpressionOperation(VisitPreservingTupleOperations(operation.Expression), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 6761return new NoneOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 6767new NoneOperation(VisitArray(((Operation)operation).ChildOperations.ToImmutableArray()), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation))); 6843ConditionalBranch(new FlowCaptureReferenceOperation(outParameterFlowCapture, outParameterPlaceholder.Syntax, outParameterPlaceholder.Type, constantValue: null), jumpIfTrue: false, resultBlock); 6890return new FlowCaptureReferenceOperation(handlerCaptureId, operation.Syntax, operation.Type, operation.GetConstantValue()); 6971return new FlowCaptureReferenceOperation(_currentInterpolatedStringHandlerCreationContext.OutPlaceholder, operation.Syntax, operation.Type, operation.GetConstantValue(), isInitialization: true); 6983return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), isImplicit: true); 6996return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), isImplicit: true); 7083return new InterpolatedStringOperation(partsBuilder.ToImmutableAndFree(), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7099return new LiteralOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7104return new LiteralOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7109return new Utf8StringOperation(operation.Value, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7115operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7121operation.Type, IsImplicit(operation)); 7128operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7135operation.Syntax, operation.Type, IsImplicit(operation)); 7155return MakeInvalidOperation(operation.Syntax, operation.Type, ImmutableArray<IOperation>.Empty); 7164operation.Syntax, operation.Type, IsImplicit(operation)); 7171operation.Syntax, operation.Type, IsImplicit(operation)); 7176return new TypeOfOperation(operation.TypeOperand, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7181return new ParenthesizedOperation(VisitRequired(operation.Operand), semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7186return new AwaitOperation(VisitRequired(operation.Operation), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7191return new SizeOfOperation(operation.TypeOperand, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7201return new IsTypeOperation(VisitRequired(operation.ValueOperand), operation.TypeOperand, operation.IsNegated, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7280initializer.Syntax, rewrittenTarget.Type, constantValue: null, isImplicit: true); 7308semanticModel: null, operation.EventReference.Syntax, operation.EventReference.Type, IsImplicit(operation.EventReference)); 7321operation.Syntax, operation.Type, IsImplicit(operation)); 7354semanticModel: null, operation.EventReference.Syntax, operation.EventReference.Type, IsImplicit(operation.EventReference)); 7363return new AddressOfOperation(VisitRequired(operation.Reference), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7370operation.Kind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7375return new DiscardOperation(operation.DiscardSymbol, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7385return new OmittedArgumentOperation(semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7419return new PlaceholderOperation(operation.PlaceholderKind, semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7424return new ConversionOperation(VisitRequired(operation.Operand), ((ConversionOperation)operation).ConversionConvertible, operation.IsTryCast, operation.IsChecked, semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7429return new DefaultValueOperation(semanticModel: null, operation.Syntax, operation.Type, operation.GetConstantValue(), IsImplicit(operation)); 7440operation.Syntax, operation.Type, IsImplicit(operation)); 7472IOperation initializedInstance = new InvalidOperation(children.ToImmutableAndFree(), semanticModel: null, operation.Syntax, operation.Type, 7496return new InvalidOperation(ImmutableArray<IOperation>.Empty, semanticModel: null, invalidOperation.Syntax, invalidOperation.Type, invalidOperation.GetConstantValue(), IsImplicit(invalidOperation)); 7503invalidOperation.Syntax, invalidOperation.Type, invalidOperation.GetConstantValue(), IsImplicit(operation))); 7545return new TranslatedQueryOperation(VisitRequired(operation.Operation), semanticModel: null, operation.Syntax, operation.Type, IsImplicit(operation)); 7696operation.Syntax, operation.Type, IsImplicit(operation)); 7714return new RangeOperation(visitedLeftOperand, visitedRightOperand, operation.IsLifted, operation.Method, semanticModel: null, operation.Syntax, operation.Type, isImplicit: IsImplicit(operation)); 7917if (operation.Type!.IsAnonymousType) 7926if (operation.Type.IsValueType) 7933? MakeInvalidOperation(visitedInstance.Type, visitedInstance) 7936semanticModel: null, operation.Syntax, operation.Type, isImplicit: true); 8013operation.Operand.Type, constantValue: operation.Operand.GetConstantValue()); 8034operation.Operand.Type, constantValue: operation.Operand.GetConstantValue()); 8044operation.Operand.Type, constantValue: operation.Operand.GetConstantValue());
Operations\OperationCloner.cs (5)
21return new NoneOperation(VisitArray(((Operation)operation).ChildOperations.ToImmutableArray()), ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.GetConstantValue(), operation.IsImplicit); 32return new DynamicObjectCreationOperation(Visit(operation.Initializer), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 37return new DynamicInvocationOperation(Visit(operation.Operation), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 42return new DynamicIndexerAccessOperation(Visit(operation.Operation), VisitArray(operation.Arguments), ((HasDynamicArgumentsExpression)operation).ArgumentNames, ((HasDynamicArgumentsExpression)operation).ArgumentRefKinds, ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.IsImplicit); 47return new InvalidOperation(VisitArray(((InvalidOperation)operation).Children), ((Operation)operation).OwningSemanticModel, operation.Syntax, operation.Type, operation.GetConstantValue(), operation.IsImplicit);
Operations\OperationExtensions.cs (1)
22return ((IFunctionPointerTypeSymbol)functionPointer.Target.Type!).Signature;
Microsoft.CodeAnalysis.Analyzers (31)
MetaAnalyzers\CompareSymbolsCorrectlyAnalyzer.cs (7)
264if (objectCreation.Type is INamedTypeSymbol createdType && 276if (operation?.Type is object && IsSymbolType(operation.Type.OriginalDefinition, symbolType)) 296if (operation.Type is object && 297operation.Type.TypeKind == TypeKind.Class && 298operation.Type.SpecialType != SpecialType.System_Object) 323return conversion.Type?.SpecialType == SpecialType.System_Object;
MetaAnalyzers\DiagnosticAnalyzerAPIUsageAnalyzer.cs (1)
232AddUsedNamedTypeCore(operation.Type, builder, ref hasAccessToTypeFromWorkspaceAssemblies);
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer.cs (2)
1206argument.Value.Type != null && 1207argument.Value.Type.SpecialType == SpecialType.System_String &&
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer_IdRangeAndCategoryValidation.cs (2)
154if (argument.Value.Type != null && 155argument.Value.Type.SpecialType == SpecialType.System_String &&
MetaAnalyzers\Fixers\CompareSymbolsCorrectlyFix.cs (2)
95IObjectCreationOperation objectCreation when objectCreation.Type != null => 98(generator, args) => generator.ObjectCreationExpression(objectCreation.Type, args), iEqualityComparer, cancellationToken)
MetaAnalyzers\PreferIsKindAnalyzer.cs (1)
82if (conditionalAccess.Operation.Type!.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T)
src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\Core\SymbolIsBannedAnalyzerBase.cs (3)
79VerifyType(context.ReportDiagnostic, objectCreation.Type, context.Operation.Syntax); 93VerifyType(context.ReportDiagnostic, arrayCreation.Type, context.Operation.Syntax); 97VerifyType(context.ReportDiagnostic, addressOf.Type, context.Operation.Syntax);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
Microsoft.CodeAnalysis.AnalyzerUtilities (98)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\CopyAnalysis\CopyAnalysis.CopyDataFlowOperationVisitor.cs (1)
605FlowConversionOperandValue(conversionInference, operation.Type))
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\DisposeAnalysis\DisposeAnalysis.DisposeDataFlowOperationVisitor.cs (2)
89var instanceType = creation.Type; 110if (disposedInstance == null || !IsDisposable(disposedInstance.Type))
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\DisposeAnalysis\DisposeAnalysisHelper.cs (1)
161IsDisposable(operation.Type);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysis.PointsToDataFlowOperationVisitor.cs (20)
275if (PointsToAnalysis.ShouldBeTracked(operation.Type, IsDisposable) && 282Debug.Assert(operation.Type == null || !operation.Type.IsNonNullableValueType() || defaultValue == PointsToAbstractValue.NoLocation); 760if (operation.Type == null || 770else if (operation.Type.IsNonNullableValueType()) 801AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type!, DataFlowAnalysisContext); 827if (operation.Operand.Type == null) 832AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Operand.Type, DataFlowAnalysisContext); 844if (operation.Type.GetUnderlyingValueTupleTypeOrThis() is { } type) 862if (operation.Type is null) 865AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type, DataFlowAnalysisContext); 886var pointsToAbstractValue = operation.Type != null 887? PointsToAbstractValue.Create(AbstractLocation.CreateAllocationLocation(operation, operation.Type, DataFlowAnalysisContext), mayBeNull: false) 923if (PointsToAnalysis.ShouldBeTracked(operation.Type, IsDisposable)) 930AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type, DataFlowAnalysisContext); 1070NullAbstractValue nullState = GetNullStateBasedOnInstanceOrReferenceValue(referenceOrInstance, operation.Type, defaultValue.NullState); 1175PointsToAnalysis.ShouldBeTracked(operation.Value.Type, IsDisposable)) 1212if (inference.IsBoxing && operation.Type != null) 1215var location = AbstractLocation.CreateAllocationLocation(operation, operation.Type, DataFlowAnalysisContext); 1218else if (inference.IsUnboxing && operation.Type.IsNonNullableValueType())
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PropertySetAnalysis\PropertySetAnalysis.PropertySetDataFlowOperationVisitor.cs (14)
150if (operation.Type == null || operation.Constructor == null) 153if (this.TrackedTypeSymbols.Any(s => operation.Type.GetBaseTypesAndThis().Contains(s))) 218if (operation.Target.Type == null) 224&& this.TrackedTypeSymbols.Any(s => operation.Target.Type.GetBaseTypesAndThis().Contains(s)) 284&& propertyReferenceOperation.Instance?.Type != null 285&& this.TrackedTypeSymbols.Any(s => propertyReferenceOperation.Instance.Type.GetBaseTypesAndThis().Contains(s)) 465if (visitedArgument.Value?.Type != null && this.TrackedTypeSymbols.Any(s => visitedArgument.Value.Type.GetBaseTypesAndThis().Contains(s))) 479if ((visitedInstance?.Type != null 480&& this.TrackedTypeSymbols.Any(s => visitedInstance.Type.GetBaseTypesAndThis().Contains(s)) 533ITypeSymbol? argumentTypeSymbol = value is IConversionOperation conversionOperation ? conversionOperation.Operand.Type : value.Type; 655if (returnValue?.Type != null 656&& this.TrackedTypeSymbols.Any(s => returnValue.Type.GetBaseTypesAndThis().Contains(s))
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (1)
505if (arrayCreationOperation?.Type is IArrayTypeSymbol arrayTypeSymbol
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataSymbolMapExtensions.cs (1)
213if (propertyReferenceOperation.Instance?.Type is not INamedTypeSymbol namedType)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAnalysis.ValueContentDataFlowOperationVisitor.cs (12)
187if (operation.Type == null) 194if (ValueContentAbstractValue.IsSupportedType(operation.Type, out var valueTypeSymbol)) 215operation.Type is INamedTypeSymbol namedType && 228return leftValue.MergeBinaryOperation(rightValue, operation.OperatorKind, operation.LeftOperand.Type, operation.RightOperand.Type, operation.Type); 238return targetValue.MergeBinaryOperation(assignedValue, operation.OperatorKind, targetType, assignedValueType, operation.Type); 246return targetValue.MergeBinaryOperation(incrementValue, operationKind, operation.Target.Type, incrementValueType, operation.Type); 294mergedValue = mergedValue.MergeBinaryOperation(newValue, BinaryOperatorKind.Add, leftType: operation.Type, rightType: operation.Type, resultType: operation.Type);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AbstractLocationDataFlowOperationVisitor.cs (1)
71if (operation.Value.Type != null)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntity.cs (1)
77captureId: null, location: location, type: instanceReferenceOperation.Type!, parent: null, entityForInstanceLocation: null, isThisOrMeInstance: false)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntityFactory.cs (7)
136ITypeSymbol? type = operation.Type; 203analysisEntity = GetOrCreateForFlowCapture(flowCapture.Id, flowCapture.Value.Type, flowCapture, isLvalueFlowCapture); 232analysisEntity = GetOrCreateForFlowCapture(flowCaptureReference.Id, flowCaptureReference.Type, flowCaptureReference, flowCaptureReference.IsLValueFlowCaptureReference()); 333if (tupleOperation.Type?.IsTupleType != true || 339var tupleType = (INamedTypeSymbol)tupleOperation.Type; 457if (instance?.Type != null) 459if (instance.Type.IsValueType)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\ConversionInference.cs (3)
19targetType: operation.Type, 20sourceType: operation.Operand.Type, 26sourceType: operation.Value.Type,
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (23)
727var thrownExceptionType = branch.BranchValue?.Type ?? CurrentBasicBlock.GetEnclosingRegionExceptionType(); 747if (branch.BranchValue.Type?.SpecialType == SpecialType.System_Boolean && 840!SymbolEqualityComparer.Default.Equals(method.ReturnType, returnValueOperation.Type)) 1237return TryInferConversion(operation.Operand, operation.Type, operation.IsTryCast, operation, out inference); 1253inference = ConversionInference.Create(targetType, sourceOperand.Type, isTryCast); 1697if (invocation.Type?.SpecialType != SpecialType.System_Boolean) 1856var leftType = operation.LeftOperand.Type; 1858var rightType = operation.RightOperand.Type; 1861operation.Type?.SpecialType == SpecialType.System_Boolean && 2027Debug.Assert(operation.Type!.HasValueCopySemantics()); 2046Debug.Assert(!operation.Type!.HasValueCopySemantics()); 2063if (operation == null || operation.Type == null || !HasPointsToAnalysisResult || !PessimisticAnalysis) 2068if (operation.Type.HasValueCopySemantics()) 2838var value = ComputeValueForCompoundAssignment(operation, targetValue, assignedValue, operation.Target.Type, operation.Value.Type); 2901var elementType = ((IArrayTypeSymbol)arrayCreation.Type!).ElementType; 3056return GetAbstractDefaultValue(operation.Type); 3113operation.Value.Type != null && 3114!operation.Value.Type.HasValueCopySemantics()) 3231operation.Type?.SpecialType == SpecialType.System_Boolean && 3702return GetAbstractDefaultValue(operation.Type); 3751if (operation.Type != null) 3753MergeAnalysisDataFromUnhandledThrowOperations(operation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Microsoft.CodeAnalysis.BannedApiAnalyzers (16)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
SymbolIsBannedAnalyzerBase.cs (3)
79VerifyType(context.ReportDiagnostic, objectCreation.Type, context.Operation.Syntax); 93VerifyType(context.ReportDiagnostic, arrayCreation.Type, context.Operation.Syntax); 97VerifyType(context.ReportDiagnostic, addressOf.Type, context.Operation.Syntax);
Microsoft.CodeAnalysis.CodeStyle (28)
src\Analyzers\Core\Analyzers\Helpers\HashCodeAnalyzer\HashCodeAnalyzer.OperationDeconstructor.cs (1)
123Equals(_method.ContainingType.BaseType, instanceReference.Type))
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
248return operation is { Type.IsValueType: true, Parent: IPropertyReferenceOperation }
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
58var type = value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchExpressionDiagnosticAnalyzer.cs (1)
26=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
26=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchExpressionHelpers.cs (2)
19var switchExpressionType = switchExpression?.Type; 108var type = operation.Value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (2)
58var switchExpressionType = switchExpression?.Type; 185var type = operation.Value.Type;
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
85var leftType = leftOperand.Type; 86var rightType = rightOperand.Type;
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (6)
175if (value.Type == null || 176value.Type.IsErrorType() || 177value.Type.SpecialType == SpecialType.System_Void) 183if (value.Type.TypeKind == TypeKind.Dynamic) 311if (!operation.Type.IsDelegateType()) 341if (assignmentOperation.Target.Type.IsDelegateType() &&
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationDiagnosticAnalyzer.cs (1)
64if (interpolation.Parent is IInterpolatedStringOperation { Parent: IConversionOperation { Type: { } convertedType } conversion } &&
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (3)
138if (instance.Type is { IsRefLikeType: false } || IsRefLikeTypeAllowed(instance.Type)) 145instance.Type.Implements(systemIFormattable))
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (3)
72!AreEqualOrHaveImplicitConversion(trueAssignment.Type, falseAssignment.Type, trueAssignment.SemanticModel!.Compilation)) 91if (nullCheckedExpression is { Type.IsValueType: true })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Microsoft.CodeAnalysis.CodeStyle.Fixes (9)
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchExpressionCodeFixProvider.cs (1)
38=> switchExpression.Value.Type ?? throw ExceptionUtilities.Unreachable();
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchStatementCodeFixProvider.cs (1)
60=> switchOperation.Value.Type ?? throw ExceptionUtilities.Unreachable();
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (5)
184conversion.Type != null && 185conversion.Type.TypeKind != TypeKind.Error) 189if (conversion.Operand.Type == null || conversion.Operand.Type.TypeKind != TypeKind.Error) 191return (TExpressionSyntax)generator.CastExpression(conversion.Type, sourceSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
Microsoft.CodeAnalysis.CSharp (2)
Compilation\CSharpCompilation.cs (1)
2422ITypeSymbol? sourceType = source.Type;
Operations\CSharpOperationFactory_Methods.cs (1)
465ITypeSymbol? assignmentType = target.Type;
Microsoft.CodeAnalysis.CSharp.Analyzers (1)
MetaAnalyzers\CSharpSemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzer.cs (1)
83var syntaxNodeDerivingType = invocation.Arguments.GetArgumentForParameterAtIndex(1).Value.WalkDownConversion().Type;
Microsoft.CodeAnalysis.CSharp.CodeStyle (35)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (4)
256return instance is { Type.TypeKind: TypeKind.Struct } || 257instance is { Type: ITypeParameterSymbol { HasReferenceTypeConstraint: false } }; 333if (operation.Type.IsSpan()) 365if (conversion.IsInlineArray && conversionOperation.Type.IsSpan())
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
138if (operation?.Parent is IAssignmentOperation { Type.TypeKind: TypeKind.Dynamic })
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (2)
105if (isTypeOperation.ValueOperand.Type is not null && 106isTypeOperation.ValueOperand.Type.InheritsFromOrEquals(isTypeOperation.TypeOperand))
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\AnalyzedPattern.cs (2)
139({ IsImplicit: true }, { IsImplicit: true }) when !Equals(leftTarget.Type, rightTarget.Type) => null,
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
246=> value.UnwrapImplicitConversion() is IObjectCreationOperation { Type.SpecialType: SpecialType.System_Object };
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
77if (arrayCreationOperation.Type is not IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Byte })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (23)
97while (current is IConversionOperation { Type.SpecialType: SpecialType.System_Delegate or SpecialType.System_MulticastDelegate }) 100if (current is IConversionOperation { Type.SpecialType: SpecialType.System_Object }) 107if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 236conversionOperation.Type.RemoveNullableIfPresent() is var type1 && 237conversionOperation.Operand.Type.RemoveNullableIfPresent() is var type2 && 253if (originalDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 270if (rewrittenDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 274if (!Equals(originalDelegateCreationOperation.Type, rewrittenDelegateCreationOperation.Type)) 410var isAcceptableSpanConversion = originalConversionOperation.Type.IsSpan() && originalParentConversionOperation.Type.IsReadOnlySpan(); 553if (castNode.IsParentKind(SyntaxKind.Interpolation) && originalConversionOperation.Type?.SpecialType is SpecialType.System_Object) 791if (!IsSignedIntegralOrIntPtrType(originalConversionOperation.Type) || 792!IsSignedIntegralOrIntPtrType(originalConversionOperation.Operand.Type)) 818var originalConvertedType = originalConversionOperation.Type; 819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type; 962if (castType.Equals(rewrittenOperation.Type, SymbolEqualityComparer.IncludeNullability)) 967castType.Equals(conditionalParentConversion.Type, SymbolEqualityComparer.IncludeNullability)) 1009if (!rewrittenConditionalConvertedType.Equals(conversionOperation.Type)) 1023if (conversionOperation.Type.IsSpanOrReadOnlySpan() && 1051if (binaryOperation.LeftOperand.Type?.SpecialType == SpecialType.System_Object && 1058else if (binaryOperation.RightOperand.Type?.SpecialType == SpecialType.System_Object && 1081if (conversionOperation.Operand.Type is not INamedTypeSymbol original)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
226if (argumentOp is not { Value.Type: { } valueType, Parameter.Type: { } parameterType })
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (2)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
613IInstanceReferenceOperation thisReference => thisReference.Type,
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
65conversion.Type is INamedTypeSymbol { IsGenericType: true } namedType &&
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\OutVarTests.cs (1)
1083Assert.Equal(expectedType, model.GetOperation(decl)?.Type);
Microsoft.CodeAnalysis.CSharp.Features (13)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (4)
256return instance is { Type.TypeKind: TypeKind.Struct } || 257instance is { Type: ITypeParameterSymbol { HasReferenceTypeConstraint: false } }; 333if (operation.Type.IsSpan()) 365if (conversion.IsInlineArray && conversionOperation.Type.IsSpan())
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
138if (operation?.Parent is IAssignmentOperation { Type.TypeKind: TypeKind.Dynamic })
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (2)
105if (isTypeOperation.ValueOperand.Type is not null && 106isTypeOperation.ValueOperand.Type.InheritsFromOrEquals(isTypeOperation.TypeOperand))
src\Analyzers\CSharp\Analyzers\UsePatternCombinators\AnalyzedPattern.cs (2)
139({ IsImplicit: true }, { IsImplicit: true }) when !Equals(leftTarget.Type, rightTarget.Type) => null,
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
246=> value.UnwrapImplicitConversion() is IObjectCreationOperation { Type.SpecialType: SpecialType.System_Object };
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
77if (arrayCreationOperation.Type is not IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Byte })
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
613IInstanceReferenceOperation thisReference => thisReference.Type,
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
65conversion.Type is INamedTypeSymbol { IsGenericType: true } namedType &&
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (4)
IOperation\IOperationTests_IConversionExpression.cs (4)
183Assert.Null(initializerOperation.Type); 5294Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, iopTree.Value.Type.NullableAnnotation); 5386Assert.Equal(conversion.Type, typeInfo.ConvertedType); 5387Assert.Equal(ConversionChildSelector(conversion).Type, typeInfo.Type);
Microsoft.CodeAnalysis.CSharp.NetAnalyzers (6)
Microsoft.NetCore.Analyzers\InteropServices\CSharpDisableRuntimeMarshalling.Fixer.cs (2)
109if (operation.TargetMethod.Name == "StructureToPtr" && operation.Arguments[0].Value.Type!.IsUnmanagedType) 114(ExpressionSyntax)editor.Generator.CastExpression(editor.SemanticModel.Compilation.CreatePointerTypeSymbol(operation.Arguments[0].Value.Type!),
Microsoft.NetCore.Analyzers\Performance\CSharpUseSearchValues.Fixer.cs (2)
86if (operation.Type is IArrayTypeSymbol arrayType) 90else if (operation.Type is INamedTypeSymbol namedType)
Microsoft.NetCore.Analyzers\Runtime\CSharpUseSpanBasedStringConcat.cs (1)
21operation.Type?.SpecialType == SpecialType.System_String;
Microsoft.NetCore.Analyzers\Usage\CSharpPreferGenericOverloads.Fixer.cs (1)
53if (typeInfo.ConvertedType.IsAssignableTo(conversionOperation.Type, invocationContext.SemanticModel.Compilation))
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (175)
Semantics\DelegateTypeTests.cs (1)
14829Assert.Equal("System.Func<System.Int32, System.String>", value.Type.ToTestDisplayString());
Semantics\DynamicTests.cs (166)
5092AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5216AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5339AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5582AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5626AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5803AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5934AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5979AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6137AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6260AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6380AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6488AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6530Assert.Equal(typeInfo.Type, propertyRef.Type); 6577Assert.Equal(typeInfo.Type, propertyRef.Type); 6621Assert.Equal(typeInfo.Type, propertyRef.Type); 6666Assert.Equal(typeInfo.Type, propertyRef.Type); 6720Assert.Equal(typeInfo.Type, propertyRef.Type); 6786Assert.Equal(typeInfo.Type, propertyRef.Type); 6794AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 6795AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 6796AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6895Assert.Equal(typeInfo.Type, propertyRef.Type); 6903AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 6904AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 6905AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7005Assert.Equal(typeInfo.Type, propertyRef.Type); 7013AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7014AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 7015AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7102Assert.Equal(typeInfo.Type, propertyRef.Type); 7110AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7111AssertEx.Equal("System.Object", operation.Value.Type.ToTestDisplayString()); 7112AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7174Assert.Equal(typeInfo.Type, propertyRef.Type); 7277Assert.Equal(typeInfo.Type, propertyRef.Type); 7287AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7288AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 7289AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7390Assert.Equal(typeInfo.Type, propertyRef.Type); 7400AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7401AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 7402AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7506Assert.Equal(typeInfo.Type, propertyRef.Type); 7516AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7517AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 7518AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7619Assert.Equal(typeInfo.Type, propertyRef.Type); 7630AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7631AssertEx.Equal("C2", operation.Value.Type.ToTestDisplayString()); 7632AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7633Assert.False(operation.Type.IsErrorType()); 7696Assert.Equal(typeInfo.Type, propertyRef.Type); 7801Assert.Equal(typeInfo.Type, propertyRef.Type); 7811AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7812AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7907Assert.Equal(typeInfo.Type, propertyRef.Type); 7917AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7918AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8011Assert.Equal(typeInfo.Type, propertyRef.Type); 8022AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8023AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8082Assert.Equal(typeInfo.Type, propertyRef.Type); 8092AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8093AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8188Assert.Equal(typeInfo.Type, propertyRef.Type); 8198AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8199AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8293Assert.Equal(typeInfo.Type, propertyRef.Type); 8303AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8304AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8398Assert.Equal(typeInfo.Type, propertyRef.Type); 8406AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8407AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8408AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8507Assert.Equal(typeInfo.Type, propertyRef.Type); 8515AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8516AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8517AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8616Assert.Equal(typeInfo.Type, propertyRef.Type); 8624AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8625AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8626AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8726Assert.Equal(typeInfo.Type, propertyRef.Type); 8734AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8735AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8736AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8835Assert.Equal(typeInfo.Type, propertyRef.Type); 8843AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8844AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8845AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8904Assert.Equal(typeInfo.Type, propertyRef.Type); 8912AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8913AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8914AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8976Assert.Equal(typeInfo.Type, propertyRef.Type); 8984AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8985AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8986AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9032Assert.Equal(typeInfo.Type, propertyRef.Type); 9040AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9041AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9042AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9122Assert.Equal(typeInfo.Type, propertyRef.Type); 9130AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9131AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9132AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9213Assert.Equal(typeInfo.Type, propertyRef.Type); 9221AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9222AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9223AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9303Assert.Equal(typeInfo.Type, propertyRef.Type); 9311AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9312AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9313AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9359Assert.Equal(typeInfo.Type, propertyRef.Type); 9367AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9368AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9369AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9420Assert.Equal(typeInfo.Type, propertyRef.Type); 9428AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9541Assert.Equal(typeInfo.Type, propertyRef.Type); 9549AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9661Assert.Equal(typeInfo.Type, propertyRef.Type); 9669AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9775Assert.Equal(typeInfo.Type, propertyRef.Type); 9783AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9886Assert.Equal(typeInfo.Type, propertyRef.Type); 9894AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9997Assert.Equal(typeInfo.Type, propertyRef.Type); 10005AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 10128Assert.Equal(typeInfo.Type, propertyRef.Type); 10143Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10144Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10145Assert.Equal(typeInfo.Type, operation.Type); 10256Assert.Equal(typeInfo.Type, propertyRef.Type); 10271Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10272Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10273Assert.Equal(typeInfo.Type, operation.Type); 10384Assert.Equal(typeInfo.Type, propertyRef.Type); 10399Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10400Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10401Assert.Equal(typeInfo.Type, operation.Type); 10538Assert.Equal(typeInfo.Type, propertyRef.Type); 10553Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10554Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10555Assert.Equal(typeInfo.Type, operation.Type); 10672Assert.Equal(typeInfo.Type, propertyRef.Type); 10687Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10688Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 10689Assert.Equal(typeInfo.Type, operation.Type); 10820Assert.Equal(typeInfo.Type, propertyRef.Type); 10835Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10836Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 10837Assert.Equal(typeInfo.Type, operation.Type); 11090Assert.Equal(typeInfo.Type, propertyRef.Type); 11105Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 11106Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 11107Assert.Equal(typeInfo.Type, operation.Type); 11433AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11486AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11562AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11606AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11647AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11699AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11751AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11791AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString());
Semantics\ObjectAndCollectionInitializerTests.cs (8)
4236Assert.Equal(typeInfo.Type, propertyRef.Type); 4244AssertEx.Equal("System.Int32", operation.Target.Type.ToTestDisplayString()); 4245AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 4246AssertEx.Equal("System.Int32", operation.Type.ToTestDisplayString()); 4290Assert.Equal(typeInfo.Type, propertyRef.Type); 4298AssertEx.Equal("System.Int32", operation.Target.Type.ToTestDisplayString()); 4299AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 4300AssertEx.Equal("System.Int32", operation.Type.ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (1)
Symbols\Source\NullablePublicAPITests.cs (1)
4965AssertEx.Equal("(System.Object, System.Int32 a)", operation.Type.ToTestDisplayString());
Microsoft.CodeAnalysis.CSharp.Test.Utilities (7)
CompilationTestUtils.cs (7)
361else if (iop is { Type: { } }) 363Assert.Equal(typeInfo.Type.NullableAnnotation, iop.Type.NullableAnnotation); 383Assert.Null(iop?.Type); 385else if (iop is { Type: { } }) 387Assert.Equal(typeInfo.ConvertedType.NullableAnnotation, iop.Type.NullableAnnotation); 428Assert.True(iop.Type?.NullableAnnotation == typeInfo.ConvertedType?.NullableAnnotation); 432Assert.Null(iop?.Type);
Microsoft.CodeAnalysis.CSharp.Workspaces (24)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (23)
97while (current is IConversionOperation { Type.SpecialType: SpecialType.System_Delegate or SpecialType.System_MulticastDelegate }) 100if (current is IConversionOperation { Type.SpecialType: SpecialType.System_Object }) 107if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 236conversionOperation.Type.RemoveNullableIfPresent() is var type1 && 237conversionOperation.Operand.Type.RemoveNullableIfPresent() is var type2 && 253if (originalDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 270if (rewrittenDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 274if (!Equals(originalDelegateCreationOperation.Type, rewrittenDelegateCreationOperation.Type)) 410var isAcceptableSpanConversion = originalConversionOperation.Type.IsSpan() && originalParentConversionOperation.Type.IsReadOnlySpan(); 553if (castNode.IsParentKind(SyntaxKind.Interpolation) && originalConversionOperation.Type?.SpecialType is SpecialType.System_Object) 791if (!IsSignedIntegralOrIntPtrType(originalConversionOperation.Type) || 792!IsSignedIntegralOrIntPtrType(originalConversionOperation.Operand.Type)) 818var originalConvertedType = originalConversionOperation.Type; 819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type; 962if (castType.Equals(rewrittenOperation.Type, SymbolEqualityComparer.IncludeNullability)) 967castType.Equals(conditionalParentConversion.Type, SymbolEqualityComparer.IncludeNullability)) 1009if (!rewrittenConditionalConvertedType.Equals(conversionOperation.Type)) 1023if (conversionOperation.Type.IsSpanOrReadOnlySpan() && 1051if (binaryOperation.LeftOperand.Type?.SpecialType == SpecialType.System_Object && 1058else if (binaryOperation.RightOperand.Type?.SpecialType == SpecialType.System_Object && 1081if (conversionOperation.Operand.Type is not INamedTypeSymbol original)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
226if (argumentOp is not { Value.Type: { } valueType, Parameter.Type: { } parameterType })
Microsoft.CodeAnalysis.Features (37)
ConvertForEachToFor\AbstractConvertForEachToForCodeRefactoringProvider.cs (1)
207var collectionType = foreachCollection.Type;
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (1)
464_switchTargetType = operation.Type;
InitializeParameter\AbstractAddParameterCheckCodeRefactoringProvider.cs (1)
323} && value.Type.IsNumericType())
SignatureHelp\CommonSignatureHelpUtilities.cs (1)
161var parentType = parentOperation?.Type;
src\Analyzers\Core\Analyzers\Helpers\HashCodeAnalyzer\HashCodeAnalyzer.OperationDeconstructor.cs (1)
123Equals(_method.ContainingType.BaseType, instanceReference.Type))
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
248return operation is { Type.IsValueType: true, Parent: IPropertyReferenceOperation }
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
58var type = value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchExpressionDiagnosticAnalyzer.cs (1)
26=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
26=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchExpressionHelpers.cs (2)
19var switchExpressionType = switchExpression?.Type; 108var type = operation.Value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (2)
58var switchExpressionType = switchExpression?.Type; 185var type = operation.Value.Type;
src\Analyzers\Core\Analyzers\RemoveRedundantEquality\AbstractRemoveRedundantEqualityDiagnosticAnalyzer.cs (2)
85var leftType = leftOperand.Type; 86var rightType = rightOperand.Type;
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.BlockAnalyzer.cs (6)
175if (value.Type == null || 176value.Type.IsErrorType() || 177value.Type.SpecialType == SpecialType.System_Void) 183if (value.Type.TypeKind == TypeKind.Dynamic) 311if (!operation.Type.IsDelegateType()) 341if (assignmentOperation.Target.Type.IsDelegateType() &&
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationDiagnosticAnalyzer.cs (1)
64if (interpolation.Parent is IInterpolatedStringOperation { Parent: IConversionOperation { Type: { } convertedType } conversion } &&
src\Analyzers\Core\Analyzers\SimplifyInterpolation\AbstractSimplifyInterpolationHelpers.cs (3)
138if (instance.Type is { IsRefLikeType: false } || IsRefLikeTypeAllowed(instance.Type)) 145instance.Type.Implements(systemIFormattable))
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (3)
72!AreEqualOrHaveImplicitConversion(trueAssignment.Type, falseAssignment.Type, trueAssignment.SemanticModel!.Compilation)) 91if (nullCheckedExpression is { Type.IsValueType: true })
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchExpressionCodeFixProvider.cs (1)
38=> switchExpression.Value.Type ?? throw ExceptionUtilities.Unreachable();
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchStatementCodeFixProvider.cs (1)
60=> switchOperation.Value.Type ?? throw ExceptionUtilities.Unreachable();
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (5)
184conversion.Type != null && 185conversion.Type.TypeKind != TypeKind.Error) 189if (conversion.Operand.Type == null || conversion.Operand.Type.TypeKind != TypeKind.Error) 191return (TExpressionSyntax)generator.CastExpression(conversion.Type, sourceSyntax);
ValueTracking\ValueTracker.OperationCollector.cs (2)
155if (literalOperation.Type is null) 160return AddOperationAsync(literalOperation, literalOperation.Type, cancellationToken);
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (16)
ExplicitAllocationAnalyzer.cs (3)
101if (context.Operation.Type?.IsReferenceType == true) 109if (conversion.Type?.IsReferenceType == true && conversion.Operand.Type?.IsValueType == true)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
Microsoft.CodeAnalysis.PublicApiAnalyzers (11)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Microsoft.CodeAnalysis.ResxSourceGenerator (11)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
Microsoft.CodeAnalysis.Test.Utilities (52)
Compilation\CompilationExtensions.cs (2)
306Assert.True(operation.Type == null || !operation.MustHaveNullType(), $"Unexpected non-null type: {operation.Type}");
Compilation\ControlFlowGraphVerifier.cs (11)
916&& arguments[0].Value.Type.SpecialType == SpecialType.System_Int32 917&& arguments[1].Value.Type.SpecialType == SpecialType.System_Int32; 949(ITypeSymbolHelpers.IsDynamicType(binOp.Type) && 950(ITypeSymbolHelpers.IsDynamicType(binOp.LeftOperand.Type) || ITypeSymbolHelpers.IsDynamicType(binOp.RightOperand.Type))))) 999ITypeSymbolHelpers.IsNullableType(reference.Type) && 1878!ITypeSymbolHelpers.IsBooleanType(binary.Type) && 1879!ITypeSymbolHelpers.IsNullableOfBoolean(binary.Type) && 1880!ITypeSymbolHelpers.IsObjectType(binary.Type) && 1881!ITypeSymbolHelpers.IsDynamicType(binary.Type)); 1892n.Type.IsAnonymousType &&
Compilation\OperationTreeVerifier.cs (6)
107LogType(operation.Type); 308Assert.True(operation.Type == null || !operation.MustHaveNullType(), $"Unexpected non-null type: {operation.Type}"); 1074Assert.Null(operation.Type); 1130Assert.NotNull(operation.Type); 1606Assert.Null(operation.Type);
Compilation\TestOperationVisitor.cs (11)
48var type = operation.Type; 572Assert.Same(((IFunctionPointerTypeSymbol)operation.Target.Type).Signature, signature); 730Assert.NotNull(operation.Type); 1027if (!operation.Type.IsValueType) 1153Assert.Null(operation.Type); 1362Assert.Null(pattern.Type); 1550Assert.NotNull(operation.Type); 1560Assert.Null(operation.Type); 1690Assert.Equal(operation.Type, discardSymbol.Type); 1726Assert.NotNull(operation.Value.Type); 1801Assert.Null(operation.Type);
Diagnostics\BoxingOperationAnalyzer.cs (4)
48if (conversion.Type.IsReferenceType && 49conversion.Operand.Type != null && 50conversion.Operand.Type.IsValueType && 63invocation.Instance.Type.IsValueType &&
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (3)
67ITypeSymbol type = increment.Type; 286return conversion.Operand.Type; 290return value.Type;
Diagnostics\FieldCouldBeReadOnlyAnalyzer.cs (1)
135if (fieldReference.Instance != null && fieldReference.Instance.Type.IsValueType)
Diagnostics\LocalCouldBeConstAnalyzer.cs (1)
126if (fieldReference.Instance != null && fieldReference.Instance.Type.IsValueType)
Diagnostics\OperationTestAnalyzer.cs (13)
57if (invalidOperation.Type == null) 159conditionRight.Type.SpecialType == SpecialType.System_Int32 && 176setupAssignment.Value.Type.SpecialType == SpecialType.System_Int32) 241advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) 250advanceOperation.RightOperand.Type.SpecialType == SpecialType.System_Int32) 265advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) 357singleValueExpression.Type.SpecialType == SpecialType.System_Int32) 377rangeMinExpression.Type.SpecialType == SpecialType.System_Int32 && 380rangeMaxExpression.Type.SpecialType == SpecialType.System_Int32) 400relationalValueExpression.Type.SpecialType == SpecialType.System_Int32) 587if (argumentValue.HasValue && argument.Type.SpecialType == SpecialType.System_Int32) 631if (literal.Type.SpecialType == SpecialType.System_Int32 && 1521if (binary.OperatorKind == BinaryOperatorKind.Multiply && binary.Type.SpecialType == SpecialType.System_Double)
Microsoft.CodeAnalysis.VisualBasic (3)
Compilation\VisualBasicCompilation.vb (1)
1906Dim sourceType As ITypeSymbol = source.Type
Operations\VisualBasicOperationFactory_Methods.vb (2)
349Dim type As ITypeSymbol = target.Type 521adjustedInfo.Operation.Type,
Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers (2)
Microsoft.NetCore.Analyzers\Runtime\BasicUseSpanBasedStringConcat.vb (1)
36If conversion IsNot Nothing AndAlso conversion.Type.SpecialType = SpecialType.System_Object AndAlso
Microsoft.NetCore.Analyzers\Usage\BasicPreferGenericOverloads.Fixer.vb (1)
53If typeInfo.ConvertedType.IsAssignableTo(conversionOperation.Type, invocationContext.SemanticModel.Compilation) Then
Microsoft.CodeAnalysis.Workspaces (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
Microsoft.Interop.ComInterfaceGenerator (10)
Analyzers\ComHostingDoesNotSupportGeneratedComInterfaceAnalyzer.cs (1)
45|| !comVisibleAttribute.Equals(ctor.Type, SymbolEqualityComparer.Default)
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (9)
143if (operation.Type is INamedTypeSymbol { IsComImport: true } && !enableGeneratedComInterfaceComImportInterop) 146if (operand is IConversionOperation { Type.SpecialType: SpecialType.System_Object } objConversion) 150if (operand.Type is null) 158if (recognizer(operand.Type)) 171if (recognizer(operation.Type)) 174if (operand is IConversionOperation { Type.SpecialType: SpecialType.System_Object } objConversion) 178if (operand.Type is INamedTypeSymbol { IsComImport: true } && !enableGeneratedComInterfaceComImportInterop) 202IConversionOperation conversion => (conversion.Operand.Type, conversion.Operand.Syntax.GetLocation()), 203IOperation op => (op.Type, op.Syntax.GetLocation())
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\CustomMarshallerAttributeAnalyzer.cs (1)
646&& attrCreation.Type.Equals(_customMarshallerAttribute, SymbolEqualityComparer.Default))
Analyzers\NativeMarshallingAttributeAnalyzer.cs (1)
88&& attrCreation.Type.ToDisplayString() == TypeNames.NativeMarshallingAttribute)
Roslyn.Diagnostics.Analyzers (20)
AbstractDoNotCopyValue.cs (6)
1108else if (operation.GetRefKind(_context.OwningSymbol) == RefKind.None && Cache.IsNonCopyableType(returnedValue.Type)) 1110_context.ReportDiagnostic(returnedValue.CreateDiagnostic(NoReturnValueFromReferenceRule, returnedValue.Type)); 1126if (Cache.IsNonCopyableType(value.Type) 1131_context.ReportDiagnostic(value.CreateDiagnostic(NoAssignValueFromReferenceRule, value.Type)); 1375{ Type: INamedTypeSymbol { OriginalDefinition: var taskType } } 1645var symbol = operation.Type;
DoNotCallGetTestAccessor.cs (1)
79if (objectCreation.Type!.Name.Equals(TestAccessorHelper.TestAccessorTypeName, StringComparison.Ordinal))
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;
Roslyn.Diagnostics.CSharp.Analyzers (25)
PreferNullLiteral.cs (1)
51var type = context.Operation.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (23)
97while (current is IConversionOperation { Type.SpecialType: SpecialType.System_Delegate or SpecialType.System_MulticastDelegate }) 100if (current is IConversionOperation { Type.SpecialType: SpecialType.System_Object }) 107if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 236conversionOperation.Type.RemoveNullableIfPresent() is var type1 && 237conversionOperation.Operand.Type.RemoveNullableIfPresent() is var type2 && 253if (originalDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 270if (rewrittenDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 274if (!Equals(originalDelegateCreationOperation.Type, rewrittenDelegateCreationOperation.Type)) 410var isAcceptableSpanConversion = originalConversionOperation.Type.IsSpan() && originalParentConversionOperation.Type.IsReadOnlySpan(); 553if (castNode.IsParentKind(SyntaxKind.Interpolation) && originalConversionOperation.Type?.SpecialType is SpecialType.System_Object) 791if (!IsSignedIntegralOrIntPtrType(originalConversionOperation.Type) || 792!IsSignedIntegralOrIntPtrType(originalConversionOperation.Operand.Type)) 818var originalConvertedType = originalConversionOperation.Type; 819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type; 962if (castType.Equals(rewrittenOperation.Type, SymbolEqualityComparer.IncludeNullability)) 967castType.Equals(conditionalParentConversion.Type, SymbolEqualityComparer.IncludeNullability)) 1009if (!rewrittenConditionalConvertedType.Equals(conversionOperation.Type)) 1023if (conversionOperation.Type.IsSpanOrReadOnlySpan() && 1051if (binaryOperation.LeftOperand.Type?.SpecialType == SpecialType.System_Object && 1058else if (binaryOperation.RightOperand.Type?.SpecialType == SpecialType.System_Object && 1081if (conversionOperation.Operand.Type is not INamedTypeSymbol original)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
226if (argumentOp is not { Value.Type: { } valueType, Parameter.Type: { } parameterType })
System.Text.RegularExpressions.Generator (1)
UpgradeToGeneratedRegexAnalyzer.cs (1)
126if (!SymbolEqualityComparer.Default.Equals(operation.Type, regexTypeSymbol))
Test.Utilities (18)
ICollectionExpressionOperationWrapper.cs (1)
26public ITypeSymbol? Type => WrappedOperation.Type;
IFunctionPointerInvocationOperationWrapper.cs (1)
51public ITypeSymbol? Type => WrappedOperation.Type;
IOperationExtensions.cs (15)
34invocation.Instance.Type; 43firstArg.Value.Type; 91if (operation.Type == null || operation.Type.IsErrorType()) 96if (operation.Type.IsPrimitiveType()) 98return HasConstantValue(constantValue, operation.Type, comparand); 101if (operation.Type.TypeKind == TypeKind.Enum) 103var enumUnderlyingType = ((INamedTypeSymbol)operation.Type).EnumUnderlyingType; 124return (arrayCreation?.Type as IArrayTypeSymbol)?.ElementType; 138if (operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null))) 562&& operation.GetAncestor(s_LambdaAndLocalFunctionKinds)?.Parent?.Type?.OriginalDefinition is { } lambdaType 583IConstantPatternOperation constantPattern => constantPattern.Value.Type, 651return instance?.WalkDownConversion().Type; 763=> operation.GetThrownException()?.Type; 816(current.ConstantValue.HasValue || current.Type != null))
IUtf8StringOperationWrapper.cs (1)
25public ITypeSymbol? Type => WrappedOperation.Type;
Text.Analyzers (13)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (1)
329return !operation.DescendantsAndSelf().All(o => o.IsImplicit || (!o.ConstantValue.HasValue && o.Type == null && o.Kind is not (OperationKind.Branch or OperationKind.Attribute)));
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (2)
298AddCoupledNamedTypesCore(builder, operation.Type, context.WellKnownTypeProvider); 340(binaryOperation.Type.SpecialType == SpecialType.System_Boolean &&
src\RoslynAnalyzers\Utilities\Compiler\Extensions\IOperationExtensions.cs (4)
35invocation.Instance.Type; 44firstArg.Value.Type; 398IConstantPatternOperation constantPattern => constantPattern.Value.Type, 468=> operation.GetThrownException()?.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
378=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 457notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
363operation.Value.Type.IsDelegateType()) 499Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
272var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 453var type = variableExpression.Type;