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)
27088ITypeSymbol IOperation.Type => throw null;
630 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)
91 if (operation.Type is not null) 188 (operation.Type?.TypeKind == TypeKind.Enum || operation.Type?.SpecialType == SpecialType.System_Int32)) { 432 } else if (operation.Type?.TypeKind == TypeKind.Enum && constantValue is int enumConstantValue) { 436 switch (operation.Type?.SpecialType) {
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.CodeStyle (25)
src\Analyzers\Core\Analyzers\Helpers\HashCodeAnalyzer\HashCodeAnalyzer.OperationDeconstructor.cs (1)
123Equals(_method.ContainingType.BaseType, instanceReference.Type))
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
60var type = value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchExpressionDiagnosticAnalyzer.cs (1)
27=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
27=> 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\AbstractSimplifyInterpolationHelpers.cs (3)
84instance.Type != null && 85!instance.Type.IsRefLikeType) 92instance.Type.Implements(systemIFormattable))
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (2)
69!AreEqualOrHaveImplicitConversion(trueAssignment.Type, falseAssignment.Type, trueAssignment.SemanticModel!.Compilation))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
375=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 454notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
364operation.Value.Type.IsDelegateType()) 500Debug.Assert(operation.Type.IsDelegateType());
Microsoft.CodeAnalysis.CodeStyle.Fixes (9)
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchExpressionCodeFixProvider.cs (1)
44=> 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)
177conversion.Type != null && 178conversion.Type.TypeKind != TypeKind.Error) 182if (conversion.Operand.Type == null || conversion.Operand.Type.TypeKind != TypeKind.Error) 184return (TExpressionSyntax)generator.CastExpression(conversion.Type, sourceSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
276var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 457var type = variableExpression.Type;
Microsoft.CodeAnalysis.CSharp (2)
Compilation\CSharpCompilation.cs (1)
2340ITypeSymbol? sourceType = source.Type;
Operations\CSharpOperationFactory_Methods.cs (1)
465ITypeSymbol? assignmentType = target.Type;
Microsoft.CodeAnalysis.CSharp.CodeStyle (30)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
259return instance is { Type.TypeKind: TypeKind.Struct } || 260instance is { Type: ITypeParameterSymbol { HasReferenceTypeConstraint: false } }; 364if (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)
106if (isTypeOperation.ValueOperand.Type is not null && 107isTypeOperation.ValueOperand.Type.InheritsFromOrEquals(isTypeOperation.TypeOperand))
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
248=> value.UnwrapImplicitConversion() is IObjectCreationOperation { Type.SpecialType: SpecialType.System_Object };
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
78if (arrayCreationOperation.Type is not IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Byte })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (21)
96while (current is IConversionOperation { Type.SpecialType: SpecialType.System_Delegate or SpecialType.System_MulticastDelegate }) 99if (current is IConversionOperation { Type.SpecialType: SpecialType.System_Object }) 106if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 235conversionOperation.Type.RemoveNullableIfPresent() is var type1 && 236conversionOperation.Operand.Type.RemoveNullableIfPresent() is var type2 && 252if (originalDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 269if (rewrittenDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 273if (!Equals(originalDelegateCreationOperation.Type, rewrittenDelegateCreationOperation.Type)) 409var isAcceptableSpanConversion = originalConversionOperation.Type.IsSpan() && originalParentConversionOperation.Type.IsReadOnlySpan(); 552if (castNode.IsParentKind(SyntaxKind.Interpolation) && originalConversionOperation.Type?.SpecialType is SpecialType.System_Object) 780if (!IsSignedIntegralOrIntPtrType(originalConversionOperation.Type) || 781!IsSignedIntegralOrIntPtrType(originalConversionOperation.Operand.Type)) 807var originalConvertedType = originalConversionOperation.Type; 808var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type; 885if (castType.Equals(rewrittenConditionalOperation.Type, SymbolEqualityComparer.IncludeNullability)) 890castType.Equals(conditionalParentConversion.Type, SymbolEqualityComparer.IncludeNullability)) 916if (binaryOperation.LeftOperand.Type?.SpecialType == SpecialType.System_Object && 923else if (binaryOperation.RightOperand.Type?.SpecialType == SpecialType.System_Object && 946if (conversionOperation.Operand.Type is not INamedTypeSymbol original)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
240if (argumentOp is not { Value.Type: { } valueType, Parameter.Type: { } parameterType })
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (2)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
614IInstanceReferenceOperation 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)
1085Assert.Equal(expectedType, model.GetOperation(decl)?.Type);
Microsoft.CodeAnalysis.CSharp.Features (10)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
259return instance is { Type.TypeKind: TypeKind.Struct } || 260instance is { Type: ITypeParameterSymbol { HasReferenceTypeConstraint: false } }; 364if (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)
106if (isTypeOperation.ValueOperand.Type is not null && 107isTypeOperation.ValueOperand.Type.InheritsFromOrEquals(isTypeOperation.TypeOperand))
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
248=> value.UnwrapImplicitConversion() is IObjectCreationOperation { Type.SpecialType: SpecialType.System_Object };
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
78if (arrayCreationOperation.Type is not IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Byte })
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (1)
614IInstanceReferenceOperation 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.Semantic.UnitTests (175)
Semantics\DelegateTypeTests.cs (1)
14757Assert.Equal("System.Func<System.Int32, System.String>", value.Type.ToTestDisplayString());
Semantics\DynamicTests.cs (166)
4994AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5118AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5241AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5484AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5528AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5705AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5836AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 5881AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6039AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6162AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6282AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6390AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6432Assert.Equal(typeInfo.Type, propertyRef.Type); 6479Assert.Equal(typeInfo.Type, propertyRef.Type); 6523Assert.Equal(typeInfo.Type, propertyRef.Type); 6568Assert.Equal(typeInfo.Type, propertyRef.Type); 6622Assert.Equal(typeInfo.Type, propertyRef.Type); 6688Assert.Equal(typeInfo.Type, propertyRef.Type); 6696AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 6697AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 6698AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6797Assert.Equal(typeInfo.Type, propertyRef.Type); 6805AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 6806AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 6807AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 6907Assert.Equal(typeInfo.Type, propertyRef.Type); 6915AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 6916AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 6917AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7004Assert.Equal(typeInfo.Type, propertyRef.Type); 7012AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7013AssertEx.Equal("System.Object", operation.Value.Type.ToTestDisplayString()); 7014AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7076Assert.Equal(typeInfo.Type, propertyRef.Type); 7179Assert.Equal(typeInfo.Type, propertyRef.Type); 7189AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7190AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 7191AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7292Assert.Equal(typeInfo.Type, propertyRef.Type); 7302AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7303AssertEx.Equal("System.Int32", operation.Value.Type.ToTestDisplayString()); 7304AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7408Assert.Equal(typeInfo.Type, propertyRef.Type); 7418AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7419AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 7420AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7521Assert.Equal(typeInfo.Type, propertyRef.Type); 7532AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7533AssertEx.Equal("C2", operation.Value.Type.ToTestDisplayString()); 7534AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7535Assert.False(operation.Type.IsErrorType()); 7598Assert.Equal(typeInfo.Type, propertyRef.Type); 7703Assert.Equal(typeInfo.Type, propertyRef.Type); 7713AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7714AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7809Assert.Equal(typeInfo.Type, propertyRef.Type); 7819AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7820AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7913Assert.Equal(typeInfo.Type, propertyRef.Type); 7924AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7925AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 7984Assert.Equal(typeInfo.Type, propertyRef.Type); 7994AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 7995AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8090Assert.Equal(typeInfo.Type, propertyRef.Type); 8100AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8101AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8195Assert.Equal(typeInfo.Type, propertyRef.Type); 8205AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8206AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8300Assert.Equal(typeInfo.Type, propertyRef.Type); 8308AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8309AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8310AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8409Assert.Equal(typeInfo.Type, propertyRef.Type); 8417AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8418AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8419AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8518Assert.Equal(typeInfo.Type, propertyRef.Type); 8526AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8527AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8528AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8628Assert.Equal(typeInfo.Type, propertyRef.Type); 8636AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8637AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8638AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8737Assert.Equal(typeInfo.Type, propertyRef.Type); 8745AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8746AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8747AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8806Assert.Equal(typeInfo.Type, propertyRef.Type); 8814AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8815AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8816AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8878Assert.Equal(typeInfo.Type, propertyRef.Type); 8886AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8887AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8888AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 8934Assert.Equal(typeInfo.Type, propertyRef.Type); 8942AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 8943AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 8944AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9024Assert.Equal(typeInfo.Type, propertyRef.Type); 9032AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9033AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9034AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9115Assert.Equal(typeInfo.Type, propertyRef.Type); 9123AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9124AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9125AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9205Assert.Equal(typeInfo.Type, propertyRef.Type); 9213AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9214AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9215AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9261Assert.Equal(typeInfo.Type, propertyRef.Type); 9269AssertEx.Equal("dynamic", operation.Target.Type.ToTestDisplayString()); 9270AssertEx.Equal("dynamic", operation.Value.Type.ToTestDisplayString()); 9271AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9322Assert.Equal(typeInfo.Type, propertyRef.Type); 9330AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9443Assert.Equal(typeInfo.Type, propertyRef.Type); 9451AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9563Assert.Equal(typeInfo.Type, propertyRef.Type); 9571AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9677Assert.Equal(typeInfo.Type, propertyRef.Type); 9685AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9788Assert.Equal(typeInfo.Type, propertyRef.Type); 9796AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 9899Assert.Equal(typeInfo.Type, propertyRef.Type); 9907AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 10030Assert.Equal(typeInfo.Type, propertyRef.Type); 10045Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10046Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10047Assert.Equal(typeInfo.Type, operation.Type); 10158Assert.Equal(typeInfo.Type, propertyRef.Type); 10173Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10174Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10175Assert.Equal(typeInfo.Type, operation.Type); 10286Assert.Equal(typeInfo.Type, propertyRef.Type); 10301Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10302Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10303Assert.Equal(typeInfo.Type, operation.Type); 10440Assert.Equal(typeInfo.Type, propertyRef.Type); 10455Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10456Assert.Equal(tupleTypeInfo.Type, operation.Value.Type); 10457Assert.Equal(typeInfo.Type, operation.Type); 10574Assert.Equal(typeInfo.Type, propertyRef.Type); 10589Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10590Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 10591Assert.Equal(typeInfo.Type, operation.Type); 10722Assert.Equal(typeInfo.Type, propertyRef.Type); 10737Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 10738Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 10739Assert.Equal(typeInfo.Type, operation.Type); 10992Assert.Equal(typeInfo.Type, propertyRef.Type); 11007Assert.Equal(tupleTypeInfo.Type, operation.Target.Type); 11008Assert.Equal("C2", operation.Value.Type.ToTestDisplayString()); 11009Assert.Equal(typeInfo.Type, operation.Type); 11335AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11388AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11464AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11508AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11549AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11601AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11653AssertEx.Equal("dynamic", operation.Type.ToTestDisplayString()); 11693AssertEx.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)
4968AssertEx.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 (22)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (21)
96while (current is IConversionOperation { Type.SpecialType: SpecialType.System_Delegate or SpecialType.System_MulticastDelegate }) 99if (current is IConversionOperation { Type.SpecialType: SpecialType.System_Object }) 106if (current.Parent is IConversionOperation { Type: { } parentConversionType, IsImplicit: false } && 235conversionOperation.Type.RemoveNullableIfPresent() is var type1 && 236conversionOperation.Operand.Type.RemoveNullableIfPresent() is var type2 && 252if (originalDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 269if (rewrittenDelegateCreationOperation.Type?.TypeKind != TypeKind.Delegate) 273if (!Equals(originalDelegateCreationOperation.Type, rewrittenDelegateCreationOperation.Type)) 409var isAcceptableSpanConversion = originalConversionOperation.Type.IsSpan() && originalParentConversionOperation.Type.IsReadOnlySpan(); 552if (castNode.IsParentKind(SyntaxKind.Interpolation) && originalConversionOperation.Type?.SpecialType is SpecialType.System_Object) 780if (!IsSignedIntegralOrIntPtrType(originalConversionOperation.Type) || 781!IsSignedIntegralOrIntPtrType(originalConversionOperation.Operand.Type)) 807var originalConvertedType = originalConversionOperation.Type; 808var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type; 885if (castType.Equals(rewrittenConditionalOperation.Type, SymbolEqualityComparer.IncludeNullability)) 890castType.Equals(conditionalParentConversion.Type, SymbolEqualityComparer.IncludeNullability)) 916if (binaryOperation.LeftOperand.Type?.SpecialType == SpecialType.System_Object && 923else if (binaryOperation.RightOperand.Type?.SpecialType == SpecialType.System_Object && 946if (conversionOperation.Operand.Type is not INamedTypeSymbol original)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
240if (argumentOp is not { Value.Type: { } valueType, Parameter.Type: { } parameterType })
Microsoft.CodeAnalysis.Features (33)
ConvertForEachToFor\AbstractConvertForEachToForCodeRefactoringProvider.cs (1)
207var collectionType = foreachCollection.Type;
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (1)
461_switchTargetType = operation.Type;
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\PopulateSwitch\AbstractPopulateSwitchDiagnosticAnalyzer.cs (1)
60var type = value.Type;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchExpressionDiagnosticAnalyzer.cs (1)
27=> operation.Value.Type is null;
src\Analyzers\Core\Analyzers\PopulateSwitch\AbstractPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
27=> 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\AbstractSimplifyInterpolationHelpers.cs (3)
84instance.Type != null && 85!instance.Type.IsRefLikeType) 92instance.Type.Implements(systemIFormattable))
src\Analyzers\Core\Analyzers\UseConditionalExpression\ForAssignment\UseConditionalExpressionForAssignmentHelpers.cs (2)
69!AreEqualOrHaveImplicitConversion(trueAssignment.Type, falseAssignment.Type, trueAssignment.SemanticModel!.Compilation))
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchExpressionCodeFixProvider.cs (1)
44=> 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)
177conversion.Type != null && 178conversion.Type.TypeKind != TypeKind.Error) 182if (conversion.Operand.Type == null || conversion.Operand.Type.TypeKind != TypeKind.Error) 184return (TExpressionSyntax)generator.CastExpression(conversion.Type, sourceSyntax);
ValueTracking\ValueTracker.OperationCollector.cs (2)
154if (literalOperation.Type is null) 159return AddOperationAsync(literalOperation, literalOperation.Type, cancellationToken);
Microsoft.CodeAnalysis.Test.Utilities (52)
Compilation\CompilationExtensions.cs (2)
302Assert.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); 321Assert.True(operation.Type == null || !operation.MustHaveNullType(), $"Unexpected non-null type: {operation.Type}"); 1092Assert.Null(operation.Type); 1148Assert.NotNull(operation.Type); 1624Assert.Null(operation.Type);
Compilation\TestOperationVisitor.cs (11)
47var type = operation.Type; 571Assert.Same(((IFunctionPointerTypeSymbol)operation.Target.Type).Signature, signature); 729Assert.NotNull(operation.Type); 1026if (!operation.Type.IsValueType) 1152Assert.Null(operation.Type); 1361Assert.Null(pattern.Type); 1549Assert.NotNull(operation.Type); 1559Assert.Null(operation.Type); 1689Assert.Equal(operation.Type, discardSymbol.Type); 1725Assert.NotNull(operation.Value.Type); 1800Assert.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)
1905Dim sourceType As ITypeSymbol = source.Type
Operations\VisualBasicOperationFactory_Methods.vb (2)
349Dim type As ITypeSymbol = target.Type 521adjustedInfo.Operation.Type,
Microsoft.CodeAnalysis.Workspaces (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (2)
375=> operation.Kind == OperationKind.Literal && operation.Type.IsNumericType(); 454notImplementedExceptionType.Equals(objectCreation.Type);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (2)
364operation.Value.Type.IsDelegateType()) 500Debug.Assert(operation.Type.IsDelegateType());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
276var valueType = (operation as IIsPatternOperation)?.Value.Type?.SpecialType; 457var 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)
System.Text.RegularExpressions.Generator (1)
UpgradeToGeneratedRegexAnalyzer.cs (1)
126if (!SymbolEqualityComparer.Default.Equals(operation.Type, regexTypeSymbol))