837 lines
42 KiB
C#
837 lines
42 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using Microsoft.Cci;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.CodeGen;
|
|
using Microsoft.CodeAnalysis.Emit;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal abstract class CSharpAttributeData : AttributeData, ICustomAttribute
|
|
{
|
|
private ThreeState _lazyIsSecurityAttribute;
|
|
|
|
int ICustomAttribute.ArgumentCount => ((AttributeData)this).CommonConstructorArguments.Length;
|
|
|
|
ushort ICustomAttribute.NamedArgumentCount => (ushort)((AttributeData)this).CommonNamedArguments.Length;
|
|
|
|
bool ICustomAttribute.AllowMultiple
|
|
{
|
|
get
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
AttributeUsageInfo attributeUsageInfo = AttributeClass.GetAttributeUsageInfo();
|
|
return ((AttributeUsageInfo)(ref attributeUsageInfo)).AllowMultiple;
|
|
}
|
|
}
|
|
|
|
public abstract NamedTypeSymbol? AttributeClass { get; }
|
|
|
|
public abstract MethodSymbol? AttributeConstructor { get; }
|
|
|
|
public abstract SyntaxReference? ApplicationSyntaxReference { get; }
|
|
|
|
[MemberNotNullWhen(true, new string[] { "AttributeClass", "AttributeConstructor" })]
|
|
internal override bool HasErrors
|
|
{
|
|
[MemberNotNullWhen(true, new string[] { "AttributeClass", "AttributeConstructor" })]
|
|
get
|
|
{
|
|
return ((AttributeData)this).HasErrors;
|
|
}
|
|
}
|
|
|
|
public IEnumerable<TypedConstant> ConstructorArguments => ((AttributeData)this).CommonConstructorArguments;
|
|
|
|
public IEnumerable<KeyValuePair<string, TypedConstant>> NamedArguments => ((AttributeData)this).CommonNamedArguments;
|
|
|
|
protected override INamedTypeSymbol? CommonAttributeClass => AttributeClass.GetPublicSymbol();
|
|
|
|
protected override IMethodSymbol? CommonAttributeConstructor => AttributeConstructor.GetPublicSymbol();
|
|
|
|
protected override SyntaxReference? CommonApplicationSyntaxReference => ApplicationSyntaxReference;
|
|
|
|
ImmutableArray<IMetadataExpression> ICustomAttribute.GetArguments(EmitContext context)
|
|
{
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<TypedConstant> commonConstructorArguments = ((AttributeData)this).CommonConstructorArguments;
|
|
if (commonConstructorArguments.IsEmpty)
|
|
{
|
|
return ImmutableArray<IMetadataExpression>.Empty;
|
|
}
|
|
ArrayBuilder<IMetadataExpression> instance = ArrayBuilder<IMetadataExpression>.GetInstance();
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = commonConstructorArguments.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
instance.Add(CreateMetadataExpression(current, context));
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
IMethodReference ICustomAttribute.Constructor(EmitContext context, bool reportDiagnostics)
|
|
{
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
if (AttributeConstructor.IsDefaultValueTypeConstructor())
|
|
{
|
|
if (reportDiagnostics)
|
|
{
|
|
context.Diagnostics.Add(ErrorCode.ERR_NotAnAttributeClass, ((EmitContext)(ref context)).Location ?? NoLocation.Singleton, AttributeClass);
|
|
}
|
|
return null;
|
|
}
|
|
return ((PEModuleBuilder)(object)context.Module).Translate(AttributeConstructor, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics);
|
|
}
|
|
|
|
ImmutableArray<IMetadataNamedArgument> ICustomAttribute.GetNamedArguments(EmitContext context)
|
|
{
|
|
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<KeyValuePair<string, TypedConstant>> commonNamedArguments = ((AttributeData)this).CommonNamedArguments;
|
|
if (commonNamedArguments.IsEmpty)
|
|
{
|
|
return ImmutableArray<IMetadataNamedArgument>.Empty;
|
|
}
|
|
ArrayBuilder<IMetadataNamedArgument> instance = ArrayBuilder<IMetadataNamedArgument>.GetInstance();
|
|
ImmutableArray<KeyValuePair<string, TypedConstant>>.Enumerator enumerator = commonNamedArguments.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
KeyValuePair<string, TypedConstant> current = enumerator.Current;
|
|
instance.Add(CreateMetadataNamedArgument(current.Key, current.Value, context));
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
ITypeReference ICustomAttribute.GetType(EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
|
return (ITypeReference)(object)((PEModuleBuilder)(object)context.Module).Translate(AttributeClass, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics);
|
|
}
|
|
|
|
private IMetadataExpression CreateMetadataExpression(TypedConstant argument, EmitContext context)
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Invalid comparison between Unknown and I4
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0026: Invalid comparison between Unknown and I4
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
if (((TypedConstant)(ref argument)).IsNull)
|
|
{
|
|
return (IMetadataExpression)(object)CreateMetadataConstant(((TypedConstant)(ref argument)).TypeInternal, null, context);
|
|
}
|
|
TypedConstantKind kind = ((TypedConstant)(ref argument)).Kind;
|
|
if ((int)kind != 3)
|
|
{
|
|
if ((int)kind == 4)
|
|
{
|
|
return (IMetadataExpression)(object)CreateMetadataArray(argument, context);
|
|
}
|
|
return (IMetadataExpression)(object)CreateMetadataConstant(((TypedConstant)(ref argument)).TypeInternal, ((TypedConstant)(ref argument)).ValueInternal, context);
|
|
}
|
|
return (IMetadataExpression)(object)CreateType(argument, context);
|
|
}
|
|
|
|
private MetadataCreateArray CreateMetadataArray(TypedConstant argument, EmitContext context)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Expected O, but got Unknown
|
|
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0086: Expected O, but got Unknown
|
|
ImmutableArray<TypedConstant> values = ((TypedConstant)(ref argument)).Values;
|
|
IArrayTypeReference val = ((PEModuleBuilder)(object)context.Module).Translate((ArrayTypeSymbol)(object)((TypedConstant)(ref argument)).TypeInternal);
|
|
if (values.Length != 0)
|
|
{
|
|
IMetadataExpression[] array = (IMetadataExpression[])(object)new IMetadataExpression[values.Length];
|
|
for (int i = 0; i < values.Length; i++)
|
|
{
|
|
array[i] = CreateMetadataExpression(values[i], context);
|
|
}
|
|
return new MetadataCreateArray(val, val.GetElementType(context), ImmutableArrayExtensions.AsImmutableOrNull<IMetadataExpression>(array));
|
|
}
|
|
return new MetadataCreateArray(val, val.GetElementType(context), ImmutableArray<IMetadataExpression>.Empty);
|
|
}
|
|
|
|
private static MetadataTypeOf CreateType(TypedConstant argument, EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Expected O, but got Unknown
|
|
PEModuleBuilder pEModuleBuilder = (PEModuleBuilder)(object)context.Module;
|
|
CSharpSyntaxNode cSharpSyntaxNode = (CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode;
|
|
DiagnosticBag diagnostics = context.Diagnostics;
|
|
return new MetadataTypeOf(((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).Translate((TypeSymbol)((TypedConstant)(ref argument)).ValueInternal, (SyntaxNode)(object)cSharpSyntaxNode, diagnostics), ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).Translate((TypeSymbol)(object)((TypedConstant)(ref argument)).TypeInternal, (SyntaxNode)(object)cSharpSyntaxNode, diagnostics));
|
|
}
|
|
|
|
private static MetadataConstant CreateMetadataConstant(ITypeSymbolInternal type, object value, EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)(PEModuleBuilder)(object)context.Module).CreateConstant((TypeSymbol)(object)type, value, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics);
|
|
}
|
|
|
|
private IMetadataNamedArgument CreateMetadataNamedArgument(string name, TypedConstant argument, EmitContext context)
|
|
{
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005f: Expected O, but got Unknown
|
|
Symbol symbol = LookupName(name);
|
|
IMetadataExpression val = CreateMetadataExpression(argument, context);
|
|
TypeSymbol typeSymbol = ((!(symbol is FieldSymbol fieldSymbol)) ? ((PropertySymbol)symbol).Type : fieldSymbol.Type);
|
|
PEModuleBuilder pEModuleBuilder = (PEModuleBuilder)(object)context.Module;
|
|
return (IMetadataNamedArgument)new MetadataNamedArgument((ISymbolInternal)(object)symbol, ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).Translate(typeSymbol, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics), val);
|
|
}
|
|
|
|
private Symbol LookupName(string name)
|
|
{
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Invalid comparison between Unknown and I4
|
|
NamedTypeSymbol namedTypeSymbol = AttributeClass;
|
|
while ((object)namedTypeSymbol != null)
|
|
{
|
|
ImmutableArray<Symbol>.Enumerator enumerator = namedTypeSymbol.GetMembers(name).GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
Symbol current = enumerator.Current;
|
|
if ((int)current.DeclaredAccessibility == 6)
|
|
{
|
|
return current;
|
|
}
|
|
}
|
|
namedTypeSymbol = namedTypeSymbol.BaseTypeNoUseSiteDiagnostics;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
internal virtual bool IsTargetAttribute(string namespaceName, string typeName)
|
|
{
|
|
if (!AttributeClass.Name.Equals(typeName))
|
|
{
|
|
return false;
|
|
}
|
|
if (AttributeClass.IsErrorType() && !(AttributeClass is MissingMetadataTypeSymbol))
|
|
{
|
|
return false;
|
|
}
|
|
return AttributeClass.HasNameQualifier(namespaceName);
|
|
}
|
|
|
|
internal bool IsTargetAttribute(Symbol targetSymbol, AttributeDescription description)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return GetTargetAttributeSignatureIndex(targetSymbol, description) != -1;
|
|
}
|
|
|
|
internal abstract int GetTargetAttributeSignatureIndex(Symbol targetSymbol, AttributeDescription description);
|
|
|
|
internal static bool IsTargetEarlyAttribute(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax, AttributeDescription description)
|
|
{
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
int num = ((attributeSyntax.ArgumentList != null) ? ((IEnumerable<AttributeArgumentSyntax>)(object)attributeSyntax.ArgumentList.Arguments).Count((AttributeArgumentSyntax arg) => arg.NameEquals == null) : 0);
|
|
return AttributeData.IsTargetEarlyAttribute((INamedTypeSymbolInternal)(object)attributeType, num, description);
|
|
}
|
|
|
|
internal bool IsSecurityAttribute(CSharpCompilation compilation)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((int)_lazyIsSecurityAttribute == 0)
|
|
{
|
|
NamedTypeSymbol wellKnownType = compilation.GetWellKnownType((WellKnownType)238);
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
|
|
_lazyIsSecurityAttribute = ThreeStateHelpers.ToThreeState(AttributeClass.IsDerivedFrom(wellKnownType, (TypeCompareKind)0, ref useSiteInfo));
|
|
}
|
|
return ThreeStateHelpers.Value(_lazyIsSecurityAttribute);
|
|
}
|
|
|
|
public override string? ToString()
|
|
{
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((object)AttributeClass != null)
|
|
{
|
|
string text = ((Symbol)AttributeClass).ToDisplayString(SymbolDisplayFormat.TestFormat);
|
|
if (!((AttributeData)this).CommonConstructorArguments.Any() & !((AttributeData)this).CommonNamedArguments.Any())
|
|
{
|
|
return text;
|
|
}
|
|
PooledStringBuilder instance = PooledStringBuilder.GetInstance();
|
|
StringBuilder builder = instance.Builder;
|
|
builder.Append(text);
|
|
builder.Append("(");
|
|
bool flag = true;
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = ((AttributeData)this).CommonConstructorArguments.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
if (!flag)
|
|
{
|
|
builder.Append(", ");
|
|
}
|
|
builder.Append(current.ToCSharpString());
|
|
flag = false;
|
|
}
|
|
ImmutableArray<KeyValuePair<string, TypedConstant>>.Enumerator enumerator2 = ((AttributeData)this).CommonNamedArguments.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
KeyValuePair<string, TypedConstant> current2 = enumerator2.Current;
|
|
if (!flag)
|
|
{
|
|
builder.Append(", ");
|
|
}
|
|
builder.Append(current2.Key);
|
|
builder.Append(" = ");
|
|
builder.Append(current2.Value.ToCSharpString());
|
|
flag = false;
|
|
}
|
|
builder.Append(")");
|
|
return instance.ToStringAndFree();
|
|
}
|
|
return ((object)this).ToString();
|
|
}
|
|
|
|
internal void DecodeSecurityAttribute<T>(Symbol targetSymbol, CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) where T : WellKnownAttributeData, ISecurityAttributeTarget, new()
|
|
{
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
bool hasErrors;
|
|
DeclarativeSecurityAction declarativeSecurityAction = DecodeSecurityAttributeAction(targetSymbol, compilation, arguments.AttributeSyntaxOpt, out hasErrors, (BindingDiagnosticBag)(object)arguments.Diagnostics);
|
|
if (hasErrors)
|
|
{
|
|
return;
|
|
}
|
|
SecurityWellKnownAttributeData orCreateData = ((ISecurityAttributeTarget)arguments.GetOrCreateData<T>()).GetOrCreateData();
|
|
orCreateData.SetSecurityAttribute(arguments.Index, declarativeSecurityAction, arguments.AttributesCount);
|
|
if (IsTargetAttribute(targetSymbol, AttributeDescription.PermissionSetAttribute))
|
|
{
|
|
string text = DecodePermissionSetAttribute(compilation, arguments.AttributeSyntaxOpt, (BindingDiagnosticBag)(object)arguments.Diagnostics);
|
|
if (text != null)
|
|
{
|
|
orCreateData.SetPathForPermissionSetAttributeFixup(arguments.Index, text, arguments.AttributesCount);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal static void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) where T : WellKnownAttributeData, ISkipLocalsInitAttributeTarget, new()
|
|
{
|
|
((ISkipLocalsInitAttributeTarget)arguments.GetOrCreateData<T>()).HasSkipLocalsInitAttribute = true;
|
|
if (!compilation.Options.AllowUnsafe)
|
|
{
|
|
((BindingDiagnosticBag)(object)arguments.Diagnostics).Add(ErrorCode.ERR_IllegalUnsafe, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
}
|
|
}
|
|
|
|
internal static void DecodeMemberNotNullAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) where T : WellKnownAttributeData, IMemberNotNullAttributeTarget, new()
|
|
{
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0027: Invalid comparison between Unknown and I4
|
|
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val = ((AttributeData)arguments.Attribute).CommonConstructorArguments[0];
|
|
if (((TypedConstant)(ref val)).IsNull)
|
|
{
|
|
return;
|
|
}
|
|
if ((int)((TypedConstant)(ref val)).Kind != 4)
|
|
{
|
|
string text = ((TypedConstant)(ref val)).DecodeValue<string>((SpecialType)20);
|
|
if (text != null)
|
|
{
|
|
((IMemberNotNullAttributeTarget)arguments.GetOrCreateData<T>()).AddNotNullMember(text);
|
|
ReportBadNotNullMemberIfNeeded(type, arguments, text);
|
|
}
|
|
return;
|
|
}
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = ((TypedConstant)(ref val)).Values.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
string text2 = ((TypedConstant)(ref current)).DecodeValue<string>((SpecialType)20);
|
|
if (text2 != null)
|
|
{
|
|
instance.Add(text2);
|
|
ReportBadNotNullMemberIfNeeded(type, arguments, text2);
|
|
}
|
|
}
|
|
((IMemberNotNullAttributeTarget)arguments.GetOrCreateData<T>()).AddNotNullMember(instance);
|
|
instance.Free();
|
|
}
|
|
|
|
private static void ReportBadNotNullMemberIfNeeded(TypeSymbol type, DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, string memberName)
|
|
{
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Invalid comparison between Unknown and I4
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002b: Invalid comparison between Unknown and I4
|
|
ImmutableArray<Symbol>.Enumerator enumerator = type.GetMembers(memberName).GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
Symbol current = enumerator.Current;
|
|
if ((int)current.Kind == 6 || (int)current.Kind == 15)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
((BindingDiagnosticBag)(object)arguments.Diagnostics).Add(ErrorCode.WRN_MemberNotNullBadMember, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location, memberName);
|
|
}
|
|
|
|
internal static void DecodeMemberNotNullWhenAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) where T : WellKnownAttributeData, IMemberNotNullAttributeTarget, new()
|
|
{
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Invalid comparison between Unknown and I4
|
|
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val = ((AttributeData)arguments.Attribute).CommonConstructorArguments[1];
|
|
if (((TypedConstant)(ref val)).IsNull)
|
|
{
|
|
return;
|
|
}
|
|
TypedConstant val2 = ((AttributeData)arguments.Attribute).CommonConstructorArguments[0];
|
|
bool flag = ((TypedConstant)(ref val2)).DecodeValue<bool>((SpecialType)7);
|
|
if ((int)((TypedConstant)(ref val)).Kind != 4)
|
|
{
|
|
string text = ((TypedConstant)(ref val)).DecodeValue<string>((SpecialType)20);
|
|
if (text != null)
|
|
{
|
|
((IMemberNotNullAttributeTarget)arguments.GetOrCreateData<T>()).AddNotNullWhenMember(flag, text);
|
|
ReportBadNotNullMemberIfNeeded(type, arguments, text);
|
|
}
|
|
return;
|
|
}
|
|
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = ((TypedConstant)(ref val)).Values.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
string text2 = ((TypedConstant)(ref current)).DecodeValue<string>((SpecialType)20);
|
|
if (text2 != null)
|
|
{
|
|
instance.Add(text2);
|
|
ReportBadNotNullMemberIfNeeded(type, arguments, text2);
|
|
}
|
|
}
|
|
((IMemberNotNullAttributeTarget)arguments.GetOrCreateData<T>()).AddNotNullWhenMember(flag, instance);
|
|
instance.Free();
|
|
}
|
|
|
|
private DeclarativeSecurityAction DecodeSecurityAttributeAction(Symbol targetSymbol, CSharpCompilation compilation, AttributeSyntax? nodeOpt, out bool hasErrors, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<TypedConstant> commonConstructorArguments = ((AttributeData)this).CommonConstructorArguments;
|
|
if (!commonConstructorArguments.Any())
|
|
{
|
|
if (IsTargetAttribute(targetSymbol, AttributeDescription.HostProtectionAttribute))
|
|
{
|
|
hasErrors = false;
|
|
return DeclarativeSecurityAction.LinkDemand;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TypedConstant typedValue = commonConstructorArguments.First();
|
|
TypeSymbol typeSymbol = (TypeSymbol)(object)((TypedConstant)(ref typedValue)).TypeInternal;
|
|
if ((object)typeSymbol != null && typeSymbol.Equals(compilation.GetWellKnownType((WellKnownType)237)))
|
|
{
|
|
return DecodeSecurityAction(typedValue, targetSymbol, nodeOpt, diagnostics, out hasErrors);
|
|
}
|
|
}
|
|
diagnostics.Add(ErrorCode.ERR_SecurityAttributeMissingAction, (nodeOpt != null) ? ((SyntaxNode)nodeOpt.Name).Location : NoLocation.Singleton);
|
|
hasErrors = true;
|
|
return DeclarativeSecurityAction.None;
|
|
}
|
|
|
|
private DeclarativeSecurityAction DecodeSecurityAction(TypedConstant typedValue, Symbol targetSymbol, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics, out bool hasErrors)
|
|
{
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0108: Invalid comparison between Unknown and I4
|
|
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ca: Invalid comparison between Unknown and I4
|
|
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d4: Invalid comparison between Unknown and I4
|
|
int num = (int)((TypedConstant)(ref typedValue)).ValueInternal;
|
|
bool flag;
|
|
switch (num)
|
|
{
|
|
case 6:
|
|
case 7:
|
|
if (IsTargetAttribute(targetSymbol, AttributeDescription.PrincipalPermissionAttribute))
|
|
{
|
|
object displayString2;
|
|
Location securityAttributeActionSyntaxLocation2 = GetSecurityAttributeActionSyntaxLocation(nodeOpt, typedValue, out displayString2);
|
|
diagnostics.Add(ErrorCode.ERR_PrincipalPermissionInvalidAction, securityAttributeActionSyntaxLocation2, displayString2);
|
|
hasErrors = true;
|
|
return DeclarativeSecurityAction.None;
|
|
}
|
|
flag = false;
|
|
break;
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
flag = false;
|
|
break;
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
flag = true;
|
|
break;
|
|
default:
|
|
{
|
|
object displayString;
|
|
Location securityAttributeActionSyntaxLocation = GetSecurityAttributeActionSyntaxLocation(nodeOpt, typedValue, out displayString);
|
|
diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidAction, securityAttributeActionSyntaxLocation, (nodeOpt != null) ? nodeOpt.GetErrorDisplayName() : "", displayString);
|
|
hasErrors = true;
|
|
return DeclarativeSecurityAction.None;
|
|
}
|
|
}
|
|
if (flag)
|
|
{
|
|
if ((int)targetSymbol.Kind == 11 || (int)targetSymbol.Kind == 9)
|
|
{
|
|
object displayString3;
|
|
Location securityAttributeActionSyntaxLocation3 = GetSecurityAttributeActionSyntaxLocation(nodeOpt, typedValue, out displayString3);
|
|
diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidActionTypeOrMethod, securityAttributeActionSyntaxLocation3, displayString3);
|
|
hasErrors = true;
|
|
return DeclarativeSecurityAction.None;
|
|
}
|
|
}
|
|
else if ((int)targetSymbol.Kind == 2)
|
|
{
|
|
object displayString4;
|
|
Location securityAttributeActionSyntaxLocation4 = GetSecurityAttributeActionSyntaxLocation(nodeOpt, typedValue, out displayString4);
|
|
diagnostics.Add(ErrorCode.ERR_SecurityAttributeInvalidActionAssembly, securityAttributeActionSyntaxLocation4, displayString4);
|
|
hasErrors = true;
|
|
return DeclarativeSecurityAction.None;
|
|
}
|
|
hasErrors = false;
|
|
return (DeclarativeSecurityAction)num;
|
|
}
|
|
|
|
private static Location GetSecurityAttributeActionSyntaxLocation(AttributeSyntax? nodeOpt, TypedConstant typedValue, out object displayString)
|
|
{
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
if (nodeOpt == null)
|
|
{
|
|
displayString = "";
|
|
return NoLocation.Singleton;
|
|
}
|
|
AttributeArgumentListSyntax argumentList = nodeOpt.ArgumentList;
|
|
if (argumentList == null || EnumerableExtensions.IsEmpty<AttributeArgumentSyntax>((IReadOnlyCollection<AttributeArgumentSyntax>)(object)argumentList.Arguments))
|
|
{
|
|
displayString = (FormattableString)$"{((TypedConstant)(ref typedValue)).ValueInternal}";
|
|
return ((SyntaxNode)nodeOpt).Location;
|
|
}
|
|
AttributeArgumentSyntax attributeArgumentSyntax = argumentList.Arguments[0];
|
|
displayString = ((object)attributeArgumentSyntax).ToString();
|
|
return ((SyntaxNode)attributeArgumentSyntax).Location;
|
|
}
|
|
|
|
private string? DecodePermissionSetAttribute(CSharpCompilation compilation, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
string text = null;
|
|
ImmutableArray<KeyValuePair<string, TypedConstant>> commonNamedArguments = ((AttributeData)this).CommonNamedArguments;
|
|
if (commonNamedArguments.Length == 1)
|
|
{
|
|
KeyValuePair<string, TypedConstant> keyValuePair = commonNamedArguments[0];
|
|
NamedTypeSymbol attributeClass = AttributeClass;
|
|
string text2 = "File";
|
|
string propName = "Hex";
|
|
if (keyValuePair.Key == text2 && PermissionSetAttributeTypeHasRequiredProperty(attributeClass, text2))
|
|
{
|
|
TypedConstant value = keyValuePair.Value;
|
|
string text3 = (string)((TypedConstant)(ref value)).ValueInternal;
|
|
XmlReferenceResolver xmlReferenceResolver = ((CompilationOptions)compilation.Options).XmlReferenceResolver;
|
|
text = ((xmlReferenceResolver != null && text3 != null) ? xmlReferenceResolver.ResolveReference(text3, (string)null) : null);
|
|
if (text == null)
|
|
{
|
|
object obj;
|
|
if (nodeOpt == null)
|
|
{
|
|
obj = null;
|
|
}
|
|
else
|
|
{
|
|
AttributeArgumentSyntax? namedArgumentSyntax = nodeOpt.GetNamedArgumentSyntax(text2);
|
|
obj = ((namedArgumentSyntax != null) ? ((SyntaxNode)namedArgumentSyntax).Location : null);
|
|
}
|
|
if (obj == null)
|
|
{
|
|
obj = NoLocation.Singleton;
|
|
}
|
|
Location location = (Location)obj;
|
|
diagnostics.Add(ErrorCode.ERR_PermissionSetAttributeInvalidFile, location, text3 ?? "<null>", text2);
|
|
}
|
|
else if (!PermissionSetAttributeTypeHasRequiredProperty(attributeClass, propName))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
return text;
|
|
}
|
|
|
|
private static bool PermissionSetAttributeTypeHasRequiredProperty(NamedTypeSymbol permissionSetType, string propName)
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Invalid comparison between Unknown and I4
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Invalid comparison between Unknown and I4
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Invalid comparison between Unknown and I4
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Invalid comparison between Unknown and I4
|
|
ImmutableArray<Symbol> members = permissionSetType.GetMembers(propName);
|
|
if (members.Length == 1 && (int)members[0].Kind == 15)
|
|
{
|
|
PropertySymbol propertySymbol = (PropertySymbol)members[0];
|
|
if (propertySymbol.TypeWithAnnotations.HasType && (int)propertySymbol.Type.SpecialType == 20 && (int)propertySymbol.DeclaredAccessibility == 6 && propertySymbol.GetMemberArity() == 0 && (object)propertySymbol.SetMethod != null && (int)propertySymbol.SetMethod.DeclaredAccessibility == 6)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal void DecodeClassInterfaceAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Invalid comparison between Unknown and I4
|
|
TypedConstant val = ((AttributeData)this).CommonConstructorArguments[0];
|
|
ClassInterfaceType classInterfaceType = (((int)((TypedConstant)(ref val)).Kind == 2) ? ((TypedConstant)(ref val)).DecodeValue<ClassInterfaceType>((SpecialType)2) : ((ClassInterfaceType)((TypedConstant)(ref val)).DecodeValue<short>((SpecialType)11)));
|
|
if ((uint)classInterfaceType > 2u)
|
|
{
|
|
Location attributeArgumentSyntaxLocation = ((AttributeData)(object)this).GetAttributeArgumentSyntaxLocation(0, nodeOpt);
|
|
diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, (nodeOpt != null) ? nodeOpt.GetErrorDisplayName() : "");
|
|
}
|
|
}
|
|
|
|
internal void DecodeInterfaceTypeAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Invalid comparison between Unknown and I4
|
|
TypedConstant val = ((AttributeData)this).CommonConstructorArguments[0];
|
|
ComInterfaceType comInterfaceType = (((int)((TypedConstant)(ref val)).Kind == 2) ? ((TypedConstant)(ref val)).DecodeValue<ComInterfaceType>((SpecialType)2) : ((ComInterfaceType)((TypedConstant)(ref val)).DecodeValue<short>((SpecialType)11)));
|
|
if ((uint)comInterfaceType > 3u)
|
|
{
|
|
CSharpSyntaxNode attributeArgumentSyntax = ((AttributeData)(object)this).GetAttributeArgumentSyntax(0, node);
|
|
diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, ((SyntaxNode)attributeArgumentSyntax).Location, node.GetErrorDisplayName());
|
|
}
|
|
}
|
|
|
|
internal string DecodeGuidAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val = ((AttributeData)this).CommonConstructorArguments[0];
|
|
string text = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
if (!Guid.TryParseExact(text, "D", out var _))
|
|
{
|
|
Location attributeArgumentSyntaxLocation = ((AttributeData)(object)this).GetAttributeArgumentSyntaxLocation(0, nodeOpt);
|
|
diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, (nodeOpt != null) ? nodeOpt.GetErrorDisplayName() : "");
|
|
text = string.Empty;
|
|
}
|
|
return text;
|
|
}
|
|
|
|
internal CollectionBuilderAttributeData DecodeCollectionBuilderAttribute()
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val = ((AttributeData)this).CommonConstructorArguments[0];
|
|
TypeSymbol builderType = (TypeSymbol)((TypedConstant)(ref val)).ValueInternal;
|
|
val = ((AttributeData)this).CommonConstructorArguments[1];
|
|
string methodName = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
return new CollectionBuilderAttributeData(builderType, methodName);
|
|
}
|
|
|
|
private protected sealed override bool IsStringProperty(string memberName)
|
|
{
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Invalid comparison between Unknown and I4
|
|
if ((object)AttributeClass != null)
|
|
{
|
|
ImmutableArray<Symbol>.Enumerator enumerator = AttributeClass.GetMembers(memberName).GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
if (enumerator.Current is PropertySymbol { Type: { } type } && (int)type.SpecialType == 20)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal bool ShouldEmitAttribute(Symbol target, bool isReturnType, bool emittingAssemblyAttributesInNetModule)
|
|
{
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0069: Expected I4, but got Unknown
|
|
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
|
|
if (((AttributeData)this).HasErrors)
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Attributes/AttributeData.cs", 700);
|
|
}
|
|
if (((AttributeData)this).IsConditionallyOmitted)
|
|
{
|
|
return false;
|
|
}
|
|
SymbolKind kind = target.Kind;
|
|
switch (kind - 2)
|
|
{
|
|
case 0:
|
|
if ((!emittingAssemblyAttributesInNetModule && (IsTargetAttribute(target, AttributeDescription.AssemblyCultureAttribute) || IsTargetAttribute(target, AttributeDescription.AssemblyVersionAttribute) || IsTargetAttribute(target, AttributeDescription.AssemblyFlagsAttribute) || IsTargetAttribute(target, AttributeDescription.AssemblyAlgorithmIdAttribute))) || IsTargetAttribute(target, AttributeDescription.TypeForwardedToAttribute) || IsSecurityAttribute(target.DeclaringCompilation))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 3:
|
|
if (IsTargetAttribute(target, AttributeDescription.SpecialNameAttribute))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 4:
|
|
if (IsTargetAttribute(target, AttributeDescription.SpecialNameAttribute) || IsTargetAttribute(target, AttributeDescription.NonSerializedAttribute) || IsTargetAttribute(target, AttributeDescription.FieldOffsetAttribute) || IsTargetAttribute(target, AttributeDescription.MarshalAsAttribute))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 7:
|
|
if (isReturnType)
|
|
{
|
|
if (IsTargetAttribute(target, AttributeDescription.MarshalAsAttribute))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else if (IsTargetAttribute(target, AttributeDescription.SpecialNameAttribute) || IsTargetAttribute(target, AttributeDescription.MethodImplAttribute) || IsTargetAttribute(target, AttributeDescription.DllImportAttribute) || IsTargetAttribute(target, AttributeDescription.PreserveSigAttribute) || IsTargetAttribute(target, AttributeDescription.DynamicSecurityMethodAttribute) || IsSecurityAttribute(target.DeclaringCompilation))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 9:
|
|
if (IsTargetAttribute(target, AttributeDescription.SpecialNameAttribute) || IsTargetAttribute(target, AttributeDescription.ComImportAttribute) || IsTargetAttribute(target, AttributeDescription.SerializableAttribute) || IsTargetAttribute(target, AttributeDescription.StructLayoutAttribute) || IsTargetAttribute(target, AttributeDescription.WindowsRuntimeImportAttribute) || IsSecurityAttribute(target.DeclaringCompilation))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 11:
|
|
if (IsTargetAttribute(target, AttributeDescription.OptionalAttribute) || IsTargetAttribute(target, AttributeDescription.DefaultParameterValueAttribute) || IsTargetAttribute(target, AttributeDescription.InAttribute) || IsTargetAttribute(target, AttributeDescription.OutAttribute) || IsTargetAttribute(target, AttributeDescription.MarshalAsAttribute))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
case 13:
|
|
if (IsTargetAttribute(target, AttributeDescription.IndexerNameAttribute) || IsTargetAttribute(target, AttributeDescription.SpecialNameAttribute) || IsTargetAttribute(target, AttributeDescription.DisallowNullAttribute) || IsTargetAttribute(target, AttributeDescription.AllowNullAttribute) || IsTargetAttribute(target, AttributeDescription.MaybeNullAttribute) || IsTargetAttribute(target, AttributeDescription.NotNullAttribute))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
}
|