638 references to TypedConstantKind
ILLink.RoslynAnalyzer (1)
DataFlow\LocalDataFlowVisitor.cs (1)
878
if (attributeArgument.Kind !=
TypedConstantKind
.Primitive)
Microsoft.AspNetCore.App.Analyzers (1)
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (1)
358
if (argument.Kind !=
TypedConstantKind
.Primitive || argument.Value is not string argString)
Microsoft.AspNetCore.Mvc.Analyzers (2)
TopLevelParameterNameAnalyzer.cs (2)
164
namedArgumentValue.Kind ==
TypedConstantKind
.Primitive &&
187
namedArgumentValue.Kind ==
TypedConstantKind
.Type)
Microsoft.AspNetCore.Mvc.Api.Analyzers (9)
ActualApiResponseMetadataFactory.cs (1)
250
attribute.ConstructorArguments[0].Kind ==
TypedConstantKind
.Primitive &&
SymbolApiConventionMatcher.cs (2)
66
attribute.ConstructorArguments[0].Kind !=
TypedConstantKind
.Enum)
88
attribute.ConstructorArguments[0].Kind !=
TypedConstantKind
.Enum)
SymbolApiResponseMetadataProvider.cs (6)
55
errorTypeAttribute.ConstructorArguments[0].Kind ==
TypedConstantKind
.Type &&
98
if (attribute.ConstructorArguments[0].Kind !=
TypedConstantKind
.Type ||
104
if (attribute.ConstructorArguments[1].Kind !=
TypedConstantKind
.Primitive ||
174
attribute.ConstructorArguments[0].Kind !=
TypedConstantKind
.Type ||
194
namedArgumentValue.Kind ==
TypedConstantKind
.Primitive &&
220
if (argument.Kind ==
TypedConstantKind
.Primitive && argument.Value is int statusCode)
Microsoft.CodeAnalysis (31)
MetadataReader\MetadataDecoder.cs (11)
1528
TypedConstantKind
kind = PEModule.CrackStringInAttributeValue(out s, ref argReader) ?
1529
TypedConstantKind
.Primitive :
1530
TypedConstantKind
.Error;
1540
return CreateTypedConstant(type,
TypedConstantKind
.Type, serializedType);
1547
private static
TypedConstantKind
GetPrimitiveOrEnumTypedConstantKind(TypeSymbol type)
1549
return (type.TypeKind == TypeKind.Enum) ?
TypedConstantKind
.Enum :
TypedConstantKind
.Primitive;
2146
return new TypedConstant(type,
TypedConstantKind
.Error, null);
2153
private static TypedConstant CreateTypedConstant(TypeSymbol type,
TypedConstantKind
kind, object value)
2157
return new TypedConstant(type,
TypedConstantKind
.Error, null);
2163
private static TypedConstant CreateTypedConstant(TypeSymbol type,
TypedConstantKind
kind, bool value)
Symbols\Attributes\CommonAttributeDataComparer.cs (2)
120
if (x.Kind ==
TypedConstantKind
.Type && y.Kind ==
TypedConstantKind
.Type)
Symbols\Attributes\UnmanagedCallersOnlyAttributeData.cs (2)
37
&& value.Kind ==
TypedConstantKind
.Array
38
&& (value.Values.IsDefaultOrEmpty || value.Values.All(v => v.Kind ==
TypedConstantKind
.Type));
Symbols\TypedConstant.cs (16)
19
private readonly
TypedConstantKind
_kind;
23
internal TypedConstant(ITypeSymbolInternal? type,
TypedConstantKind
kind, object? value)
25
Debug.Assert(kind ==
TypedConstantKind
.Array || !(value is ImmutableArray<TypedConstant>));
27
Debug.Assert(type is object || kind ==
TypedConstantKind
.Error);
35
: this(type,
TypedConstantKind
.Array, value: array.IsDefault ? null : (object)array)
42
public
TypedConstantKind
Kind
97
if (Kind ==
TypedConstantKind
.Array)
115
if (Kind !=
TypedConstantKind
.Array)
137
if (_kind ==
TypedConstantKind
.Error)
158
internal static
TypedConstantKind
GetTypedConstantKind(ITypeSymbolInternal type, Compilation compilation)
178
return
TypedConstantKind
.Primitive;
183
return
TypedConstantKind
.Array;
185
return
TypedConstantKind
.Enum;
187
return
TypedConstantKind
.Error;
193
return
TypedConstantKind
.Type;
196
return
TypedConstantKind
.Error;
Microsoft.CodeAnalysis.Analyzers (4)
MetaAnalyzers\CompilerExtensionStrictApiAnalyzer.cs (2)
184
if (arg.Kind ==
TypedConstantKind
.Array)
203
if (argument is { Kind:
TypedConstantKind
.Primitive, Type.SpecialType: SpecialType.System_String })
MetaAnalyzers\DiagnosticAnalyzerAttributeAnalyzer.cs (2)
110
if (arg.Kind ==
TypedConstantKind
.Array)
149
if (argument.Kind ==
TypedConstantKind
.Primitive &&
Microsoft.CodeAnalysis.BannedApiAnalyzers (3)
RestrictedInternalsVisibleToAnalyzer.cs (3)
152
assemblyAttribute.ConstructorArguments[0].Kind !=
TypedConstantKind
.Primitive ||
160
if (assemblyAttribute.ConstructorArguments[1].Kind !=
TypedConstantKind
.Array ||
169
if (namespaceConstant.Kind ==
TypedConstantKind
.Primitive &&
Microsoft.CodeAnalysis.CodeStyle (3)
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
850
attribute.ConstructorArguments is [_, { Kind:
TypedConstantKind
.Primitive, Value: string checkId }, ..])
861
Kind:
TypedConstantKind
.Primitive,
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
777
attribute.ConstructorArguments is [{ Kind:
TypedConstantKind
.Primitive, Type.SpecialType: SpecialType.System_String, Value: string value }])
Microsoft.CodeAnalysis.CSharp (117)
Binder\Binder_Attributes.cs (22)
723
if (reorderedArgument.Kind ==
TypedConstantKind
.Error)
727
else if (reorderedArgument.Kind ==
TypedConstantKind
.Array &&
741
Debug.Assert(hasErrors || reorderedArguments.All(arg => arg.Kind !=
TypedConstantKind
.Error));
840
var
typedConstantKind = node.Type.GetAttributeParameterTypedConstantKind(_binder.Compilation);
842
return VisitExpression(node, typedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors || typedConstantKind ==
TypedConstantKind
.Error);
845
private TypedConstant VisitExpression(BoundExpression node,
TypedConstantKind
typedConstantKind, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
854
typedConstantKind =
TypedConstantKind
.Error;
871
return CreateTypedConstant(node,
TypedConstantKind
.Error, diagnostics, ref attrHasErrors, curArgumentHasErrors);
877
var
typedConstantKind = type.GetAttributeParameterTypedConstantKind(_binder.Compilation);
893
return new TypedConstant(spread.Expression.Type,
TypedConstantKind
.Error, value: null);
927
var
typedConstantKind = operandType.GetAttributeParameterTypedConstantKind(_binder.Compilation);
932
return CreateTypedConstant(node,
TypedConstantKind
.Error, diagnostics, ref attrHasErrors, curArgumentHasErrors);
968
return CreateTypedConstant(node,
TypedConstantKind
.Type, diagnostics, ref attrHasErrors, curArgumentHasErrors, simpleValue: node.SourceType.Type);
978
return CreateTypedConstant(node,
TypedConstantKind
.Error, diagnostics, ref attrHasErrors, curArgumentHasErrors);
982
var
typedConstantKind = type.GetAttributeParameterTypedConstantKind(_binder.Compilation);
1000
initializer = ImmutableArray.Create(CreateTypedConstant(node,
TypedConstantKind
.Error, diagnostics, ref attrHasErrors, curArgumentHasErrors));
1012
private static TypedConstant CreateTypedConstant(BoundExpression node,
TypedConstantKind
typedConstantKind, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors,
1018
if (typedConstantKind !=
TypedConstantKind
.Error && type.ContainsTypeParameter())
1039
typedConstantKind =
TypedConstantKind
.Error;
1042
if (typedConstantKind ==
TypedConstantKind
.Error)
1050
return new TypedConstant(type,
TypedConstantKind
.Error, null);
1052
else if (typedConstantKind ==
TypedConstantKind
.Array)
Compiler\ClsComplianceChecker.cs (1)
286
paramType.Type.GetAttributeParameterTypedConstantKind(_compilation) ==
TypedConstantKind
.Error)
Emitter\Model\AttributeDataAdapter.cs (3)
30
Debug.Assert(argument.Kind !=
TypedConstantKind
.Error);
108
case
TypedConstantKind
.Array:
111
case
TypedConstantKind
.Type:
Emitter\Model\PEAssemblyBuilder.cs (1)
349
[new TypedConstant(Compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, markerName)],
Emitter\Model\PEModuleBuilder.cs (5)
1590
var value = flagsBuilder.SelectAsArray((flag, byteType) => new TypedConstant(byteType,
TypedConstantKind
.Primitive, flag), byteType);
1612
ImmutableArray.Create(new TypedConstant(byteType,
TypedConstantKind
.Primitive, nullableValue)));
1632
ImmutableArray.Create(new TypedConstant(Compilation.GetSpecialType(SpecialType.System_Byte),
TypedConstantKind
.Primitive, value)));
1674
var transformFlags = builder.SelectAsArray((flag, constantType) => new TypedConstant(constantType,
TypedConstantKind
.Primitive, flag), booleanType);
1757
[new TypedConstant(Compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, markerName)]);
Emitter\NoPia\EmbeddedType.cs (2)
279
ImmutableArray.Create(new TypedConstant(stringType,
TypedConstantKind
.Primitive, guidString),
280
new TypedConstant(stringType,
TypedConstantKind
.Primitive,
Emitter\NoPia\EmbeddedTypesManager.cs (1)
147
ImmutableArray.Create(new TypedConstant(ctor.Parameters[0].Type,
TypedConstantKind
.Type, ctor.ContainingAssembly.GetSpecialType(SpecialType.System_Object))),
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.FieldSymbol.cs (1)
155
new TypedConstant(manager.System_Diagnostics_DebuggerBrowsableState,
TypedConstantKind
.Enum, DebuggerBrowsableState.Never))));
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.TemplateSymbol.cs (2)
220
arguments: ImmutableArray.Create(new TypedConstant(Manager.System_String,
TypedConstantKind
.Primitive, displayString)),
223
new TypedConstant(Manager.System_String,
TypedConstantKind
.Primitive, "<Anonymous Type>"))));
Symbols\Attributes\AttributeData.cs (8)
259
if (value.Kind !=
TypedConstantKind
.Array)
310
if (value.Kind !=
TypedConstantKind
.Array)
575
Debug.Assert(ctorArgument.Kind ==
TypedConstantKind
.Enum || ctorArgument.Kind ==
TypedConstantKind
.Primitive);
577
ClassInterfaceType interfaceType = ctorArgument.Kind ==
TypedConstantKind
.Enum ?
600
Debug.Assert(ctorArgument.Kind ==
TypedConstantKind
.Enum || ctorArgument.Kind ==
TypedConstantKind
.Primitive);
602
ComInterfaceType interfaceType = ctorArgument.Kind ==
TypedConstantKind
.Enum ?
Symbols\Compilation_WellKnownMembers.cs (13)
473
new TypedConstant(systemByte,
TypedConstantKind
.Primitive, scale),
474
new TypedConstant(systemByte,
TypedConstantKind
.Primitive, (byte)(isNegative ? 128 : 0)),
475
new TypedConstant(systemUnit32,
TypedConstantKind
.Primitive, high),
476
new TypedConstant(systemUnit32,
TypedConstantKind
.Primitive, mid),
477
new TypedConstant(systemUnit32,
TypedConstantKind
.Primitive, low)
483
var ticks = new TypedConstant(GetSpecialType(SpecialType.System_Int64),
TypedConstantKind
.Primitive, value.Ticks);
500
TypedConstantKind
.Enum,
777
var typedConstantDebugMode = new TypedConstant(debuggingModesType,
TypedConstantKind
.Enum, constantVal);
830
new TypedConstant(attributeTargetsType,
TypedConstantKind
.Enum, targets));
832
new KeyValuePair<WellKnownMember, TypedConstant>(WellKnownMember.System_AttributeUsageAttribute__AllowMultiple, new TypedConstant(boolType,
TypedConstantKind
.Primitive, allowMultiple)),
833
new KeyValuePair<WellKnownMember, TypedConstant>(WellKnownMember.System_AttributeUsageAttribute__Inherited, new TypedConstant(boolType,
TypedConstantKind
.Primitive, inherited)));
863
new TypedConstant(constantType,
TypedConstantKind
.Primitive, name), stringType);
910
var result = flagsBuilder.SelectAsArray((flag, constantType) => new TypedConstant(constantType,
TypedConstantKind
.Primitive, flag), booleanType);
Symbols\MethodSymbol.cs (4)
1016
Debug.Assert(callConvTypedConstant.Kind ==
TypedConstantKind
.Type);
1285
new TypedConstant(declaringCompilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, PEModule.RequiredMembersMarker), // message
1286
new TypedConstant(declaringCompilation.GetSpecialType(SpecialType.System_Boolean),
TypedConstantKind
.Primitive, true)) // error
1291
ImmutableArray.Create(new TypedConstant(declaringCompilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, nameof(CompilerFeatureRequiredFeatures.RequiredMembers)))
Symbols\Retargeting\RetargetingSymbolTranslator.cs (2)
1228
if (oldConstant.Kind ==
TypedConstantKind
.Array)
1244
if ((oldConstant.Kind ==
TypedConstantKind
.Type) && (oldConstantValue != null))
Symbols\Source\SourceAssemblySymbol.cs (6)
1829
var typedConstantRequestMinimum = new TypedConstant(securityActionType,
TypedConstantKind
.Enum, constantValue);
1835
var typedConstantTrue = new TypedConstant(boolType,
TypedConstantKind
.Primitive, value: true);
1973
var typedConstantNoStringInterning = new TypedConstant(int32Type,
TypedConstantKind
.Primitive, Cci.Constants.CompilationRelaxations_NoStringInterning);
1992
var typedConstantTrue = new TypedConstant(boolType,
TypedConstantKind
.Primitive, value: true);
2026
var typedConstant = new TypedConstant(stringType,
TypedConstantKind
.Primitive, _compilation.Options.CryptoKeyContainer);
2036
var typedConstant = new TypedConstant(stringType,
TypedConstantKind
.Primitive, _compilation.Options.CryptoKeyFile);
Symbols\Source\SourceComplexParameterSymbol.cs (2)
984
SpecialType specialType = arg.Kind ==
TypedConstantKind
.Enum ?
993
if (arg.Kind !=
TypedConstantKind
.Array && arg.ValueInternal == null)
Symbols\Source\SourceFixedFieldSymbol.cs (2)
48
var item1 = new TypedConstant(systemType,
TypedConstantKind
.Type, ((PointerTypeSymbol)this.Type).PointedAtType);
49
var item2 = new TypedConstant(intType,
TypedConstantKind
.Primitive, this.FixedSize);
Symbols\Source\SourceMemberContainerSymbol.cs (1)
1483
&& attr.CommonConstructorArguments[0].Kind ==
TypedConstantKind
.Type)
Symbols\Source\SourceMethodSymbol.cs (2)
144
TypedConstantKind
.Type, stateMachineType.GetUnboundGenericTypeOrSelf());
231
ImmutableArray.Create(new TypedConstant(compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, nameof(CompilerFeatureRequiredFeatures.UserDefinedCompoundAssignmentOperators)))
Symbols\Source\SourceMethodSymbolWithAttributes.cs (2)
1008
{ Kind: not
TypedConstantKind
.Array, Value: int lineNumberOneBased },
1009
{ Kind: not
TypedConstantKind
.Array, Value: int characterNumberOneBased }])
Symbols\Source\SourceModuleSymbol.cs (2)
653
var version = ImmutableArray.Create(new TypedConstant(compilation.GetSpecialType(SpecialType.System_Int32),
TypedConstantKind
.Primitive, 11));
660
new TypedConstant(compilation.GetSpecialType(SpecialType.System_Boolean),
TypedConstantKind
.Primitive, _assemblySymbol.InternalsAreVisible));
Symbols\Source\SourceNamedTypeSymbol.cs (7)
1035
Debug.Assert(attributeData.CommonConstructorArguments[0].Kind ==
TypedConstantKind
.Type);
1346
Debug.Assert(argument.Kind ==
TypedConstantKind
.Type);
1719
new TypedConstant(compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, PEModule.ByRefLikeMarker), // message
1720
new TypedConstant(compilation.GetSpecialType(SpecialType.System_Boolean),
TypedConstantKind
.Primitive, true)), // error=true
1725
ImmutableArray.Create(new TypedConstant(compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, nameof(CompilerFeatureRequiredFeatures.RefStructs))),
1738
var defaultMemberNameConstant = new TypedConstant(compilation.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, defaultMemberName);
1774
ImmutableArray.Create(new TypedConstant(compilation.GetWellKnownType(WellKnownType.System_Type),
TypedConstantKind
.Type, originalType)),
Symbols\Source\SourceNamedTypeSymbol_Extension.cs (5)
875
if (argument.Kind ==
TypedConstantKind
.Error)
890
case
TypedConstantKind
.Primitive:
894
case
TypedConstantKind
.Enum:
900
case
TypedConstantKind
.Type:
907
case
TypedConstantKind
.Array:
Symbols\Synthesized\SynthesizedInlineArrayTypeSymbol.cs (1)
211
arguments: ImmutableArray.Create(new TypedConstant(compilation.GetSpecialType(SpecialType.System_Int32),
TypedConstantKind
.Primitive, _arrayLength)),
Symbols\TypedConstantExtensions.cs (6)
25
if (constant.Kind ==
TypedConstantKind
.Array)
30
if (constant.Kind ==
TypedConstantKind
.Type || constant.TypeInternal!.SpecialType == SpecialType.System_Object)
36
if (constant.Kind ==
TypedConstantKind
.Enum)
51
Debug.Assert(constant.Kind ==
TypedConstantKind
.Enum);
71
Debug.Assert(constant.Kind ==
TypedConstantKind
.Enum);
150
Debug.Assert(constant.Kind ==
TypedConstantKind
.Enum);
Symbols\TypeSymbolExtensions.cs (16)
241
return GetAttributeParameterTypedConstantKind(type, compilation) !=
TypedConstantKind
.Error;
250
public static
TypedConstantKind
GetAttributeParameterTypedConstantKind(this TypeSymbol type, CSharpCompilation compilation)
262
TypedConstantKind
kind =
TypedConstantKind
.Error;
265
return
TypedConstantKind
.Error;
273
return
TypedConstantKind
.Error;
276
kind =
TypedConstantKind
.Array;
286
if (kind ==
TypedConstantKind
.Error)
289
kind =
TypedConstantKind
.Enum;
295
var
typedConstantKind = TypedConstant.GetTypedConstantKind(type, compilation);
298
case
TypedConstantKind
.Array:
299
case
TypedConstantKind
.Enum:
300
case
TypedConstantKind
.Error:
301
return
TypedConstantKind
.Error;
304
if (kind ==
TypedConstantKind
.Array || kind ==
TypedConstantKind
.Enum)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (5)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\AttributeGenerator.cs (1)
104
if (existingSyntax?.ArgumentList != null && constant.Kind is not
TypedConstantKind
.Array && constant.Value is string stringValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (4)
29
case
TypedConstantKind
.Primitive:
30
case
TypedConstantKind
.Enum:
33
case
TypedConstantKind
.Type:
38
case
TypedConstantKind
.Array:
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (229)
Attributes\AttributeTests.cs (178)
491
attrs[0].VerifyValue(0,
TypedConstantKind
.Primitive, "Roslyn.Compilers.UnitTests");
493
attrs[1].VerifyValue(0,
TypedConstantKind
.Primitive, "Roslyn.Compilers.CSharp");
495
attrs[2].VerifyValue(0,
TypedConstantKind
.Primitive, "Roslyn.Compilers.CSharp.UnitTests");
497
attrs[3].VerifyValue(0,
TypedConstantKind
.Primitive, "Roslyn.Compilers.CSharp.Test.Utilities");
499
attrs[4].VerifyValue(0,
TypedConstantKind
.Primitive, "Roslyn.Compilers.VisualBasic");
654
Assert.Equal(
TypedConstantKind
.Array, attributeData.ConstructorArguments.Single().Kind);
684
Assert.Equal(
TypedConstantKind
.Error, attrs[0].ConstructorArguments.Single().Kind);
1029
Assert.Equal(
TypedConstantKind
.Array, arguments0[2].Kind);
1036
Assert.Equal(
TypedConstantKind
.Array, arguments1[2].Kind);
1435
a.VerifyValue(0,
TypedConstantKind
.Enum, (int)System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5);
1439
a.VerifyValue(0,
TypedConstantKind
.Primitive, "");
1443
a.VerifyValue(0,
TypedConstantKind
.Primitive, true);
1447
a.VerifyValue(0,
TypedConstantKind
.Enum, (int)AssemblyNameFlags.Retargetable);
1451
a.VerifyValue(0,
TypedConstantKind
.Primitive, "MyKey.snk");
1455
a.VerifyValue(0,
TypedConstantKind
.Primitive, "Key Name");
1459
a.VerifyValue(0,
TypedConstantKind
.Primitive, "1.2.*");
1463
a.VerifyValue(0,
TypedConstantKind
.Primitive, "4.3.2.100");
1520
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
1606
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, true);
1710
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeof(object));
1711
attrs.First().VerifyNamedArgumentValue<object>(0, "O",
TypedConstantKind
.Primitive, null);
1716
attrs.First().VerifyValue(0,
TypedConstantKind
.Array, new object[] { typeof(string) });
1721
attrs.First().VerifyValue(0,
TypedConstantKind
.Array, new object[] { 1, "two", typeof(string), 3.1415926 });
1724
attrs.First().VerifyValue(0,
TypedConstantKind
.Array, new object[] { new object[] { typeof(string) } });
3106
attrs[1].VerifyNamedArgumentValue<ushort>(0, "UShortField",
TypedConstantKind
.Primitive, 1234);
3115
attrs[0].VerifyValue(0,
TypedConstantKind
.Enum, (int)FileMode.Open);
3116
attrs[0].VerifyValue(1,
TypedConstantKind
.Enum, (int)(BindingFlags.DeclaredOnly | BindingFlags.Public));
3117
attrs[0].VerifyNamedArgumentValue<uint>(0, "UIntField",
TypedConstantKind
.Primitive, 1230);
3122
attrs[0].VerifyValue(0,
TypedConstantKind
.Array, new char[] { 'q', 'c' });
3131
attrs[0].VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
3132
attrs[0].VerifyValue<long>(1,
TypedConstantKind
.Primitive, 256);
3133
attrs[0].VerifyValue<float>(2,
TypedConstantKind
.Primitive, 0);
3134
attrs[0].VerifyValue<short>(3,
TypedConstantKind
.Primitive, -1);
3135
attrs[0].VerifyNamedArgumentValue<ulong[]>(0, "AryField",
TypedConstantKind
.Array, new ulong[] { 0, 1, 12345657 });
3137
attrs[1].VerifyValue<object>(0,
TypedConstantKind
.Type, typeof(Dictionary<string, int>));
3138
attrs[1].VerifyValue<long>(1,
TypedConstantKind
.Primitive, 265);
3139
attrs[1].VerifyValue<float>(2,
TypedConstantKind
.Primitive, -0.0001f);
3140
attrs[1].VerifyValue<short>(3,
TypedConstantKind
.Primitive, 2);
3177
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Array, new object[] { 0, "", null });
3178
attrs.First().VerifyValue<byte>(1,
TypedConstantKind
.Primitive, 255);
3179
attrs.First().VerifyValue<sbyte>(2,
TypedConstantKind
.Primitive, -128);
3180
attrs.First().VerifyNamedArgumentValue<object[]>(0, "AryProp",
TypedConstantKind
.Array, new object[] { new object[] { "", typeof(IList<string>) } });
3186
attrs[0].VerifyValue<object>(0,
TypedConstantKind
.Type, typeof(string[,,]));
3219
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Array, new object[] { 1, null, "Hi" });
3220
attrs.First().VerifyNamedArgumentValue<object>(0, "ObjectField",
TypedConstantKind
.Primitive, 2);
3451
attrs.First().VerifyValue<char[]>(0,
TypedConstantKind
.Array, new char[] { ' ' });
3452
attrs.First().VerifyValue<string[]>(1,
TypedConstantKind
.Array, new string[] { "" });
3464
attrs.First().VerifyValue<char[]>(0,
TypedConstantKind
.Array, new char[] { ' ' });
3465
attrs.First().VerifyValue<string[]>(1,
TypedConstantKind
.Array, new string[] { "" });
3533
attr.VerifyValue<string>(0,
TypedConstantKind
.Primitive, "MultipleArgumentsToParamsParameter");
3534
attr.VerifyValue<int[]>(1,
TypedConstantKind
.Array, new int[] { 4, 5, 6 });
3540
attr.VerifyValue<string>(0,
TypedConstantKind
.Primitive, "NoArgumentsToParamsParameter");
3541
attr.VerifyValue<int[]>(1,
TypedConstantKind
.Array, new int[] { });
3547
attr.VerifyValue<string>(0,
TypedConstantKind
.Primitive, "NullArgumentToParamsParameter");
3548
attr.VerifyValue<int[]>(1,
TypedConstantKind
.Array, null);
3590
attrs.First().VerifyValue<char[]>(0,
TypedConstantKind
.Array, new char[] { ' ' });
3591
attrs.First().VerifyValue<string[]>(1,
TypedConstantKind
.Array, new string[] { "whatever" });
3603
attrs.First().VerifyValue<char[]>(0,
TypedConstantKind
.Array, new char[] { ' ' });
3604
attrs.First().VerifyValue<string[]>(1,
TypedConstantKind
.Array, new string[] { "whatever" });
3639
attrs.First().VerifyValue(0,
TypedConstantKind
.Type, typeof(Object));
3684
attrs.First().VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
4086
attr.VerifyValue(0,
TypedConstantKind
.Enum, (int)(AttributeTargets.Field | AttributeTargets.Event));
4089
attr.VerifyNamedArgumentValue(0, "Inherited",
TypedConstantKind
.Primitive, false);
4090
attr.VerifyNamedArgumentValue(1, "AllowMultiple",
TypedConstantKind
.Primitive, true);
4140
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 4);
4141
attrs.First().VerifyValue(1,
TypedConstantKind
.Primitive, 5);
4143
attrs.First().VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, 6);
4183
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 3);
4184
attrs.First().VerifyValue(1,
TypedConstantKind
.Primitive, 4);
4185
attrs.First().VerifyValue(2,
TypedConstantKind
.Primitive, 5);
4187
attrs.First().VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, 6);
4229
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 2);
4230
attrs.First().VerifyValue(1,
TypedConstantKind
.Primitive, 1);
4272
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 3);
4273
attrs.First().VerifyValue(1,
TypedConstantKind
.Primitive, 4);
4274
attrs.First().VerifyValue(2,
TypedConstantKind
.Primitive, 5);
4276
attrs.First().VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, 6);
4318
attr.VerifyValue<int>(0,
TypedConstantKind
.Primitive, 2);
4521
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 2);
4527
attrs.First().VerifyValue(0,
TypedConstantKind
.Primitive, 2);
4576
attrs.First().VerifyValue(0,
TypedConstantKind
.Type, cClass.AsUnboundGenericType());
4616
attrs.First().VerifyValue(0,
TypedConstantKind
.Type, bClass.AsUnboundGenericType());
4968
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Enum, (int)new DayOfWeek());
4970
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new bool());
4972
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new sbyte());
4974
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new byte());
4976
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new short());
4978
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new ushort());
4980
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new int());
4982
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new uint());
4984
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new char());
4986
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new float());
4988
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new Single());
4990
enumerator.Current.VerifyNamedArgumentValue(0, "X",
TypedConstantKind
.Primitive, new double());
5255
attr.VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
5261
attr.VerifyValue<int>(0,
TypedConstantKind
.Primitive, 1);
5316
attr.VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
5320
attr.VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
5328
attr.VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
5332
attr.VerifyValue<object>(0,
TypedConstantKind
.Primitive, null);
5495
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5500
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5506
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5513
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5522
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5529
attrs.First().VerifyValue<object>(0,
TypedConstantKind
.Type, typeArg);
5618
attributes[0].VerifyValue(0,
TypedConstantKind
.Primitive, value);
9415
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9416
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, value1);
9417
attrs1[2].VerifyValue(0,
TypedConstantKind
.Array, value1);
9420
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9421
attrs2[1].VerifyValue(0,
TypedConstantKind
.Primitive, (object)null);
9422
attrs2[2].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9426
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9427
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9428
attrs3[2].VerifyValue(0,
TypedConstantKind
.Array, value3);
9496
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9497
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, value1);
9498
attrs1[2].VerifyValue(0,
TypedConstantKind
.Array, value1);
9502
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9503
attrs2[1].VerifyValue(0,
TypedConstantKind
.Primitive, (object)null);
9504
attrs2[2].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9509
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9510
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9511
attrs3[2].VerifyValue(0,
TypedConstantKind
.Array, value3);
9514
attrs4[0].VerifyValue(0,
TypedConstantKind
.Array, new object[] { "A" });
9515
attrs4[1].VerifyValue(0,
TypedConstantKind
.Primitive, "A");
9516
attrs4[2].VerifyValue(0,
TypedConstantKind
.Primitive, "A");
9580
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9581
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, value1);
9582
attrs1[2].VerifyValue(0,
TypedConstantKind
.Array, value1);
9585
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9586
attrs2[1].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9587
attrs2[2].VerifyValue(0,
TypedConstantKind
.Array, (string[])null);
9591
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9592
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9596
attrs4[0].VerifyValue(0,
TypedConstantKind
.Array, value4);
9597
attrs4[1].VerifyValue(0,
TypedConstantKind
.Array, value4);
9598
attrs4[2].VerifyValue(0,
TypedConstantKind
.Array, value4);
9653
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9654
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, value1);
9657
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9658
attrs2[1].VerifyValue(0,
TypedConstantKind
.Primitive, (object)null);
9659
attrs2[2].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9663
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9664
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9665
attrs3[2].VerifyValue(0,
TypedConstantKind
.Array, value3);
9727
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9728
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, value1);
9732
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9733
attrs2[1].VerifyValue(0,
TypedConstantKind
.Primitive, (object)null);
9734
attrs2[2].VerifyValue(0,
TypedConstantKind
.Array, (object[])null);
9739
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9740
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9741
attrs3[2].VerifyValue(0,
TypedConstantKind
.Array, value3);
9744
attrs4[0].VerifyValue(0,
TypedConstantKind
.Array, new object[] { 1 });
9745
attrs4[1].VerifyValue(0,
TypedConstantKind
.Primitive, 1);
9746
attrs4[2].VerifyValue(0,
TypedConstantKind
.Primitive, 1);
9807
attrs1[0].VerifyValue(0,
TypedConstantKind
.Array, value1);
9808
attrs1[1].VerifyValue(0,
TypedConstantKind
.Array, new object[] { value1 });
9809
attrs1[2].VerifyValue(0,
TypedConstantKind
.Array, value1);
9813
attrs2[0].VerifyValue(0,
TypedConstantKind
.Array, value2);
9814
attrs2[1].VerifyValue(0,
TypedConstantKind
.Array, value2);
9818
attrs3[0].VerifyValue(0,
TypedConstantKind
.Array, value3);
9819
attrs3[1].VerifyValue(0,
TypedConstantKind
.Array, value3);
9823
attrs4[0].VerifyValue(0,
TypedConstantKind
.Array, value4);
9824
attrs4[1].VerifyValue(0,
TypedConstantKind
.Array, value4);
9825
attrs4[2].VerifyValue(0,
TypedConstantKind
.Array, value4);
9877
attrs[0].VerifyValue(0,
TypedConstantKind
.Array, nullArray);
9879
attrs[1].VerifyValue(0,
TypedConstantKind
.Array, emptyArray);
9881
attrs[2].VerifyValue(0,
TypedConstantKind
.Array, nullArray);
9882
attrs[2].VerifyNamedArgumentValue(0, fieldName,
TypedConstantKind
.Array, nullArray);
9884
attrs[3].VerifyValue(0,
TypedConstantKind
.Array, emptyArray);
9885
attrs[3].VerifyNamedArgumentValue(0, fieldName,
TypedConstantKind
.Array, nullArray);
9887
attrs[4].VerifyValue(0,
TypedConstantKind
.Array, nullArray);
9888
attrs[4].VerifyNamedArgumentValue(0, fieldName,
TypedConstantKind
.Array, emptyArray);
9890
attrs[5].VerifyValue(0,
TypedConstantKind
.Array, emptyArray);
9891
attrs[5].VerifyNamedArgumentValue(0, fieldName,
TypedConstantKind
.Array, emptyArray);
Attributes\AttributeTests_Dynamic.cs (2)
541
Assert.Equal(
TypedConstantKind
.Array, argument.Kind);
550
Assert.Equal(
TypedConstantKind
.Primitive, actualTransformFlag.Kind);
Attributes\AttributeTests_Security.cs (1)
63
typeAttribute.VerifyNamedArgumentValue(0, "MayLeakOnAbort",
TypedConstantKind
.Primitive, true);
Attributes\AttributeTests_Synthesized.cs (4)
70
attribute.VerifyValue(0,
TypedConstantKind
.Primitive, expectedArgValue);
82
attribute.VerifyNamedArgumentValue<bool>(0, "WrapNonExceptionThrows",
TypedConstantKind
.Primitive, true);
108
attribute.VerifyValue(0,
TypedConstantKind
.Enum, (int)expectedDebuggingMode);
1970
new TypedConstant(comp.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, "unused"))));
Attributes\AttributeTests_Tuples.cs (1)
638
Assert.Equal(
TypedConstantKind
.Array, arg.Kind);
Attributes\AttributeTests_WellKnownAttributes.cs (43)
141
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 1);
165
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "ABCDEF5D-2448-447A-B786-64682CBEF123");
168
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)ComInterfaceType.InterfaceIsIUnknown);
171
attrSym.VerifyValue(0,
TypedConstantKind
.Type, typeof(object));
174
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)TypeLibTypeFlags.FAggregatable);
177
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, false);
178
attrSym.VerifyNamedArgumentValue(0, "ThrowOnUnmappableChar",
TypedConstantKind
.Primitive, true);
267
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, false);
270
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)CallingConvention.StdCall);
273
attrSym.VerifyNamedArgumentValue(0, "BestFitMapping",
TypedConstantKind
.Primitive, true);
274
attrSym.VerifyNamedArgumentValue(1, "CharSet",
TypedConstantKind
.Enum, (int)CharSet.Ansi);
275
attrSym.VerifyNamedArgumentValue(2, "SetLastError",
TypedConstantKind
.Primitive, true);
276
attrSym.VerifyNamedArgumentValue(3, "ThrowOnUnmappableChar",
TypedConstantKind
.Primitive, true);
283
attrSym.VerifyValue(0,
TypedConstantKind
.Type, typeof(object));
286
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "ProgId");
290
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 123);
293
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 1);
307
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, true);
310
attrSym.VerifyValue(1,
TypedConstantKind
.Primitive, "EGoo, InteropAttribute, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
318
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)TypeLibVarFlags.FDisplayBind);
322
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "message");
323
attrSym.VerifyValue(1,
TypedConstantKind
.Primitive, false);
417
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 99uL);
425
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "Ref");
436
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 0f);
456
attrSym.VerifyValue(2,
TypedConstantKind
.Primitive, 100);
470
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)LayoutKind.Explicit);
472
attrSym.VerifyNamedArgumentValue(0, "Size",
TypedConstantKind
.Primitive, 16);
473
attrSym.VerifyNamedArgumentValue(1, "Pack",
TypedConstantKind
.Primitive, 8);
474
attrSym.VerifyNamedArgumentValue(2, "CharSet",
TypedConstantKind
.Enum, (int)CharSet.Unicode);
481
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)UnmanagedType.I8);
483
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 0);
2480
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "unmanaged.dll");
2482
attrSym.VerifyNamedArgumentValue(0, "CallingConvention",
TypedConstantKind
.Enum, (int)CallingConvention.FastCall);
2483
attrSym.VerifyNamedArgumentValue(1, "SetLastError",
TypedConstantKind
.Primitive, true);
2488
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "user32.dll");
2490
attrSym.VerifyNamedArgumentValue(0, "CharSet",
TypedConstantKind
.Enum, (int)CharSet.Unicode);
2491
attrSym.VerifyNamedArgumentValue(1, "ExactSpelling",
TypedConstantKind
.Primitive, false);
2492
attrSym.VerifyNamedArgumentValue(2, "EntryPoint",
TypedConstantKind
.Primitive, "MessageBox");
5156
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)AttributeTargets.Class);
5158
attrSym.VerifyNamedArgumentValue(0, "AllowMultiple",
TypedConstantKind
.Primitive, true);
5162
attrSym.VerifyValue(0,
TypedConstantKind
.Enum, (int)AttributeTargets.Class);
5164
attrSym.VerifyNamedArgumentValue(0, "AllowMultiple",
TypedConstantKind
.Primitive, false);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (111)
Symbols\Metadata\PE\LoadingAttributes.cs (94)
61
aBoolInst.VerifyValue(0,
TypedConstantKind
.Primitive, true);
64
aByteInst.VerifyValue(0,
TypedConstantKind
.Primitive, Convert.ToByte(1));
67
aCharInst.VerifyValue(0,
TypedConstantKind
.Primitive, 'a');
70
aSingleInst.VerifyValue(0,
TypedConstantKind
.Primitive, 3.14159f);
73
aDoubleInst.VerifyValue(0,
TypedConstantKind
.Primitive, 3.1415926);
76
aInt16Inst.VerifyValue(0,
TypedConstantKind
.Primitive, (Int16)16);
79
aInt32Inst.VerifyValue(0,
TypedConstantKind
.Primitive, 32);
82
aInt64Inst.VerifyValue(0,
TypedConstantKind
.Primitive, 64L);
85
aObjectInst.VerifyValue(0,
TypedConstantKind
.Primitive, "object");
88
aStringInst.VerifyValue(0,
TypedConstantKind
.Primitive, "assembly");
91
aTypeInst.VerifyValue(0,
TypedConstantKind
.Type, typeof(string));
133
aBoolInst.VerifyValue(0,
TypedConstantKind
.Primitive, true);
136
aByteInst.VerifyValue(0,
TypedConstantKind
.Primitive, Convert.ToByte(1));
139
aCharInst.VerifyValue(0,
TypedConstantKind
.Primitive, 'a');
142
aSingleInst.VerifyValue(0,
TypedConstantKind
.Primitive, 3.14159f);
145
aDoubleInst.VerifyValue(0,
TypedConstantKind
.Primitive, 3.1415926);
148
aInt16Inst.VerifyValue(0,
TypedConstantKind
.Primitive, (Int16)16);
151
aInt32Inst.VerifyValue(0,
TypedConstantKind
.Primitive, 32);
154
aInt64Inst.VerifyValue(0,
TypedConstantKind
.Primitive, 64L);
157
aObjectInst.VerifyValue(0,
TypedConstantKind
.Primitive, "object");
160
aStringInst.VerifyValue(0,
TypedConstantKind
.Primitive, "module");
163
aTypeInst.VerifyValue(0,
TypedConstantKind
.Type, typeof(string));
205
c1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "C1");
208
innerC1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "InnerC1");
215
innerC2.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "InnerC2");
218
field1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "field1");
221
property1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "Property1");
224
sub1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "Sub1");
227
sub1P1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "p1");
230
function1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "Function1");
269
a.VerifyNamedArgumentValue(0, "B",
TypedConstantKind
.Primitive, true);
272
a.VerifyNamedArgumentValue(0, "B",
TypedConstantKind
.Primitive, Convert.ToByte(1));
275
a.VerifyNamedArgumentValue(0, "C",
TypedConstantKind
.Primitive, 'b');
278
a.VerifyNamedArgumentValue(0, "E",
TypedConstantKind
.Enum, 0);
281
a.VerifyNamedArgumentValue(0, "S",
TypedConstantKind
.Primitive, 3.14159f);
284
a.VerifyNamedArgumentValue(0, "D",
TypedConstantKind
.Primitive, 3.1415926);
287
a.VerifyNamedArgumentValue(0, "I",
TypedConstantKind
.Primitive, (Int16)16);
290
a.VerifyNamedArgumentValue(0, "I",
TypedConstantKind
.Primitive, 32);
293
a.VerifyNamedArgumentValue(0, "I",
TypedConstantKind
.Primitive, 64L);
296
a.VerifyNamedArgumentValue(0, "T",
TypedConstantKind
.Type, c3);
328
a.VerifyNamedArgumentValue(0, "IA",
TypedConstantKind
.Array, new int[] { 1, 2 });
332
a.VerifyNamedArgumentValue(0, "EA",
TypedConstantKind
.Array, new int[] { 0, 1 });
336
a.VerifyNamedArgumentValue(0, "SA",
TypedConstantKind
.Array, new string[] { "Yes", "No" });
340
a.VerifyNamedArgumentValue(0, "OA",
TypedConstantKind
.Array, new string[] { "Yes", "No" });
346
a.VerifyNamedArgumentValue(0, "TA",
TypedConstantKind
.Array, new TypeSymbol[] { c1, c3 });
385
c1.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, "C1");
432
l.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Type, "System.Collections.Generic.List<>");
435
l.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Type, "System.Collections.Generic.List<C1>");
438
l.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Type, "System.Collections.Generic.List<System.String>");
441
l.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Type, "System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<C1, System.String>>");
444
l.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Type, "System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String, C1.InnerC1<System.Int32>.InnerC2<System.String, System.String>>>");
477
arg.VerifyValue(0,
TypedConstantKind
.Array, new int[] { 1, 2 });
481
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { stringType });
485
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { stringType });
489
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { stringType });
493
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { new object[] { stringType } });
499
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { 1, "two", stringType, 3.1415926 });
505
arg.VerifyValue(0,
TypedConstantKind
.Array, new object[] { 1, new object[] { 2, 3, 4 }, 5 });
511
arg.VerifyValue(0,
TypedConstantKind
.Array, new int[] { 1, 2, 3 });
606
a.VerifyValue(0,
TypedConstantKind
.Primitive, "InteropAttributes");
609
a.VerifyValue(1,
TypedConstantKind
.Primitive, 2);
612
a.VerifyValue(0,
TypedConstantKind
.Primitive, "1234C65D-1234-447A-B786-64682CBEF136");
615
a.VerifyValue(0,
TypedConstantKind
.Primitive, false);
616
a.VerifyNamedArgumentValue(0, "ThrowOnUnmappableChar",
TypedConstantKind
.Primitive, true);
619
a.VerifyValue(0,
TypedConstantKind
.Primitive, false);
630
a.VerifyValue(2,
TypedConstantKind
.Primitive, 3);
637
a.VerifyValue(0,
TypedConstantKind
.Primitive, true);
644
a.VerifyValue(0,
TypedConstantKind
.Primitive, 8);
647
a.VerifyNamedArgumentValue(0, "WrapNonExceptionThrows",
TypedConstantKind
.Primitive, true);
694
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "ABCDEF5D-2448-447A-B786-64682CBEF123");
747
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, false);
757
attrSym.VerifyNamedArgumentValue(0, "BestFitMapping",
TypedConstantKind
.Primitive, true);
758
attrSym.VerifyNamedArgumentValue(1, "CharSet",
TypedConstantKind
.Enum, (int)CharSet.Ansi);
759
attrSym.VerifyNamedArgumentValue(2, "SetLastError",
TypedConstantKind
.Primitive, true);
760
attrSym.VerifyNamedArgumentValue(3, "ThrowOnUnmappableChar",
TypedConstantKind
.Primitive, true);
797
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "message");
798
attrSym.VerifyValue(1,
TypedConstantKind
.Primitive, false);
854
attrSym.VerifyValue(0,
TypedConstantKind
.Type, cbar);
858
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "MyIndex");
863
mem.GetAttributes().First().VerifyValue(0,
TypedConstantKind
.Primitive, 10);
897
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 1);
927
attrSym.VerifyNamedArgumentValue(0, "UShortField",
TypedConstantKind
.Primitive, Convert.ToUInt16(321));
931
attrSym.VerifyNamedArgumentValue(0, "TypeField",
TypedConstantKind
.Type, typeof(Dictionary<string, int>));
968
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 3.1415926);
977
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, 'q');
978
attrSym.VerifyValue(1,
TypedConstantKind
.Primitive, Convert.ToByte(2));
990
attrSym.VerifyValue(0,
TypedConstantKind
.Primitive, "555");
1005
attrSym.VerifyValue(0,
TypedConstantKind
.Array, new sbyte[] { -1, 0, 1 });
1183
attr1.VerifyValue(0,
TypedConstantKind
.Primitive, "4.6.1055.0");
1187
attr1.VerifyValue(0,
TypedConstantKind
.Primitive, "4.6.1055.0");
1243
attr.VerifyValue(0,
TypedConstantKind
.Primitive, "genericUriParserOptions");
1244
attr.VerifyNamedArgumentValue(1, "IsRequired",
TypedConstantKind
.Primitive, true);
1276
attr.VerifyValue(0,
TypedConstantKind
.Primitive, "DataCategory_Mapping");
1279
attr.VerifyValue(0,
TypedConstantKind
.Primitive, "DataAdapter_MissingMappingAction");
Symbols\Retargeting\RetargetCustomAttributes.cs (3)
152
attribute.VerifyValue(0,
TypedConstantKind
.Type, newMsCorLib_systemType);
155
attribute.VerifyNamedArgumentValue<object>(0, "Target",
TypedConstantKind
.Type, typeof(int[]));
156
attribute.VerifyNamedArgumentValue(1, "TargetTypeName",
TypedConstantKind
.Primitive, "IntArrayType");
Symbols\TypedConstantTests.cs (14)
44
TypedConstant common = new TypedConstant(_systemType,
TypedConstantKind
.Type, _namedType);
57
new[] { new TypedConstant(_systemType,
TypedConstantKind
.Type, _namedType) }.AsImmutableOrNull());
77
new TypedConstant(_intType,
TypedConstantKind
.Primitive, 1),
78
new TypedConstant(_intType,
TypedConstantKind
.Primitive, 1));
84
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, s1),
85
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, s2));
88
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
89
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null));
92
new TypedConstant(_enumString1,
TypedConstantKind
.Primitive, null),
93
new TypedConstant(_enumString2,
TypedConstantKind
.Primitive, null));
96
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
97
new TypedConstant(_stringType,
TypedConstantKind
.Error, null));
100
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
101
new TypedConstant(_systemType,
TypedConstantKind
.Primitive, null));
Microsoft.CodeAnalysis.CSharp.Test.Utilities (6)
Extensions.cs (5)
403
public static void VerifyValue<T>(this CSharpAttributeData attr, int i,
TypedConstantKind
kind, T v)
410
public static void VerifyNamedArgumentValue<T>(this CSharpAttributeData attr, int i, string name,
TypedConstantKind
kind, T v)
426
case
TypedConstantKind
.Array:
428
case
TypedConstantKind
.Enum:
430
case
TypedConstantKind
.Type:
TestAttributesVisitor.cs (1)
189
if (value.Kind ==
TypedConstantKind
.Array)
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (4)
Metadata\WinMdDumpTest.cs (4)
292
case
TypedConstantKind
.Array:
309
case
TypedConstantKind
.Type:
315
case
TypedConstantKind
.Enum:
316
case
TypedConstantKind
.Primitive:
Microsoft.CodeAnalysis.CSharp.Workspaces (5)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\AttributeGenerator.cs (1)
104
if (existingSyntax?.ArgumentList != null && constant.Kind is not
TypedConstantKind
.Array && constant.Value is string stringValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (4)
29
case
TypedConstantKind
.Primitive:
30
case
TypedConstantKind
.Enum:
33
case
TypedConstantKind
.Type:
38
case
TypedConstantKind
.Array:
Microsoft.CodeAnalysis.Features (6)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (2)
6924
TypedConstantKind
.Array => x.Values.IsDefault || x.Values.SequenceEqual(y.Values, Instance),
6925
TypedConstantKind
.Type => TypesEquivalent((ITypeSymbol?)x.Value, (ITypeSymbol?)y.Value, exact: false),
EmbeddedLanguages\EmbeddedLanguageDetector.cs (1)
533
if (argument.Kind !=
TypedConstantKind
.Primitive || argument.Value is not string argString)
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
850
attribute.ConstructorArguments is [_, { Kind:
TypedConstantKind
.Primitive, Value: string checkId }, ..])
861
Kind:
TypedConstantKind
.Primitive,
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
777
attribute.ConstructorArguments is [{ Kind:
TypedConstantKind
.Primitive, Type.SpecialType: SpecialType.System_String, Value: string value }])
Microsoft.CodeAnalysis.PublicApiAnalyzers (1)
DeclarePublicApiAnalyzer.Impl.cs (1)
611
if (attribute.ConstructorArguments is not [{ Kind:
TypedConstantKind
.Primitive, Type.SpecialType: SpecialType.System_String, Value: string diagnosticId }])
Microsoft.CodeAnalysis.UnitTests (12)
CommonTypedConstantTests.cs (12)
42
new TypedConstant(_intType,
TypedConstantKind
.Primitive, 1),
43
new TypedConstant(_intType,
TypedConstantKind
.Primitive, 1));
49
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, s1),
50
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, s2));
53
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
54
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null));
57
new TypedConstant(_enumString1,
TypedConstantKind
.Primitive, null),
58
new TypedConstant(_enumString2,
TypedConstantKind
.Primitive, null));
61
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
62
new TypedConstant(_stringType,
TypedConstantKind
.Error, null));
65
new TypedConstant(_stringType,
TypedConstantKind
.Primitive, null),
66
new TypedConstant(_enumString1,
TypedConstantKind
.Primitive, null));
Microsoft.CodeAnalysis.VisualBasic (62)
Binding\Binder_Attributes.vb (2)
886
If kind =
TypedConstantKind
.Array Then
896
Return New TypedConstant(type,
TypedConstantKind
.Error, Nothing)
Emit\AttributeDataAdapter.vb (2)
71
Case
TypedConstantKind
.Array
73
Case
TypedConstantKind
.Type
Emit\NoPia\EmbeddedType.vb (2)
219
ImmutableArray.Create(New TypedConstant(stringType,
TypedConstantKind
.Primitive, guidString),
220
New TypedConstant(stringType,
TypedConstantKind
.Primitive, UnderlyingNamedType.AdaptedNamedTypeSymbol.ToDisplayString(SymbolDisplayFormat.QualifiedNameOnlyFormat))),
Emit\NoPia\EmbeddedTypesManager.vb (1)
108
ImmutableArray.Create(New TypedConstant(ctor.Parameters(0).Type,
TypedConstantKind
.Type, ctor.ContainingAssembly.GetSpecialType(SpecialType.System_Object))),
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousDelegate_TemplateSymbol.vb (1)
181
Dim value As New TypedConstant(Manager.System_String,
TypedConstantKind
.Primitive, "<generated method>")
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType_TemplateSymbol.vb (1)
184
ImmutableArray.Create(New TypedConstant(Manager.System_String,
TypedConstantKind
.Primitive, builder.ToStringAndFree())))
Symbols\Attributes\AttributeData.vb (9)
438
Debug.Assert(ctorArgument.Kind =
TypedConstantKind
.Enum OrElse ctorArgument.Kind =
TypedConstantKind
.Primitive)
440
Dim interfaceType As ClassInterfaceType = If(ctorArgument.Kind =
TypedConstantKind
.Enum,
465
Debug.Assert(ctorArgument.Kind =
TypedConstantKind
.Enum OrElse ctorArgument.Kind =
TypedConstantKind
.Primitive)
467
interfaceType = If(ctorArgument.Kind =
TypedConstantKind
.Enum,
483
Debug.Assert(ctorArgument.Kind =
TypedConstantKind
.Enum OrElse ctorArgument.Kind =
TypedConstantKind
.Primitive)
485
Return If(ctorArgument.Kind =
TypedConstantKind
.Enum,
Symbols\Retargeting\RetargetingSymbolTranslator.vb (2)
726
If oldConstant.Kind =
TypedConstantKind
.Array Then
738
If (oldConstant.Kind =
TypedConstantKind
.Type) AndAlso (oldConstantValue IsNot Nothing) Then
Symbols\Source\SourceAssemblySymbol.vb (5)
1545
Dim typedConstantNoStringInterning = New TypedConstant(int32Type,
TypedConstantKind
.Primitive, Cci.Constants.CompilationRelaxations_NoStringInterning)
1563
Dim typedConstantTrue = New TypedConstant(boolType,
TypedConstantKind
.Primitive, True)
1601
Dim typedConstantDebugMode = New TypedConstant(int32Type,
TypedConstantKind
.Enum, CInt(debuggingMode))
1618
Dim typedConstant = New TypedConstant(stringType,
TypedConstantKind
.Primitive, _compilation.Options.CryptoKeyContainer)
1627
Dim typedConstant = New TypedConstant(stringType,
TypedConstantKind
.Primitive, _compilation.Options.CryptoKeyFile)
Symbols\Source\SourceFieldSymbol.vb (1)
695
New TypedConstant(specialTypeInt64,
TypedConstantKind
.Primitive, attributeValue.Ticks))))
Symbols\Source\SourceMemberMethodSymbol.vb (1)
1014
If arg.Kind <>
TypedConstantKind
.Array AndAlso CInt(arg.ValueInternal) = DESIGNERSERIALIZATIONVISIBILITYTYPE_CONTENT Then
Symbols\Source\SourceNamedTypeSymbol.vb (7)
2252
If attrData.CommonConstructorArguments.Length = 1 AndAlso attrData.CommonConstructorArguments(0).Kind =
TypedConstantKind
.Primitive Then
2269
Debug.Assert(argument.Kind =
TypedConstantKind
.Type)
2542
New TypedConstant(stringType,
TypedConstantKind
.Primitive, DefaultPropertyName))))
2557
New TypedConstant(GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, _comClassData.ClassId))))
2563
New TypedConstant(GetSpecialType(SpecialType.System_Int32),
TypedConstantKind
.Enum, CInt(ClassInterfaceType.None)))))
2584
New TypedConstant(GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, eventInterfaceName))))
2611
ImmutableArray.Create(New TypedConstant(compilation.GetWellKnownType(WellKnownType.System_Type),
TypedConstantKind
.Type, originalType)),
Symbols\Source\SourceNamedTypeSymbol_ComClass.vb (11)
43
Dim strVal As String = If(args(0).Kind <>
TypedConstantKind
.Array, TryCast(args(0).ValueInternal, String), Nothing)
50
strVal = If(args(1).Kind <>
TypedConstantKind
.Array, TryCast(args(1).ValueInternal, String), Nothing)
56
strVal = If(args(2).Kind <>
TypedConstantKind
.Array, TryCast(args(2).ValueInternal, String), Nothing)
313
Dim value As Object = If(typedValue.Kind <>
TypedConstantKind
.Array, typedValue.ValueInternal, Nothing)
487
Dim value As Object = If(typedValue.Kind <>
TypedConstantKind
.Array, typedValue.ValueInternal, Nothing)
1002
New TypedConstant(_comClass.GetSpecialType(SpecialType.System_String),
TypedConstantKind
.Primitive, id))))
1010
TypedConstantKind
.Primitive,
1017
TypedConstantKind
.Primitive,
1024
TypedConstantKind
.Primitive,
1372
TypedConstantKind
.Primitive,
1878
TypedConstantKind
.Primitive,
Symbols\Source\SourceParameterSymbol.vb (2)
421
Dim specialType = If(arg.Kind =
TypedConstantKind
.Enum,
427
If arg.Kind <>
TypedConstantKind
.Array AndAlso
Symbols\Source\SourceParameterSymbolBase.vb (1)
64
TypedConstantKind
.Primitive,
Symbols\Source\SourceWithEventsBackingFieldSymbol.vb (1)
76
TypedConstantKind
.Primitive,
Symbols\TypedConstant.vb (4)
33
If constant.Kind =
TypedConstantKind
.Array Then
37
If constant.Kind =
TypedConstantKind
.Type OrElse constant.TypeInternal.SpecialType = SpecialType.System_Object Then
41
If constant.Kind =
TypedConstantKind
.Enum Then
51
Debug.Assert(constant.Kind =
TypedConstantKind
.Enum)
Symbols\WellKnownMembers.vb (9)
221
TypedConstantKind
.Type,
245
New TypedConstant(specialTypeByte,
TypedConstantKind
.Primitive, scale),
246
New TypedConstant(specialTypeByte,
TypedConstantKind
.Primitive, CByte(If(isNegative, 128, 0))),
247
New TypedConstant(specialTypeUInt32,
TypedConstantKind
.Primitive, high),
248
New TypedConstant(specialTypeUInt32,
TypedConstantKind
.Primitive, mid),
249
New TypedConstant(specialTypeUInt32,
TypedConstantKind
.Primitive, low)
261
TypedConstantKind
.Enum,
277
TypedConstantKind
.Enum,
737
Return New TypedConstant(constantType,
TypedConstantKind
.Primitive, name)
Microsoft.Extensions.Logging.Generators (3)
LoggerMessageGenerator.Parser.cs (3)
140
if (typedConstant.Kind ==
TypedConstantKind
.Error)
196
if (typedConstant.Kind ==
TypedConstantKind
.Error)
854
private static object GetItem(TypedConstant arg) => arg.Kind ==
TypedConstantKind
.Array ? arg.Values : arg.Value;
Microsoft.Extensions.Options.SourceGeneration (2)
Parser.cs (2)
509
if (argument.Kind ==
TypedConstantKind
.Array)
522
if (namedArgument.Value.Kind ==
TypedConstantKind
.Array)
Microsoft.Gen.MetadataExtractor (5)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (5)
261
&& attributeData.ConstructorArguments[0].Kind ==
TypedConstantKind
.Primitive)
287
if (arg.Value.Kind ==
TypedConstantKind
.Primitive &&
300
if (arg.Kind !=
TypedConstantKind
.Array)
307
if (item.Kind !=
TypedConstantKind
.Primitive)
423
&& methodAttribute.ConstructorArguments[0].Kind ==
TypedConstantKind
.Type)
Microsoft.Gen.Metrics (5)
Parser.cs (5)
261
&& attributeData.ConstructorArguments[0].Kind ==
TypedConstantKind
.Primitive)
287
if (arg.Value.Kind ==
TypedConstantKind
.Primitive &&
300
if (arg.Kind !=
TypedConstantKind
.Array)
307
if (item.Kind !=
TypedConstantKind
.Primitive)
423
&& methodAttribute.ConstructorArguments[0].Kind ==
TypedConstantKind
.Type)
Microsoft.Gen.MetricsReports (5)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (5)
261
&& attributeData.ConstructorArguments[0].Kind ==
TypedConstantKind
.Primitive)
287
if (arg.Value.Kind ==
TypedConstantKind
.Primitive &&
300
if (arg.Kind !=
TypedConstantKind
.Array)
307
if (item.Kind !=
TypedConstantKind
.Primitive)
423
&& methodAttribute.ConstructorArguments[0].Kind ==
TypedConstantKind
.Type)
Roslyn.Diagnostics.CSharp.Analyzers (5)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\AttributeGenerator.cs (1)
104
if (existingSyntax?.ArgumentList != null && constant.Kind is not
TypedConstantKind
.Array && constant.Value is string stringValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (4)
29
case
TypedConstantKind
.Primitive:
30
case
TypedConstantKind
.Enum:
33
case
TypedConstantKind
.Type:
38
case
TypedConstantKind
.Array:
System.Text.RegularExpressions.Generator (1)
RegexGenerator.Parser.cs (1)
69
if (generatedRegexAttr.ConstructorArguments.Any(ca => ca.Kind ==
TypedConstantKind
.Error))