2229 lines
103 KiB
C#
2229 lines
103 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Reflection.PortableExecutable;
|
|
using System.Security.Cryptography;
|
|
using System.Threading;
|
|
using Microsoft.Cci;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal sealed class SourceAssemblySymbol : MetadataOrSourceAssemblySymbol, ISourceAssemblySymbolInternal, IAssemblySymbolInternal, ISymbolInternal, IAttributeTargetSymbol
|
|
{
|
|
private class NameCollisionForAddedModulesTypeComparer : IComparer<NamedTypeSymbol>
|
|
{
|
|
public static readonly NameCollisionForAddedModulesTypeComparer Singleton = new NameCollisionForAddedModulesTypeComparer();
|
|
|
|
private NameCollisionForAddedModulesTypeComparer()
|
|
{
|
|
}
|
|
|
|
public int Compare(NamedTypeSymbol x, NamedTypeSymbol y)
|
|
{
|
|
int num = string.CompareOrdinal(x.Name, y.Name);
|
|
if (num == 0)
|
|
{
|
|
num = x.Arity - y.Arity;
|
|
if (num == 0)
|
|
{
|
|
num = x.ContainingModule.Ordinal - y.ContainingModule.Ordinal;
|
|
}
|
|
}
|
|
return num;
|
|
}
|
|
}
|
|
|
|
private readonly CSharpCompilation _compilation;
|
|
|
|
private SymbolCompletionState _state;
|
|
|
|
internal AssemblyIdentity lazyAssemblyIdentity;
|
|
|
|
private readonly string _assemblySimpleName;
|
|
|
|
private StrongNameKeys _lazyStrongNameKeys;
|
|
|
|
private readonly ImmutableArray<ModuleSymbol> _modules;
|
|
|
|
private CustomAttributesBag<CSharpAttributeData> _lazySourceAttributesBag;
|
|
|
|
private CustomAttributesBag<CSharpAttributeData> _lazyNetModuleAttributesBag;
|
|
|
|
private IDictionary<string, NamedTypeSymbol> _lazyForwardedTypesFromSource;
|
|
|
|
private ConcurrentSet<int> _lazyOmittedAttributeIndices;
|
|
|
|
private ThreeState _lazyContainsExtensionMethods;
|
|
|
|
private readonly ConcurrentDictionary<FieldSymbol, bool> _unassignedFieldsMap = new ConcurrentDictionary<FieldSymbol, bool>();
|
|
|
|
private readonly ConcurrentSet<FieldSymbol> _unreadFields = new ConcurrentSet<FieldSymbol>();
|
|
|
|
internal ConcurrentSet<TypeSymbol> TypesReferencedInExternalMethods = new ConcurrentSet<TypeSymbol>();
|
|
|
|
private ImmutableArray<Diagnostic> _unusedFieldWarnings;
|
|
|
|
private ConcurrentDictionary<AssemblySymbol, bool> _optimisticallyGrantedInternalsAccess;
|
|
|
|
[ThreadStatic]
|
|
private static AssemblySymbol t_assemblyForWhichCurrentThreadIsComputingKeys;
|
|
|
|
[ThreadStatic]
|
|
private static PooledHashSet<AttributeSyntax> t_forwardedTypesAttributesInProgress;
|
|
|
|
private ConcurrentDictionary<string, ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>>> _lazyInternalsVisibleToMap;
|
|
|
|
public override string Name => _assemblySimpleName;
|
|
|
|
internal sealed override CSharpCompilation DeclaringCompilation => _compilation;
|
|
|
|
public override bool IsInteractive => ((Compilation)_compilation).IsSubmission;
|
|
|
|
public override AssemblyIdentity Identity
|
|
{
|
|
get
|
|
{
|
|
if (lazyAssemblyIdentity == (AssemblyIdentity)null)
|
|
{
|
|
Interlocked.CompareExchange(ref lazyAssemblyIdentity, ComputeIdentity(), null);
|
|
}
|
|
return lazyAssemblyIdentity;
|
|
}
|
|
}
|
|
|
|
internal bool RuntimeCompatibilityWrapNonExceptionThrows => (GetSourceDecodedWellKnownAttributeData() ?? GetNetModuleDecodedWellKnownAttributeData())?.RuntimeCompatibilityWrapNonExceptionThrows ?? true;
|
|
|
|
internal string FileVersion => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyFileVersionAttributeSetting);
|
|
|
|
internal string Title => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyTitleAttributeSetting);
|
|
|
|
internal string Description => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyDescriptionAttributeSetting);
|
|
|
|
internal string Company => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyCompanyAttributeSetting);
|
|
|
|
internal string Product => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyProductAttributeSetting);
|
|
|
|
internal string InformationalVersion => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyInformationalVersionAttributeSetting);
|
|
|
|
internal string Copyright => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyCopyrightAttributeSetting);
|
|
|
|
internal string Trademark => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyTrademarkAttributeSetting);
|
|
|
|
private ThreeState AssemblyDelaySignAttributeSetting
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0016: 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_0014: 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_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)
|
|
ThreeState val = (ThreeState)0;
|
|
ThreeState val2 = val;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> sourceDecodedWellKnownAttributeData = GetSourceDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
val2 = sourceDecodedWellKnownAttributeData.AssemblyDelaySignAttributeSetting;
|
|
}
|
|
if (val2 == val)
|
|
{
|
|
sourceDecodedWellKnownAttributeData = GetNetModuleDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
val2 = sourceDecodedWellKnownAttributeData.AssemblyDelaySignAttributeSetting;
|
|
}
|
|
}
|
|
return val2;
|
|
}
|
|
}
|
|
|
|
private string AssemblyKeyContainerAttributeSetting => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyKeyContainerAttributeSetting, WellKnownAttributeData.StringMissingValue, QuickAttributes.AssemblyKeyName);
|
|
|
|
private string AssemblyKeyFileAttributeSetting => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyKeyFileAttributeSetting, WellKnownAttributeData.StringMissingValue, QuickAttributes.AssemblyKeyFile);
|
|
|
|
private string AssemblyCultureAttributeSetting => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblyCultureAttributeSetting);
|
|
|
|
public string SignatureKey => GetWellKnownAttributeDataStringField((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> data) => data.AssemblySignatureKeyAttributeSetting, null, QuickAttributes.AssemblySignatureKey);
|
|
|
|
private Version AssemblyVersionAttributeSetting
|
|
{
|
|
get
|
|
{
|
|
Version version = null;
|
|
Version version2 = version;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> sourceDecodedWellKnownAttributeData = GetSourceDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
version2 = sourceDecodedWellKnownAttributeData.AssemblyVersionAttributeSetting;
|
|
}
|
|
if (version2 == version)
|
|
{
|
|
sourceDecodedWellKnownAttributeData = GetNetModuleDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
version2 = sourceDecodedWellKnownAttributeData.AssemblyVersionAttributeSetting;
|
|
}
|
|
}
|
|
return version2;
|
|
}
|
|
}
|
|
|
|
public override Version AssemblyVersionPattern
|
|
{
|
|
get
|
|
{
|
|
Version assemblyVersionAttributeSetting = AssemblyVersionAttributeSetting;
|
|
if ((object)assemblyVersionAttributeSetting != null && (assemblyVersionAttributeSetting.Build == 65535 || assemblyVersionAttributeSetting.Revision == 65535))
|
|
{
|
|
return assemblyVersionAttributeSetting;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public AssemblyHashAlgorithm HashAlgorithm => AssemblyAlgorithmIdAttributeSetting ?? AssemblyHashAlgorithm.Sha1;
|
|
|
|
internal AssemblyHashAlgorithm? AssemblyAlgorithmIdAttributeSetting
|
|
{
|
|
get
|
|
{
|
|
AssemblyHashAlgorithm? result = null;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> sourceDecodedWellKnownAttributeData = GetSourceDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
result = sourceDecodedWellKnownAttributeData.AssemblyAlgorithmIdAttributeSetting;
|
|
}
|
|
if (!result.HasValue)
|
|
{
|
|
sourceDecodedWellKnownAttributeData = GetNetModuleDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
result = sourceDecodedWellKnownAttributeData.AssemblyAlgorithmIdAttributeSetting;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public AssemblyFlags AssemblyFlags
|
|
{
|
|
get
|
|
{
|
|
AssemblyFlags assemblyFlags = (AssemblyFlags)0;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> sourceDecodedWellKnownAttributeData = GetSourceDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
assemblyFlags = sourceDecodedWellKnownAttributeData.AssemblyFlagsAttributeSetting;
|
|
}
|
|
sourceDecodedWellKnownAttributeData = GetNetModuleDecodedWellKnownAttributeData();
|
|
if (sourceDecodedWellKnownAttributeData != null)
|
|
{
|
|
assemblyFlags |= sourceDecodedWellKnownAttributeData.AssemblyFlagsAttributeSetting;
|
|
}
|
|
return assemblyFlags;
|
|
}
|
|
}
|
|
|
|
internal StrongNameKeys StrongNameKeys
|
|
{
|
|
get
|
|
{
|
|
if (_lazyStrongNameKeys == null)
|
|
{
|
|
try
|
|
{
|
|
t_assemblyForWhichCurrentThreadIsComputingKeys = this;
|
|
Interlocked.CompareExchange(ref _lazyStrongNameKeys, ComputeStrongNameKeys(), null);
|
|
}
|
|
finally
|
|
{
|
|
t_assemblyForWhichCurrentThreadIsComputingKeys = null;
|
|
}
|
|
}
|
|
return _lazyStrongNameKeys;
|
|
}
|
|
}
|
|
|
|
internal override ImmutableArray<byte> PublicKey => StrongNameKeys.PublicKey;
|
|
|
|
public override ImmutableArray<ModuleSymbol> Modules => _modules;
|
|
|
|
public override ImmutableArray<Location> Locations => ImmutableArrayExtensions.AsImmutable<Location>(Modules.SelectMany((ModuleSymbol m) => m.Locations));
|
|
|
|
public bool InternalsAreVisible
|
|
{
|
|
get
|
|
{
|
|
EnsureAttributesAreBound();
|
|
return _lazyInternalsVisibleToMap != null;
|
|
}
|
|
}
|
|
|
|
internal bool IsDelaySigned
|
|
{
|
|
get
|
|
{
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Invalid comparison between Unknown and I4
|
|
if (((CompilationOptions)_compilation.Options).DelaySign.HasValue)
|
|
{
|
|
return ((CompilationOptions)_compilation.Options).DelaySign.Value;
|
|
}
|
|
if (((CompilationOptions)_compilation.Options).PublicSign)
|
|
{
|
|
return false;
|
|
}
|
|
return (int)AssemblyDelaySignAttributeSetting == 2;
|
|
}
|
|
}
|
|
|
|
internal SourceModuleSymbol SourceModule => (SourceModuleSymbol)Modules[0];
|
|
|
|
internal override bool RequiresCompletion => true;
|
|
|
|
internal override bool IsLinked => false;
|
|
|
|
internal bool DeclaresTheObjectClass
|
|
{
|
|
get
|
|
{
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Invalid comparison between Unknown and I4
|
|
if ((object)base.CorLibrary != this)
|
|
{
|
|
return false;
|
|
}
|
|
NamedTypeSymbol specialType = GetSpecialType((SpecialType)1);
|
|
if (!specialType.IsErrorType())
|
|
{
|
|
return (int)specialType.DeclaredAccessibility == 6;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override bool MightContainExtensionMethods
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (ThreeStateHelpers.HasValue(_lazyContainsExtensionMethods))
|
|
{
|
|
return ThreeStateHelpers.Value(_lazyContainsExtensionMethods);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private bool HasDebuggableAttribute => GetSourceDecodedWellKnownAttributeData()?.HasDebuggableAttribute ?? false;
|
|
|
|
private bool HasReferenceAssemblyAttribute => GetSourceDecodedWellKnownAttributeData()?.HasReferenceAssemblyAttribute ?? false;
|
|
|
|
IAttributeTargetSymbol IAttributeTargetSymbol.AttributesOwner => this;
|
|
|
|
AttributeLocation IAttributeTargetSymbol.DefaultAttributeLocation => AttributeLocation.Assembly;
|
|
|
|
AttributeLocation IAttributeTargetSymbol.AllowedAttributeLocations
|
|
{
|
|
get
|
|
{
|
|
if (!IsInteractive)
|
|
{
|
|
return AttributeLocation.Assembly | AttributeLocation.Module;
|
|
}
|
|
return AttributeLocation.None;
|
|
}
|
|
}
|
|
|
|
internal sealed override ObsoleteAttributeData? ObsoleteAttributeData
|
|
{
|
|
get
|
|
{
|
|
CustomAttributesBag<CSharpAttributeData> lazySourceAttributesBag = _lazySourceAttributesBag;
|
|
if (lazySourceAttributesBag != null && lazySourceAttributesBag.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
ObsoleteAttributeData val = ((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazySourceAttributesBag.DecodedWellKnownAttributeData)?.ExperimentalAttributeData;
|
|
if (val != null)
|
|
{
|
|
return val;
|
|
}
|
|
}
|
|
CustomAttributesBag<CSharpAttributeData> lazyNetModuleAttributesBag = _lazyNetModuleAttributesBag;
|
|
if (lazyNetModuleAttributesBag != null && lazyNetModuleAttributesBag.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
return ((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazyNetModuleAttributesBag.DecodedWellKnownAttributeData)?.ExperimentalAttributeData;
|
|
}
|
|
if (GetAttributeDeclarations().IsEmpty)
|
|
{
|
|
return null;
|
|
}
|
|
return ObsoleteAttributeData.Uninitialized;
|
|
}
|
|
}
|
|
|
|
internal IEnumerable<CSharpAttributeData> GetCustomAttributesToEmit(PEModuleBuilder moduleBuilder, bool emittingRefAssembly, bool emittingAssemblyAttributesInNetModule)
|
|
{
|
|
ImmutableArray<CSharpAttributeData> attributes = GetAttributes();
|
|
ArrayBuilder<SynthesizedAttributeData> attributes2 = null;
|
|
AddSynthesizedAttributes(moduleBuilder, ref attributes2);
|
|
if (emittingRefAssembly && !HasReferenceAssemblyAttribute)
|
|
{
|
|
SynthesizedAttributeData attribute = DeclaringCompilation.TrySynthesizeAttribute((WellKnownMember)393, default(ImmutableArray<TypedConstant>), default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
|
|
Symbol.AddSynthesizedAttribute(ref attributes2, attribute);
|
|
}
|
|
return GetCustomAttributesToEmit(attributes, attributes2, isReturnType: false, emittingAssemblyAttributesInNetModule);
|
|
}
|
|
|
|
internal SourceAssemblySymbol(CSharpCompilation compilation, string assemblySimpleName, string moduleName, ImmutableArray<PEModule> netModules)
|
|
{
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0063: Invalid comparison between Unknown and I4
|
|
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
_compilation = compilation;
|
|
_assemblySimpleName = assemblySimpleName;
|
|
ArrayBuilder<ModuleSymbol> val = new ArrayBuilder<ModuleSymbol>(1 + netModules.Length);
|
|
val.Add((ModuleSymbol)new SourceModuleSymbol(this, compilation.Declarations, moduleName));
|
|
MetadataImportOptions importOptions = (MetadataImportOptions)(((int)((CompilationOptions)compilation.Options).MetadataImportOptions != 2) ? 1 : 2);
|
|
ImmutableArray<PEModule>.Enumerator enumerator = netModules.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
PEModule current = enumerator.Current;
|
|
val.Add((ModuleSymbol)new PEModuleSymbol(this, current, importOptions, val.Count));
|
|
}
|
|
_modules = val.ToImmutableAndFree();
|
|
if (!((CompilationOptions)compilation.Options).CryptoPublicKey.IsEmpty)
|
|
{
|
|
_lazyStrongNameKeys = StrongNameKeys.Create(((CompilationOptions)compilation.Options).CryptoPublicKey, (RSAParameters?)null, false, (CommonMessageProvider)(object)MessageProvider.Instance);
|
|
}
|
|
}
|
|
|
|
internal bool MightContainNoPiaLocalTypes()
|
|
{
|
|
for (int i = 1; i < _modules.Length; i++)
|
|
{
|
|
if (((PEModuleSymbol)_modules[i]).Module.ContainsNoPiaLocalTypes())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return SourceModule.MightContainNoPiaLocalTypes();
|
|
}
|
|
|
|
internal override Symbol GetSpecialTypeMember(SpecialMember member)
|
|
{
|
|
//IL_0006: 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)
|
|
if (!((Compilation)_compilation).IsMemberMissing(member))
|
|
{
|
|
return base.GetSpecialTypeMember(member);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private string? GetWellKnownAttributeDataStringField(Func<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>, string> fieldGetter, string? missingValue = null, QuickAttributes? attributeMatchesOpt = null)
|
|
{
|
|
string text = missingValue;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> val = (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)((!attributeMatchesOpt.HasValue) ? ((object)GetSourceDecodedWellKnownAttributeData()) : ((object)GetSourceDecodedWellKnownAttributeData(attributeMatchesOpt.Value)));
|
|
if (val != null)
|
|
{
|
|
text = fieldGetter(val);
|
|
}
|
|
if ((object)text == missingValue)
|
|
{
|
|
val = ((!attributeMatchesOpt.HasValue || _lazyNetModuleAttributesBag != null) ? GetNetModuleDecodedWellKnownAttributeData() : GetLimitedNetModuleDecodedWellKnownAttributeData(attributeMatchesOpt.Value));
|
|
if (val != null)
|
|
{
|
|
text = fieldGetter(val);
|
|
}
|
|
}
|
|
return text;
|
|
}
|
|
|
|
private StrongNameKeys ComputeStrongNameKeys()
|
|
{
|
|
string text = ((CompilationOptions)_compilation.Options).CryptoKeyFile;
|
|
if (((CompilationOptions)DeclaringCompilation.Options).PublicSign)
|
|
{
|
|
if (!string.IsNullOrEmpty(text) && !PathUtilities.IsAbsolute(text))
|
|
{
|
|
return StrongNameKeys.None;
|
|
}
|
|
return StrongNameKeys.Create(text, (CommonMessageProvider)(object)MessageProvider.Instance);
|
|
}
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = AssemblyKeyFileAttributeSetting;
|
|
if ((object)text == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
text = null;
|
|
}
|
|
}
|
|
string text2 = ((CompilationOptions)_compilation.Options).CryptoKeyContainer;
|
|
if (string.IsNullOrEmpty(text2))
|
|
{
|
|
text2 = AssemblyKeyContainerAttributeSetting;
|
|
if ((object)text2 == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
text2 = null;
|
|
}
|
|
}
|
|
bool flag = !string.IsNullOrEmpty(SignatureKey);
|
|
return StrongNameKeys.Create(((CompilationOptions)DeclaringCompilation.Options).StrongNameProvider, text, text2, flag, (CommonMessageProvider)(object)MessageProvider.Instance);
|
|
}
|
|
|
|
private void ValidateAttributeSemantics(BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00db: Invalid comparison between Unknown and I4
|
|
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
|
|
if (StrongNameKeys.DiagnosticOpt != null && !EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
((BindingDiagnosticBag)diagnostics).Add(StrongNameKeys.DiagnosticOpt);
|
|
}
|
|
ValidateIVTPublicKeys(diagnostics);
|
|
CheckOptimisticIVTAccessGrants(diagnostics);
|
|
DetectAttributeAndOptionConflicts(diagnostics);
|
|
if (IsDelaySigned && !Identity.HasPublicKey)
|
|
{
|
|
diagnostics.Add(ErrorCode.WRN_DelaySignButNoKey, NoLocation.Singleton);
|
|
}
|
|
if (((CompilationOptions)DeclaringCompilation.Options).PublicSign)
|
|
{
|
|
if (EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_PublicSignNetModule, NoLocation.Singleton);
|
|
}
|
|
else if (!Identity.HasPublicKey)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_PublicSignButNoKey, NoLocation.Singleton);
|
|
}
|
|
}
|
|
if ((int)((CompilationOptions)DeclaringCompilation.Options).OutputKind != 3 && ((CompilationOptions)DeclaringCompilation.Options).CryptoPublicKey.IsEmpty && Identity.HasPublicKey && !IsDelaySigned && !((CompilationOptions)DeclaringCompilation.Options).PublicSign && !StrongNameKeys.CanSign && StrongNameKeys.DiagnosticOpt == null)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_SignButNoPrivateKey, NoLocation.Singleton, StrongNameKeys.KeyFilePath);
|
|
}
|
|
ReportDiagnosticsForSynthesizedAttributes(_compilation, diagnostics);
|
|
}
|
|
|
|
private static void ReportDiagnosticsForSynthesizedAttributes(CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
|
ReportDiagnosticsForUnsafeSynthesizedAttributes(compilation, diagnostics);
|
|
if (!EnumBounds.IsNetModule(((CompilationOptions)compilation.Options).OutputKind))
|
|
{
|
|
if (!(compilation.GetWellKnownType((WellKnownType)176) is MissingMetadataTypeSymbol))
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)114, diagnostics, NoLocation.Singleton);
|
|
}
|
|
if (!(compilation.GetWellKnownType((WellKnownType)177) is MissingMetadataTypeSymbol))
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)115, diagnostics, NoLocation.Singleton);
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)116, diagnostics, NoLocation.Singleton);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void ReportDiagnosticsForUnsafeSynthesizedAttributes(CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
|
|
{
|
|
if (compilation.Options.AllowUnsafe && !(compilation.GetWellKnownType((WellKnownType)236) is MissingMetadataTypeSymbol))
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)134, diagnostics, NoLocation.Singleton);
|
|
if (!(compilation.GetWellKnownType((WellKnownType)239) is MissingMetadataTypeSymbol) && !(compilation.GetWellKnownType((WellKnownType)237) is MissingMetadataTypeSymbol))
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)136, diagnostics, NoLocation.Singleton);
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(compilation, (WellKnownMember)137, diagnostics, NoLocation.Singleton);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ValidateIVTPublicKeys(BindingDiagnosticBag diagnostics)
|
|
{
|
|
EnsureAttributesAreBound();
|
|
if (!Identity.IsStrongName || _lazyInternalsVisibleToMap == null)
|
|
{
|
|
return;
|
|
}
|
|
foreach (ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>> value in _lazyInternalsVisibleToMap.Values)
|
|
{
|
|
foreach (KeyValuePair<ImmutableArray<byte>, Tuple<Location, string>> item in value)
|
|
{
|
|
if (item.Key.IsDefaultOrEmpty)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_FriendAssemblySNReq, item.Value.Item1, item.Value.Item2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DetectAttributeAndOptionConflicts(BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Invalid comparison between Unknown and I4
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0044: Invalid comparison between Unknown and I4
|
|
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f6: Invalid comparison between Unknown and I4
|
|
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013e: Invalid comparison between Unknown and I4
|
|
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0239: Invalid comparison between Unknown and I4
|
|
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0282: Invalid comparison between Unknown and I4
|
|
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
|
|
EnsureAttributesAreBound();
|
|
ThreeState assemblyDelaySignAttributeSetting = AssemblyDelaySignAttributeSetting;
|
|
AttributeDescription val;
|
|
if (((CompilationOptions)_compilation.Options).DelaySign.HasValue && (int)assemblyDelaySignAttributeSetting != 0 && ((CompilationOptions)DeclaringCompilation.Options).DelaySign.Value != ((int)assemblyDelaySignAttributeSetting == 2))
|
|
{
|
|
Location singleton = NoLocation.Singleton;
|
|
object[] obj = new object[2] { "DelaySign", null };
|
|
val = AttributeDescription.AssemblyDelaySignAttribute;
|
|
obj[1] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, singleton, obj);
|
|
}
|
|
if (((CompilationOptions)_compilation.Options).PublicSign && (int)assemblyDelaySignAttributeSetting == 2)
|
|
{
|
|
Location singleton2 = NoLocation.Singleton;
|
|
object[] obj2 = new object[2] { "PublicSign", null };
|
|
val = AttributeDescription.AssemblyDelaySignAttribute;
|
|
obj2[1] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, singleton2, obj2);
|
|
}
|
|
if (!string.IsNullOrEmpty(((CompilationOptions)_compilation.Options).CryptoKeyContainer))
|
|
{
|
|
string assemblyKeyContainerAttributeSetting = AssemblyKeyContainerAttributeSetting;
|
|
if ((object)assemblyKeyContainerAttributeSetting == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
if ((int)((CompilationOptions)_compilation.Options).OutputKind == 3)
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(_compilation, (WellKnownMember)46, diagnostics, NoLocation.Singleton);
|
|
}
|
|
}
|
|
else if (string.Compare(((CompilationOptions)_compilation.Options).CryptoKeyContainer, assemblyKeyContainerAttributeSetting, StringComparison.OrdinalIgnoreCase) != 0)
|
|
{
|
|
if ((int)((CompilationOptions)_compilation.Options).OutputKind == 3)
|
|
{
|
|
Location singleton3 = NoLocation.Singleton;
|
|
object[] array = new object[2];
|
|
val = AttributeDescription.AssemblyKeyNameAttribute;
|
|
array[0] = ((AttributeDescription)(ref val)).FullName;
|
|
array[1] = "CryptoKeyContainer";
|
|
diagnostics.Add(ErrorCode.ERR_CmdOptionConflictsSource, singleton3, array);
|
|
}
|
|
else
|
|
{
|
|
Location singleton4 = NoLocation.Singleton;
|
|
object[] obj3 = new object[2] { "CryptoKeyContainer", null };
|
|
val = AttributeDescription.AssemblyKeyNameAttribute;
|
|
obj3[1] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, singleton4, obj3);
|
|
}
|
|
}
|
|
}
|
|
if (((CompilationOptions)_compilation.Options).PublicSign && !EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind) && (object)AssemblyKeyContainerAttributeSetting != WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
Location singleton5 = NoLocation.Singleton;
|
|
object[] array2 = new object[1];
|
|
val = AttributeDescription.AssemblyKeyNameAttribute;
|
|
array2[0] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_AttributeIgnoredWhenPublicSigning, singleton5, array2);
|
|
}
|
|
if (!string.IsNullOrEmpty(((CompilationOptions)_compilation.Options).CryptoKeyFile))
|
|
{
|
|
string assemblyKeyFileAttributeSetting = AssemblyKeyFileAttributeSetting;
|
|
if ((object)assemblyKeyFileAttributeSetting == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
if ((int)((CompilationOptions)_compilation.Options).OutputKind == 3)
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(_compilation, (WellKnownMember)45, diagnostics, NoLocation.Singleton);
|
|
}
|
|
}
|
|
else if (string.Compare(((CompilationOptions)_compilation.Options).CryptoKeyFile, assemblyKeyFileAttributeSetting, StringComparison.OrdinalIgnoreCase) != 0)
|
|
{
|
|
if ((int)((CompilationOptions)_compilation.Options).OutputKind == 3)
|
|
{
|
|
Location singleton6 = NoLocation.Singleton;
|
|
object[] array3 = new object[2];
|
|
val = AttributeDescription.AssemblyKeyFileAttribute;
|
|
array3[0] = ((AttributeDescription)(ref val)).FullName;
|
|
array3[1] = "CryptoKeyFile";
|
|
diagnostics.Add(ErrorCode.ERR_CmdOptionConflictsSource, singleton6, array3);
|
|
}
|
|
else
|
|
{
|
|
Location singleton7 = NoLocation.Singleton;
|
|
object[] obj4 = new object[2] { "CryptoKeyFile", null };
|
|
val = AttributeDescription.AssemblyKeyFileAttribute;
|
|
obj4[1] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_CmdOptionConflictsSource, singleton7, obj4);
|
|
}
|
|
}
|
|
}
|
|
if (((CompilationOptions)_compilation.Options).PublicSign && !EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind) && (object)AssemblyKeyFileAttributeSetting != WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
Location singleton8 = NoLocation.Singleton;
|
|
object[] array4 = new object[1];
|
|
val = AttributeDescription.AssemblyKeyFileAttribute;
|
|
array4[0] = ((AttributeDescription)(ref val)).FullName;
|
|
diagnostics.Add(ErrorCode.WRN_AttributeIgnoredWhenPublicSigning, singleton8, array4);
|
|
}
|
|
}
|
|
|
|
internal override bool HasComplete(CompletionPart part)
|
|
{
|
|
return _state.HasComplete(part);
|
|
}
|
|
|
|
internal override void ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
|
|
{
|
|
while (true)
|
|
{
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
CompletionPart nextIncompletePart = _state.NextIncompletePart;
|
|
switch (nextIncompletePart)
|
|
{
|
|
case CompletionPart.Attributes:
|
|
EnsureAttributesAreBound();
|
|
break;
|
|
case CompletionPart.StartBaseType:
|
|
case CompletionPart.FinishBaseType:
|
|
if (_state.NotePartComplete(CompletionPart.StartBaseType))
|
|
{
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
|
|
ValidateAttributeSemantics(instance);
|
|
AddDeclarationDiagnostics(instance);
|
|
_state.NotePartComplete(CompletionPart.FinishBaseType);
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
|
}
|
|
break;
|
|
case CompletionPart.StartInterfaces:
|
|
SourceModule.ForceComplete(locationOpt, cancellationToken);
|
|
if (SourceModule.HasComplete(CompletionPart.MembersCompleted))
|
|
{
|
|
_state.NotePartComplete(CompletionPart.StartInterfaces);
|
|
break;
|
|
}
|
|
return;
|
|
case CompletionPart.EnumUnderlyingType:
|
|
case CompletionPart.TypeArguments:
|
|
if (_state.NotePartComplete(CompletionPart.EnumUnderlyingType))
|
|
{
|
|
ReportDiagnosticsForAddedModules();
|
|
_state.NotePartComplete(CompletionPart.TypeArguments);
|
|
}
|
|
break;
|
|
case CompletionPart.None:
|
|
return;
|
|
default:
|
|
_state.NotePartComplete(CompletionPart.NamespaceSymbolAll | CompletionPart.ReturnTypeAttributes | CompletionPart.Parameters | CompletionPart.Type | CompletionPart.FinishInterfaces | CompletionPart.TypeParameters | CompletionPart.TypeMembers | CompletionPart.SynthesizedExplicitImplementations | CompletionPart.StartMemberChecks | CompletionPart.FinishMemberChecks | CompletionPart.MembersCompletedChecksStarted);
|
|
break;
|
|
}
|
|
_state.SpinWaitComplete(nextIncompletePart, cancellationToken);
|
|
}
|
|
}
|
|
|
|
private void ReportDiagnosticsForAddedModules()
|
|
{
|
|
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
|
|
foreach (KeyValuePair<MetadataReference, int> item in ((CommonReferenceManager<CSharpCompilation, AssemblySymbol>)(object)_compilation.GetBoundReferenceManager()).ReferencedModuleIndexMap)
|
|
{
|
|
MetadataReference key = item.Key;
|
|
PortableExecutableReference val = (PortableExecutableReference)(object)((key is PortableExecutableReference) ? key : null);
|
|
if (val != null && val.FilePath != null)
|
|
{
|
|
string fileName = FileNameUtilities.GetFileName(val.FilePath, true);
|
|
string name = _modules[item.Value].Name;
|
|
if (!string.Equals(fileName, name, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
instance.Add(ErrorCode.ERR_NetModuleNameMismatch, NoLocation.Singleton, name, fileName);
|
|
}
|
|
}
|
|
}
|
|
if (_modules.Length > 1 && !EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
Machine machine = base.Machine;
|
|
bool flag = machine == Machine.I386 && !base.Bit32Required;
|
|
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
for (int i = 1; i < _modules.Length; i++)
|
|
{
|
|
ModuleSymbol moduleSymbol = _modules[i];
|
|
if (!hashSet.Add(moduleSymbol.Name))
|
|
{
|
|
instance.Add(ErrorCode.ERR_NetModuleNameMustBeUnique, NoLocation.Singleton, moduleSymbol.Name);
|
|
}
|
|
if (((PEModuleSymbol)moduleSymbol).Module.IsCOFFOnly)
|
|
{
|
|
continue;
|
|
}
|
|
Machine machine2 = moduleSymbol.Machine;
|
|
if (machine2 != Machine.I386 || moduleSymbol.Bit32Required)
|
|
{
|
|
if (flag)
|
|
{
|
|
instance.Add(ErrorCode.ERR_AgnosticToMachineModule, NoLocation.Singleton, moduleSymbol);
|
|
}
|
|
else if (machine != machine2)
|
|
{
|
|
instance.Add(ErrorCode.ERR_ConflictingMachineModule, NoLocation.Singleton, moduleSymbol);
|
|
}
|
|
}
|
|
}
|
|
for (int j = 1; j < _modules.Length; j++)
|
|
{
|
|
PEModuleSymbol pEModuleSymbol = (PEModuleSymbol)_modules[j];
|
|
try
|
|
{
|
|
foreach (string item2 in pEModuleSymbol.Module.GetReferencedManagedModulesOrThrow())
|
|
{
|
|
if (hashSet.Add(item2))
|
|
{
|
|
instance.Add(ErrorCode.ERR_MissingNetModuleReference, NoLocation.Singleton, item2);
|
|
}
|
|
}
|
|
}
|
|
catch (BadImageFormatException)
|
|
{
|
|
instance.Add((DiagnosticInfo?)(object)new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, pEModuleSymbol), NoLocation.Singleton);
|
|
}
|
|
}
|
|
}
|
|
ReportNameCollisionDiagnosticsForAddedModules(GlobalNamespace, instance);
|
|
AddDeclarationDiagnostics(instance);
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
|
}
|
|
|
|
private void ReportNameCollisionDiagnosticsForAddedModules(NamespaceSymbol ns, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0187: Invalid comparison between Unknown and I4
|
|
if (!(ns is MergedNamespaceSymbol { ConstituentNamespaces: var constituentNamespaces } mergedNamespaceSymbol) || (constituentNamespaces.Length <= 2 && (constituentNamespaces.Length != 2 || constituentNamespaces[0].ContainingModule.Ordinal == 0 || constituentNamespaces[1].ContainingModule.Ordinal == 0)))
|
|
{
|
|
return;
|
|
}
|
|
ArrayBuilder<NamedTypeSymbol> instance = ArrayBuilder<NamedTypeSymbol>.GetInstance();
|
|
ImmutableArray<NamespaceSymbol>.Enumerator enumerator = constituentNamespaces.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
NamespaceSymbol current = enumerator.Current;
|
|
if (current.ContainingModule.Ordinal != 0)
|
|
{
|
|
instance.AddRange(current.GetTypeMembers());
|
|
}
|
|
}
|
|
instance.Sort((IComparer<NamedTypeSymbol>)NameCollisionForAddedModulesTypeComparer.Singleton);
|
|
bool flag = false;
|
|
for (int i = 0; i < instance.Count - 1; i++)
|
|
{
|
|
NamedTypeSymbol namedTypeSymbol = instance[i];
|
|
NamedTypeSymbol namedTypeSymbol2 = instance[i + 1];
|
|
if (namedTypeSymbol.Arity == namedTypeSymbol2.Arity && namedTypeSymbol.Name == namedTypeSymbol2.Name)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (namedTypeSymbol.Arity != 0 || !namedTypeSymbol.ContainingNamespace.IsGlobalNamespace || namedTypeSymbol.Name != "<Module>")
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_DuplicateNameInNS, namedTypeSymbol2.GetFirstLocationOrNone(), ((Symbol)namedTypeSymbol2).ToDisplayString(SymbolDisplayFormat.ShortFormat), namedTypeSymbol2.ContainingNamespace);
|
|
}
|
|
flag = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
instance.Free();
|
|
ImmutableArray<Symbol>.Enumerator enumerator2 = mergedNamespaceSymbol.GetMembers().GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
Symbol current2 = enumerator2.Current;
|
|
if ((int)current2.Kind == 12)
|
|
{
|
|
ReportNameCollisionDiagnosticsForAddedModules((NamespaceSymbol)current2, diagnostics);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool IsKnownAssemblyAttribute(CSharpAttributeData attribute)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: 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_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00de: 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)
|
|
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyTitleAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyDescriptionAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyConfigurationAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCultureAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyVersionAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCompanyAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyProductAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyInformationalVersionAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCopyrightAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyTrademarkAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyFileAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyNameAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyAlgorithmIdAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyFlagsAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyDelaySignAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblyFileVersionAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.SatelliteContractVersionAttribute) || attribute.IsTargetAttribute(this, AttributeDescription.AssemblySignatureKeyAttribute))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void AddOmittedAttributeIndex(int index)
|
|
{
|
|
if (_lazyOmittedAttributeIndices == null)
|
|
{
|
|
Interlocked.CompareExchange(ref _lazyOmittedAttributeIndices, new ConcurrentSet<int>(), null);
|
|
}
|
|
_lazyOmittedAttributeIndices.Add(index);
|
|
}
|
|
|
|
private HashSet<CSharpAttributeData> GetUniqueSourceAssemblyAttributes()
|
|
{
|
|
ImmutableArray<CSharpAttributeData> attributes = GetSourceAttributesBag().Attributes;
|
|
HashSet<CSharpAttributeData> uniqueAttributes = null;
|
|
for (int i = 0; i < attributes.Length; i++)
|
|
{
|
|
CSharpAttributeData cSharpAttributeData = attributes[i];
|
|
if (!((AttributeData)cSharpAttributeData).HasErrors && !AddUniqueAssemblyAttribute(cSharpAttributeData, ref uniqueAttributes))
|
|
{
|
|
AddOmittedAttributeIndex(i);
|
|
}
|
|
}
|
|
return uniqueAttributes;
|
|
}
|
|
|
|
private static bool AddUniqueAssemblyAttribute(CSharpAttributeData attribute, ref HashSet<CSharpAttributeData> uniqueAttributes)
|
|
{
|
|
if (uniqueAttributes == null)
|
|
{
|
|
uniqueAttributes = new HashSet<CSharpAttributeData>((IEqualityComparer<CSharpAttributeData>?)CommonAttributeDataComparer.Instance);
|
|
}
|
|
return uniqueAttributes.Add(attribute);
|
|
}
|
|
|
|
private bool ValidateAttributeUsageForNetModuleAttribute(CSharpAttributeData attribute, string netModuleName, BindingDiagnosticBag diagnostics, ref HashSet<CSharpAttributeData> uniqueAttributes)
|
|
{
|
|
//IL_0018: 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)
|
|
NamedTypeSymbol attributeClass = attribute.AttributeClass;
|
|
AttributeUsageInfo attributeUsageInfo = attributeClass.GetAttributeUsageInfo();
|
|
if (((AttributeUsageInfo)(ref attributeUsageInfo)).AllowMultiple)
|
|
{
|
|
return AddUniqueAssemblyAttribute(attribute, ref uniqueAttributes);
|
|
}
|
|
if (uniqueAttributes == null || !EnumerableExtensions.Contains<CSharpAttributeData>((IEnumerable<CSharpAttributeData>)uniqueAttributes, (Func<CSharpAttributeData, bool>)((CSharpAttributeData a) => TypeSymbol.Equals(a.AttributeClass, attributeClass, (TypeCompareKind)0))))
|
|
{
|
|
AddUniqueAssemblyAttribute(attribute, ref uniqueAttributes);
|
|
return true;
|
|
}
|
|
if (IsKnownAssemblyAttribute(attribute))
|
|
{
|
|
if (!uniqueAttributes.Contains(attribute))
|
|
{
|
|
diagnostics.Add(ErrorCode.WRN_AssemblyAttributeFromModuleIsOverridden, NoLocation.Singleton, attribute.AttributeClass, netModuleName);
|
|
}
|
|
}
|
|
else if (AddUniqueAssemblyAttribute(attribute, ref uniqueAttributes))
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_DuplicateAttributeInNetModule, NoLocation.Singleton, attribute.AttributeClass.Name, netModuleName);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ImmutableArray<CSharpAttributeData> GetNetModuleAttributes(out ImmutableArray<string> netModuleNames)
|
|
{
|
|
ArrayBuilder<CSharpAttributeData> val = null;
|
|
ArrayBuilder<string> val2 = null;
|
|
for (int i = 1; i < _modules.Length; i++)
|
|
{
|
|
PEModuleSymbol obj = (PEModuleSymbol)_modules[i];
|
|
string name = obj.Name;
|
|
ImmutableArray<CSharpAttributeData>.Enumerator enumerator = obj.GetAssemblyAttributes().GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
CSharpAttributeData current = enumerator.Current;
|
|
if (val2 == null)
|
|
{
|
|
val2 = ArrayBuilder<string>.GetInstance();
|
|
val = ArrayBuilder<CSharpAttributeData>.GetInstance();
|
|
}
|
|
val2.Add(name);
|
|
val.Add(current);
|
|
}
|
|
}
|
|
if (val2 == null)
|
|
{
|
|
netModuleNames = ImmutableArray<string>.Empty;
|
|
return ImmutableArray<CSharpAttributeData>.Empty;
|
|
}
|
|
netModuleNames = val2.ToImmutableAndFree();
|
|
return val.ToImmutableAndFree();
|
|
}
|
|
|
|
private WellKnownAttributeData ValidateAttributeUsageAndDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> attributesFromNetModules, ImmutableArray<string> netModuleNames, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
int length = attributesFromNetModules.Length;
|
|
int length2 = GetSourceAttributesBag().Attributes.Length;
|
|
HashSet<CSharpAttributeData> uniqueAttributes = GetUniqueSourceAssemblyAttributes();
|
|
DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments = new DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation>
|
|
{
|
|
AttributesCount = length,
|
|
Diagnostics = (BindingDiagnosticBag)(object)diagnostics,
|
|
SymbolPart = AttributeLocation.None
|
|
};
|
|
for (int num = length - 1; num >= 0; num--)
|
|
{
|
|
int index = num + length2;
|
|
CSharpAttributeData cSharpAttributeData = attributesFromNetModules[num];
|
|
if (!((AttributeData)cSharpAttributeData).HasErrors && ValidateAttributeUsageForNetModuleAttribute(cSharpAttributeData, netModuleNames[num], diagnostics, ref uniqueAttributes))
|
|
{
|
|
arguments.Attribute = cSharpAttributeData;
|
|
arguments.Index = num;
|
|
arguments.AttributeSyntaxOpt = null;
|
|
DecodeWellKnownAttribute(ref arguments, index, isFromNetModule: true);
|
|
}
|
|
else
|
|
{
|
|
AddOmittedAttributeIndex(index);
|
|
}
|
|
}
|
|
if (!arguments.HasDecodedData)
|
|
{
|
|
return null;
|
|
}
|
|
return arguments.DecodedData;
|
|
}
|
|
|
|
private void LoadAndValidateNetModuleAttributes(ref CustomAttributesBag<CSharpAttributeData> lazyNetModuleAttributesBag)
|
|
{
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, CustomAttributesBag<CSharpAttributeData>.Empty, null);
|
|
return;
|
|
}
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
|
|
ImmutableArray<string> netModuleNames;
|
|
ImmutableArray<CSharpAttributeData> netModuleAttributes = GetNetModuleAttributes(out netModuleNames);
|
|
WellKnownAttributeData val = null;
|
|
if (netModuleAttributes.Any())
|
|
{
|
|
val = ValidateAttributeUsageAndDecodeWellKnownAttributes(netModuleAttributes, netModuleNames, instance);
|
|
}
|
|
else
|
|
{
|
|
GetUniqueSourceAssemblyAttributes();
|
|
}
|
|
HashSet<NamedTypeSymbol> hashSet = null;
|
|
for (int num = _modules.Length - 1; num > 0; num--)
|
|
{
|
|
foreach (NamedTypeSymbol forwardedType in ((PEModuleSymbol)_modules[num]).GetForwardedTypes())
|
|
{
|
|
if (hashSet == null)
|
|
{
|
|
if (val == null)
|
|
{
|
|
val = (WellKnownAttributeData)(object)new CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>();
|
|
}
|
|
hashSet = ((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)val).ForwardedTypes;
|
|
if (hashSet == null)
|
|
{
|
|
hashSet = new HashSet<NamedTypeSymbol>();
|
|
((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)val).ForwardedTypes = hashSet;
|
|
}
|
|
}
|
|
if (hashSet.Add(forwardedType) && forwardedType.IsErrorType() && !instance.ReportUseSite(forwardedType, NoLocation.Singleton))
|
|
{
|
|
DiagnosticInfo errorInfo = ((ErrorTypeSymbol)forwardedType).ErrorInfo;
|
|
if (errorInfo != null)
|
|
{
|
|
instance.Add(errorInfo, NoLocation.Singleton);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
CustomAttributesBag<CSharpAttributeData> val2;
|
|
if (val != null || netModuleAttributes.Any())
|
|
{
|
|
val2 = new CustomAttributesBag<CSharpAttributeData>();
|
|
val2.SetEarlyDecodedWellKnownAttributeData((EarlyWellKnownAttributeData)null);
|
|
val2.SetDecodedWellKnownAttributeData(val);
|
|
val2.SetAttributes(netModuleAttributes);
|
|
if (val2.IsEmpty)
|
|
{
|
|
val2 = CustomAttributesBag<CSharpAttributeData>.Empty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
val2 = CustomAttributesBag<CSharpAttributeData>.Empty;
|
|
}
|
|
if (Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, val2, null) == null)
|
|
{
|
|
AddDeclarationDiagnostics(instance);
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
|
}
|
|
|
|
private CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> GetLimitedNetModuleDecodedWellKnownAttributeData(QuickAttributes attributeMatches)
|
|
{
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
return null;
|
|
}
|
|
ImmutableArray<string> netModuleNames;
|
|
ImmutableArray<CSharpAttributeData> netModuleAttributes = GetNetModuleAttributes(out netModuleNames);
|
|
WellKnownAttributeData val = null;
|
|
if (netModuleAttributes.Any())
|
|
{
|
|
val = limitedDecodeWellKnownAttributes(netModuleAttributes, netModuleNames, attributeMatches);
|
|
}
|
|
return (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)val;
|
|
void limitedDecodeWellKnownAttribute(CSharpAttributeData attribute, QuickAttributes quickAttributes, ref CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> result)
|
|
{
|
|
//IL_0007: 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_0089: 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)
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val2;
|
|
if (quickAttributes == QuickAttributes.AssemblySignatureKey && attribute.IsTargetAttribute(this, AttributeDescription.AssemblySignatureKeyAttribute))
|
|
{
|
|
if (result == null)
|
|
{
|
|
result = new CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>();
|
|
}
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> obj = result;
|
|
val2 = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
obj.AssemblySignatureKeyAttributeSetting = (string)((TypedConstant)(ref val2)).ValueInternal;
|
|
}
|
|
else if (quickAttributes == QuickAttributes.AssemblyKeyFile && attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyFileAttribute))
|
|
{
|
|
if (result == null)
|
|
{
|
|
result = new CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>();
|
|
}
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> obj2 = result;
|
|
val2 = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
obj2.AssemblyKeyFileAttributeSetting = (string)((TypedConstant)(ref val2)).ValueInternal;
|
|
}
|
|
else if (quickAttributes == QuickAttributes.AssemblyKeyName && attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyNameAttribute))
|
|
{
|
|
if (result == null)
|
|
{
|
|
result = new CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>();
|
|
}
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> obj3 = result;
|
|
val2 = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
obj3.AssemblyKeyContainerAttributeSetting = (string)((TypedConstant)(ref val2)).ValueInternal;
|
|
}
|
|
}
|
|
WellKnownAttributeData limitedDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> attributesFromNetModules, ImmutableArray<string> immutableArray, QuickAttributes attributeMatches2)
|
|
{
|
|
int length = attributesFromNetModules.Length;
|
|
HashSet<CSharpAttributeData> uniqueAttributes = null;
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> result = null;
|
|
for (int num = length - 1; num >= 0; num--)
|
|
{
|
|
CSharpAttributeData cSharpAttributeData = attributesFromNetModules[num];
|
|
if (!((AttributeData)cSharpAttributeData).HasErrors && ValidateAttributeUsageForNetModuleAttribute(cSharpAttributeData, immutableArray[num], BindingDiagnosticBag.Discarded, ref uniqueAttributes))
|
|
{
|
|
limitedDecodeWellKnownAttribute(cSharpAttributeData, attributeMatches2, ref result);
|
|
}
|
|
}
|
|
return (WellKnownAttributeData)(object)result;
|
|
}
|
|
}
|
|
|
|
private CustomAttributesBag<CSharpAttributeData> GetNetModuleAttributesBag()
|
|
{
|
|
if (_lazyNetModuleAttributesBag == null)
|
|
{
|
|
LoadAndValidateNetModuleAttributes(ref _lazyNetModuleAttributesBag);
|
|
}
|
|
return _lazyNetModuleAttributesBag;
|
|
}
|
|
|
|
internal CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> GetNetModuleDecodedWellKnownAttributeData()
|
|
{
|
|
return (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)GetNetModuleAttributesBag().DecodedWellKnownAttributeData;
|
|
}
|
|
|
|
internal ImmutableArray<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations()
|
|
{
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<SyntaxList<AttributeListSyntax>> instance = ArrayBuilder<SyntaxList<AttributeListSyntax>>.GetInstance();
|
|
ImmutableArray<SingleNamespaceDeclaration>.Enumerator enumerator = DeclaringCompilation.MergedRootDeclaration.Declarations.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
RootSingleNamespaceDeclaration rootSingleNamespaceDeclaration = (RootSingleNamespaceDeclaration)enumerator.Current;
|
|
if (rootSingleNamespaceDeclaration.HasAssemblyAttributes)
|
|
{
|
|
CompilationUnitSyntax compilationUnitSyntax = (CompilationUnitSyntax)(object)((Location)rootSingleNamespaceDeclaration.Location).SourceTree.GetRoot(default(CancellationToken));
|
|
instance.Add(compilationUnitSyntax.AttributeLists);
|
|
}
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
private void EnsureAttributesAreBound()
|
|
{
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((_lazySourceAttributesBag == null || !_lazySourceAttributesBag.IsSealed) && LoadAndValidateAttributes(OneOrMany.Create<SyntaxList<AttributeListSyntax>>(GetAttributeDeclarations()), ref _lazySourceAttributesBag))
|
|
{
|
|
_state.NotePartComplete(CompletionPart.Attributes);
|
|
}
|
|
}
|
|
|
|
private CustomAttributesBag<CSharpAttributeData> GetSourceAttributesBag()
|
|
{
|
|
EnsureAttributesAreBound();
|
|
return _lazySourceAttributesBag;
|
|
}
|
|
|
|
public sealed override ImmutableArray<CSharpAttributeData> GetAttributes()
|
|
{
|
|
ImmutableArray<CSharpAttributeData> immutableArray = GetSourceAttributesBag().Attributes;
|
|
ImmutableArray<CSharpAttributeData> attributes = GetNetModuleAttributesBag().Attributes;
|
|
if (immutableArray.Length > 0)
|
|
{
|
|
if (attributes.Length > 0)
|
|
{
|
|
immutableArray = ImmutableArrayExtensions.Concat<CSharpAttributeData>(immutableArray, attributes);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
immutableArray = attributes;
|
|
}
|
|
return immutableArray;
|
|
}
|
|
|
|
internal bool IsIndexOfOmittedAssemblyAttribute(int index)
|
|
{
|
|
if (_lazyOmittedAttributeIndices != null)
|
|
{
|
|
return _lazyOmittedAttributeIndices.Contains(index);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> GetSourceDecodedWellKnownAttributeData()
|
|
{
|
|
CustomAttributesBag<CSharpAttributeData> val = _lazySourceAttributesBag;
|
|
if (val == null || !val.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
val = GetSourceAttributesBag();
|
|
}
|
|
return (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)val.DecodedWellKnownAttributeData;
|
|
}
|
|
|
|
private CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>? GetSourceDecodedWellKnownAttributeData(QuickAttributes attribute)
|
|
{
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
CustomAttributesBag<CSharpAttributeData> lazySourceAttributesBag = _lazySourceAttributesBag;
|
|
if (lazySourceAttributesBag != null && lazySourceAttributesBag.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
return (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazySourceAttributesBag.DecodedWellKnownAttributeData;
|
|
}
|
|
lazySourceAttributesBag = null;
|
|
Func<AttributeSyntax, bool> attributeMatchesOpt = attribute switch
|
|
{
|
|
QuickAttributes.AssemblySignatureKey => isPossibleAssemblySignatureKeyAttribute,
|
|
QuickAttributes.AssemblyKeyName => isPossibleAssemblyKeyNameAttribute,
|
|
QuickAttributes.AssemblyKeyFile => isPossibleAssemblyKeyFileAttribute,
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)attribute),
|
|
};
|
|
LoadAndValidateAttributes(OneOrMany.Create<SyntaxList<AttributeListSyntax>>(GetAttributeDeclarations()), ref lazySourceAttributesBag, AttributeLocation.None, earlyDecodingOnly: false, null, attributeMatchesOpt);
|
|
return (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazySourceAttributesBag?.DecodedWellKnownAttributeData;
|
|
bool isPossibleAssemblyKeyFileAttribute(AttributeSyntax node)
|
|
{
|
|
return DeclaringCompilation.GetBinderFactory(node.SyntaxTree).GetBinder((SyntaxNode)(object)node).QuickAttributeChecker.IsPossibleMatch(node, QuickAttributes.AssemblyKeyFile);
|
|
}
|
|
bool isPossibleAssemblyKeyNameAttribute(AttributeSyntax node)
|
|
{
|
|
return DeclaringCompilation.GetBinderFactory(node.SyntaxTree).GetBinder((SyntaxNode)(object)node).QuickAttributeChecker.IsPossibleMatch(node, QuickAttributes.AssemblyKeyName);
|
|
}
|
|
bool isPossibleAssemblySignatureKeyAttribute(AttributeSyntax node)
|
|
{
|
|
return DeclaringCompilation.GetBinderFactory(node.SyntaxTree).GetBinder((SyntaxNode)(object)node).QuickAttributeChecker.IsPossibleMatch(node, QuickAttributes.AssemblySignatureKey);
|
|
}
|
|
}
|
|
|
|
internal HashSet<NamedTypeSymbol> GetForwardedTypes()
|
|
{
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
CustomAttributesBag<CSharpAttributeData> lazySourceAttributesBag = _lazySourceAttributesBag;
|
|
if (lazySourceAttributesBag != null && lazySourceAttributesBag.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
return ((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazySourceAttributesBag.DecodedWellKnownAttributeData)?.ForwardedTypes;
|
|
}
|
|
bool flag = t_forwardedTypesAttributesInProgress == null;
|
|
if (flag)
|
|
{
|
|
t_forwardedTypesAttributesInProgress = PooledHashSet<AttributeSyntax>.GetInstance();
|
|
}
|
|
try
|
|
{
|
|
lazySourceAttributesBag = null;
|
|
LoadAndValidateAttributes(OneOrMany.Create<SyntaxList<AttributeListSyntax>>(GetAttributeDeclarations()), ref lazySourceAttributesBag, AttributeLocation.None, earlyDecodingOnly: false, null, IsPossibleForwardedTypesAttribute, BeforePossibleForwardedTypesAttributePartBound, AfterPossibleForwardedTypesAttributePartBound);
|
|
return ((CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)lazySourceAttributesBag?.DecodedWellKnownAttributeData)?.ForwardedTypes;
|
|
}
|
|
finally
|
|
{
|
|
if (flag)
|
|
{
|
|
PooledHashSet<AttributeSyntax> obj = t_forwardedTypesAttributesInProgress;
|
|
t_forwardedTypesAttributesInProgress = null;
|
|
obj.Free();
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void BeforePossibleForwardedTypesAttributePartBound(AttributeSyntax node)
|
|
{
|
|
((HashSet<AttributeSyntax>)(object)t_forwardedTypesAttributesInProgress).Add(node);
|
|
}
|
|
|
|
private static void AfterPossibleForwardedTypesAttributePartBound(AttributeSyntax node)
|
|
{
|
|
((HashSet<AttributeSyntax>)(object)t_forwardedTypesAttributesInProgress).Remove(node);
|
|
}
|
|
|
|
private bool IsPossibleForwardedTypesAttribute(AttributeSyntax node)
|
|
{
|
|
if (DeclaringCompilation.GetBinderFactory(node.SyntaxTree).GetBinder((SyntaxNode)(object)node).QuickAttributeChecker.IsPossibleMatch(node, QuickAttributes.TypeForwardedTo) && !((HashSet<AttributeSyntax>)(object)t_forwardedTypesAttributesInProgress).Contains(node))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static IEnumerable<SecurityAttribute> GetSecurityAttributes(CustomAttributesBag<CSharpAttributeData> attributesBag)
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> val = (CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>)(object)attributesBag.DecodedWellKnownAttributeData;
|
|
if (val == null)
|
|
{
|
|
yield break;
|
|
}
|
|
SecurityWellKnownAttributeData securityInformation = val.SecurityInformation;
|
|
if (securityInformation == null)
|
|
{
|
|
yield break;
|
|
}
|
|
foreach (SecurityAttribute securityAttribute in securityInformation.GetSecurityAttributes<CSharpAttributeData>(attributesBag.Attributes))
|
|
{
|
|
yield return securityAttribute;
|
|
}
|
|
}
|
|
|
|
internal IEnumerable<SecurityAttribute> GetSecurityAttributes()
|
|
{
|
|
foreach (SecurityAttribute securityAttribute in GetSecurityAttributes(GetSourceAttributesBag()))
|
|
{
|
|
yield return securityAttribute;
|
|
}
|
|
foreach (SecurityAttribute securityAttribute2 in GetSecurityAttributes(GetNetModuleAttributesBag()))
|
|
{
|
|
yield return securityAttribute2;
|
|
}
|
|
if (!_compilation.Options.AllowUnsafe || _compilation.GetWellKnownType((WellKnownType)236) is MissingMetadataTypeSymbol || _compilation.GetWellKnownType((WellKnownType)239) is MissingMetadataTypeSymbol)
|
|
{
|
|
yield break;
|
|
}
|
|
NamedTypeSymbol wellKnownType = _compilation.GetWellKnownType((WellKnownType)237);
|
|
if (!(wellKnownType is MissingMetadataTypeSymbol))
|
|
{
|
|
FieldSymbol fieldSymbol = (FieldSymbol)_compilation.GetWellKnownTypeMember((WellKnownMember)135);
|
|
object obj = (((object)fieldSymbol == null || fieldSymbol.HasUseSiteError) ? ((object)0) : fieldSymbol.ConstantValue);
|
|
TypedConstant item = default(TypedConstant);
|
|
((TypedConstant)(ref item))._002Ector((ITypeSymbolInternal)(object)wellKnownType, (TypedConstantKind)2, obj);
|
|
NamedTypeSymbol specialType = _compilation.GetSpecialType((SpecialType)7);
|
|
TypedConstant value = default(TypedConstant);
|
|
((TypedConstant)(ref value))._002Ector((ITypeSymbolInternal)(object)specialType, (TypedConstantKind)1, (object)true);
|
|
SynthesizedAttributeData synthesizedAttributeData = _compilation.TrySynthesizeAttribute((WellKnownMember)136, ImmutableArray.Create<TypedConstant>(item), ImmutableArray.Create(new KeyValuePair<WellKnownMember, TypedConstant>((WellKnownMember)137, value)));
|
|
if (synthesizedAttributeData != null)
|
|
{
|
|
yield return new SecurityAttribute((DeclarativeSecurityAction)(int)obj, (ICustomAttribute)(object)synthesizedAttributeData);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal override ImmutableArray<AssemblySymbol> GetNoPiaResolutionAssemblies()
|
|
{
|
|
return _modules[0].GetReferencedAssemblySymbols();
|
|
}
|
|
|
|
internal override void SetNoPiaResolutionAssemblies(ImmutableArray<AssemblySymbol> assemblies)
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs", 1848);
|
|
}
|
|
|
|
internal override ImmutableArray<AssemblySymbol> GetLinkedReferencedAssemblies()
|
|
{
|
|
return default(ImmutableArray<AssemblySymbol>);
|
|
}
|
|
|
|
internal override void SetLinkedReferencedAssemblies(ImmutableArray<AssemblySymbol> assemblies)
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs", 1862);
|
|
}
|
|
|
|
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
|
{
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0194: Invalid comparison between Unknown and I4
|
|
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
|
|
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
|
|
bool num = EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind);
|
|
if (ContainsExtensionMethods())
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.TrySynthesizeAttribute((WellKnownMember)111));
|
|
}
|
|
if (!num && !Modules.Any((ModuleSymbol m) => m.HasAssemblyCompilationRelaxationsAttribute) && !(_compilation.GetWellKnownType((WellKnownType)176) is MissingMetadataTypeSymbol))
|
|
{
|
|
NamedTypeSymbol specialType = _compilation.GetSpecialType((SpecialType)13);
|
|
TypedConstant item = default(TypedConstant);
|
|
((TypedConstant)(ref item))._002Ector((ITypeSymbolInternal)(object)specialType, (TypedConstantKind)1, (object)8);
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.TrySynthesizeAttribute((WellKnownMember)114, ImmutableArray.Create<TypedConstant>(item)));
|
|
}
|
|
if (!num && !Modules.Any((ModuleSymbol m) => m.HasAssemblyRuntimeCompatibilityAttribute) && !(_compilation.GetWellKnownType((WellKnownType)177) is MissingMetadataTypeSymbol))
|
|
{
|
|
NamedTypeSymbol specialType2 = _compilation.GetSpecialType((SpecialType)7);
|
|
TypedConstant value = default(TypedConstant);
|
|
((TypedConstant)(ref value))._002Ector((ITypeSymbolInternal)(object)specialType2, (TypedConstantKind)1, (object)true);
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.TrySynthesizeAttribute((WellKnownMember)115, ImmutableArray<TypedConstant>.Empty, ImmutableArray.Create(new KeyValuePair<WellKnownMember, TypedConstant>((WellKnownMember)116, value))));
|
|
}
|
|
if (!num && !HasDebuggableAttribute)
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.SynthesizeDebuggableAttribute());
|
|
}
|
|
if ((int)((CompilationOptions)_compilation.Options).OutputKind == 3)
|
|
{
|
|
if (!string.IsNullOrEmpty(((CompilationOptions)_compilation.Options).CryptoKeyContainer) && (object)AssemblyKeyContainerAttributeSetting == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
NamedTypeSymbol specialType3 = _compilation.GetSpecialType((SpecialType)20);
|
|
TypedConstant item2 = default(TypedConstant);
|
|
((TypedConstant)(ref item2))._002Ector((ITypeSymbolInternal)(object)specialType3, (TypedConstantKind)1, (object)((CompilationOptions)_compilation.Options).CryptoKeyContainer);
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.TrySynthesizeAttribute((WellKnownMember)46, ImmutableArray.Create<TypedConstant>(item2)));
|
|
}
|
|
if (!string.IsNullOrEmpty(((CompilationOptions)_compilation.Options).CryptoKeyFile) && (object)AssemblyKeyFileAttributeSetting == WellKnownAttributeData.StringMissingValue)
|
|
{
|
|
NamedTypeSymbol specialType4 = _compilation.GetSpecialType((SpecialType)20);
|
|
TypedConstant item3 = default(TypedConstant);
|
|
((TypedConstant)(ref item3))._002Ector((ITypeSymbolInternal)(object)specialType4, (TypedConstantKind)1, (object)((CompilationOptions)_compilation.Options).CryptoKeyFile);
|
|
Symbol.AddSynthesizedAttribute(ref attributes, _compilation.TrySynthesizeAttribute((WellKnownMember)45, ImmutableArray.Create<TypedConstant>(item3)));
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool ContainsExtensionMethods()
|
|
{
|
|
//IL_0001: 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_0019: 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)
|
|
if (!ThreeStateHelpers.HasValue(_lazyContainsExtensionMethods))
|
|
{
|
|
_lazyContainsExtensionMethods = ThreeStateHelpers.ToThreeState(ContainsExtensionMethods(_modules));
|
|
}
|
|
return ThreeStateHelpers.Value(_lazyContainsExtensionMethods);
|
|
}
|
|
|
|
private static bool ContainsExtensionMethods(ImmutableArray<ModuleSymbol> modules)
|
|
{
|
|
ImmutableArray<ModuleSymbol>.Enumerator enumerator = modules.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
if (ContainsExtensionMethods(enumerator.Current.GlobalNamespace))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool ContainsExtensionMethods(NamespaceSymbol ns)
|
|
{
|
|
//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_0023: Invalid comparison between Unknown and I4
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Invalid comparison between Unknown and I4
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<Symbol>.Enumerator enumerator = ns.GetMembersUnordered().GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
Symbol current = enumerator.Current;
|
|
SymbolKind kind = current.Kind;
|
|
if ((int)kind != 11)
|
|
{
|
|
if ((int)kind != 12)
|
|
{
|
|
throw ExceptionUtilities.UnexpectedValue((object)current.Kind);
|
|
}
|
|
if (ContainsExtensionMethods((NamespaceSymbol)current))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else if (((NamedTypeSymbol)current).MightContainExtensionMethods)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void CheckOptimisticIVTAccessGrants(BindingDiagnosticBag bag)
|
|
{
|
|
//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_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002c: Invalid comparison between Unknown and I4
|
|
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Invalid comparison between Unknown and I4
|
|
ConcurrentDictionary<AssemblySymbol, bool> optimisticallyGrantedInternalsAccess = _optimisticallyGrantedInternalsAccess;
|
|
if (optimisticallyGrantedInternalsAccess == null)
|
|
{
|
|
return;
|
|
}
|
|
foreach (AssemblySymbol key in optimisticallyGrantedInternalsAccess.Keys)
|
|
{
|
|
IVTConclusion val = MakeFinalIVTDetermination(key);
|
|
if ((int)val == 2)
|
|
{
|
|
bag.Add(ErrorCode.ERR_FriendRefNotEqualToThis, NoLocation.Singleton, key.Identity, Identity);
|
|
}
|
|
else if ((int)val == 1)
|
|
{
|
|
bag.Add(ErrorCode.ERR_FriendRefSigningMismatch, NoLocation.Singleton, key.Identity);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal override IEnumerable<ImmutableArray<byte>> GetInternalsVisibleToPublicKeys(string simpleName)
|
|
{
|
|
EnsureAttributesAreBound();
|
|
if (_lazyInternalsVisibleToMap == null)
|
|
{
|
|
return SpecializedCollections.EmptyEnumerable<ImmutableArray<byte>>();
|
|
}
|
|
ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>> value = null;
|
|
_lazyInternalsVisibleToMap.TryGetValue(simpleName, out value);
|
|
if (value == null)
|
|
{
|
|
return SpecializedCollections.EmptyEnumerable<ImmutableArray<byte>>();
|
|
}
|
|
return value.Keys;
|
|
}
|
|
|
|
internal override IEnumerable<string> GetInternalsVisibleToAssemblyNames()
|
|
{
|
|
EnsureAttributesAreBound();
|
|
if (_lazyInternalsVisibleToMap == null)
|
|
{
|
|
return SpecializedCollections.EmptyEnumerable<string>();
|
|
}
|
|
return _lazyInternalsVisibleToMap.Keys;
|
|
}
|
|
|
|
internal override bool AreInternalsVisibleToThisAssembly(AssemblySymbol potentialGiverOfAccess)
|
|
{
|
|
//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)
|
|
//IL_0056: 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_005b: Invalid comparison between Unknown and I4
|
|
if (_lazyStrongNameKeys == null && (object)t_assemblyForWhichCurrentThreadIsComputingKeys != null)
|
|
{
|
|
if (!EnumerableExtensions.IsEmpty<ImmutableArray<byte>>(potentialGiverOfAccess.GetInternalsVisibleToPublicKeys(Name)))
|
|
{
|
|
if (_optimisticallyGrantedInternalsAccess == null)
|
|
{
|
|
Interlocked.CompareExchange(ref _optimisticallyGrantedInternalsAccess, new ConcurrentDictionary<AssemblySymbol, bool>(), null);
|
|
}
|
|
_optimisticallyGrantedInternalsAccess.TryAdd(potentialGiverOfAccess, value: true);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
IVTConclusion val = MakeFinalIVTDetermination(potentialGiverOfAccess);
|
|
if ((int)val != 0)
|
|
{
|
|
return (int)val == 1;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private AssemblyIdentity ComputeIdentity()
|
|
{
|
|
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005e: Expected O, but got Unknown
|
|
return new AssemblyIdentity(_assemblySimpleName, VersionHelper.GenerateVersionFromPatternAndCurrentTime(((CompilationOptions)_compilation.Options).CurrentLocalTime, AssemblyVersionAttributeSetting), AssemblyCultureAttributeSetting, StrongNameKeys.PublicKey, !StrongNameKeys.PublicKey.IsDefault, (AssemblyFlags & AssemblyFlags.Retargetable) == AssemblyFlags.Retargetable);
|
|
}
|
|
|
|
private static Location GetAssemblyAttributeLocationForDiagnostic(AttributeSyntax attributeSyntaxOpt)
|
|
{
|
|
if (attributeSyntaxOpt == null)
|
|
{
|
|
return NoLocation.Singleton;
|
|
}
|
|
return ((SyntaxNode)attributeSyntaxOpt).Location;
|
|
}
|
|
|
|
private void DecodeTypeForwardedToAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
|
|
{
|
|
//IL_001c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ff: Invalid comparison between Unknown and I4
|
|
BindingDiagnosticBag bindingDiagnosticBag = (BindingDiagnosticBag)(object)arguments.Diagnostics;
|
|
TypedConstant val = ((AttributeData)arguments.Attribute).CommonConstructorArguments[0];
|
|
TypeSymbol typeSymbol = (TypeSymbol)((TypedConstant)(ref val)).ValueInternal;
|
|
if ((object)typeSymbol == null)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidFwdType, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt));
|
|
return;
|
|
}
|
|
UseSiteInfo<AssemblySymbol> useSiteInfo = typeSymbol.GetUseSiteInfo();
|
|
DiagnosticInfo diagnosticInfo = useSiteInfo.DiagnosticInfo;
|
|
if ((diagnosticInfo == null || diagnosticInfo.Code != 7003) && ((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(useSiteInfo, (useSiteInfo.DiagnosticInfo != null) ? GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt) : Location.None))
|
|
{
|
|
return;
|
|
}
|
|
if (typeSymbol.ContainingAssembly == this)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_ForwardedTypeInThisAssembly, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), typeSymbol);
|
|
return;
|
|
}
|
|
if ((object)typeSymbol.ContainingType != null)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_ForwardedTypeIsNested, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), typeSymbol, typeSymbol.ContainingType);
|
|
return;
|
|
}
|
|
if ((int)typeSymbol.Kind != 11)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidFwdType, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt));
|
|
return;
|
|
}
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
HashSet<NamedTypeSymbol> forwardedTypes = orCreateData.ForwardedTypes;
|
|
if (forwardedTypes == null)
|
|
{
|
|
forwardedTypes = new HashSet<NamedTypeSymbol> { (NamedTypeSymbol)typeSymbol };
|
|
orCreateData.ForwardedTypes = forwardedTypes;
|
|
}
|
|
else if (!forwardedTypes.Add((NamedTypeSymbol)typeSymbol))
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_DuplicateTypeForwarder, GetAssemblyAttributeLocationForDiagnostic(arguments.AttributeSyntaxOpt), typeSymbol);
|
|
}
|
|
}
|
|
|
|
private void DecodeOneInternalsVisibleToAttribute(AttributeSyntax nodeOpt, CSharpAttributeData attrData, BindingDiagnosticBag diagnostics, int index, ref ConcurrentDictionary<string, ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>>> lazyInternalsVisibleToMap)
|
|
{
|
|
//IL_000b: 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)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
|
TypedConstant val = ((AttributeData)attrData).CommonConstructorArguments[0];
|
|
string text = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
if (text == null)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_CannotPassNullForFriendAssembly, GetAssemblyAttributeLocationForDiagnostic(nodeOpt));
|
|
return;
|
|
}
|
|
AssemblyIdentity val2 = default(AssemblyIdentity);
|
|
AssemblyIdentityParts val3 = default(AssemblyIdentityParts);
|
|
if (!AssemblyIdentity.TryParseDisplayName(text, ref val2, ref val3))
|
|
{
|
|
diagnostics.Add(ErrorCode.WRN_InvalidAssemblyName, GetAssemblyAttributeLocationForDiagnostic(nodeOpt), text);
|
|
AddOmittedAttributeIndex(index);
|
|
return;
|
|
}
|
|
if ((val3 & -194) != 0)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_FriendAssemblyBadArgs, GetAssemblyAttributeLocationForDiagnostic(nodeOpt), text);
|
|
return;
|
|
}
|
|
if (lazyInternalsVisibleToMap == null)
|
|
{
|
|
Interlocked.CompareExchange(ref lazyInternalsVisibleToMap, new ConcurrentDictionary<string, ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>>>(StringComparer.OrdinalIgnoreCase), null);
|
|
}
|
|
Tuple<Location, string> value = null;
|
|
if (val2.PublicKey.IsEmpty)
|
|
{
|
|
value = new Tuple<Location, string>(GetAssemblyAttributeLocationForDiagnostic(nodeOpt), text);
|
|
}
|
|
ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>> value2 = null;
|
|
if (lazyInternalsVisibleToMap.TryGetValue(val2.Name, out value2))
|
|
{
|
|
value2.TryAdd(val2.PublicKey, value);
|
|
return;
|
|
}
|
|
value2 = new ConcurrentDictionary<ImmutableArray<byte>, Tuple<Location, string>>();
|
|
value2.TryAdd(val2.PublicKey, value);
|
|
lazyInternalsVisibleToMap.TryAdd(val2.Name, value2);
|
|
}
|
|
|
|
protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
|
|
{
|
|
DecodeWellKnownAttribute(ref arguments, arguments.Index, isFromNetModule: false);
|
|
}
|
|
|
|
private void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, int index, bool isFromNetModule)
|
|
{
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0039: 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_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)
|
|
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0107: 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)
|
|
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0446: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0509: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0523: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_057b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0597: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0607: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_068c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0662: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0667: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0747: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_070b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0710: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpAttributeData attribute = arguments.Attribute;
|
|
BindingDiagnosticBag bindingDiagnosticBag = (BindingDiagnosticBag)(object)arguments.Diagnostics;
|
|
TypedConstant val;
|
|
int targetAttributeSignatureIndex;
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.InternalsVisibleToAttribute))
|
|
{
|
|
DecodeOneInternalsVisibleToAttribute(arguments.AttributeSyntaxOpt, attribute, bindingDiagnosticBag, index, ref _lazyInternalsVisibleToMap);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblySignatureKeyAttribute))
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
string text = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblySignatureKeyAttributeSetting = text;
|
|
if (!StrongNameKeys.IsValidPublicKeyString(text))
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidSignaturePublicKey, ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
|
|
}
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyFileAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData.AssemblyKeyFileAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyKeyNameAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData2 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData2.AssemblyKeyContainerAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyDelaySignAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData3 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData3.AssemblyDelaySignAttributeSetting = (ThreeState)((!(bool)((TypedConstant)(ref val)).ValueInternal) ? 1 : 2);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyVersionAttribute))
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
string text2 = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
Version assemblyVersionAttributeSetting = default(Version);
|
|
if (!VersionHelper.TryParseAssemblyVersion(text2, !((Compilation)_compilation).IsEmitDeterministic, ref assemblyVersionAttributeSetting))
|
|
{
|
|
Location attributeArgumentSyntaxLocation = ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt);
|
|
bool flag = ((Compilation)_compilation).IsEmitDeterministic && (text2?.Contains('*') ?? false);
|
|
bindingDiagnosticBag.Add(flag ? ErrorCode.ERR_InvalidVersionFormatDeterministic : ErrorCode.ERR_InvalidVersionFormat, attributeArgumentSyntaxLocation, text2 ?? "<null>");
|
|
}
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblyVersionAttributeSetting = assemblyVersionAttributeSetting;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyFileVersionAttribute))
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
string text3 = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
Version version = default(Version);
|
|
if (!VersionHelper.TryParse(text3, ref version))
|
|
{
|
|
Location attributeArgumentSyntaxLocation2 = ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt);
|
|
bindingDiagnosticBag.Add(ErrorCode.WRN_InvalidVersionFormat, attributeArgumentSyntaxLocation2, text3 ?? "<null>");
|
|
}
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblyFileVersionAttributeSetting = text3;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyTitleAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData4 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData4.AssemblyTitleAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyDescriptionAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData5 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData5.AssemblyDescriptionAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCultureAttribute))
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
string text4 = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
if (!string.IsNullOrEmpty(text4))
|
|
{
|
|
if (EnumBounds.IsApplication(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidAssemblyCultureForExe, ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
|
|
}
|
|
else if (!AssemblyIdentity.IsValidCultureName(text4))
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidAssemblyCulture, ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt));
|
|
text4 = null;
|
|
}
|
|
}
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblyCultureAttributeSetting = text4;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCompanyAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData6 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData6.AssemblyCompanyAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyProductAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData7 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData7.AssemblyProductAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyInformationalVersionAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData8 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData8.AssemblyInformationalVersionAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.SatelliteContractVersionAttribute))
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
string text5 = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
Version version2 = default(Version);
|
|
if (!VersionHelper.TryParseAssemblyVersion(text5, false, ref version2))
|
|
{
|
|
Location attributeArgumentSyntaxLocation3 = ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(0, arguments.AttributeSyntaxOpt);
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidVersionFormat2, attributeArgumentSyntaxLocation3, text5 ?? "<null>");
|
|
}
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyCopyrightAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData9 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData9.AssemblyCopyrightAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.AssemblyTrademarkAttribute))
|
|
{
|
|
CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> orCreateData10 = arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>();
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
orCreateData10.AssemblyTrademarkAttributeSetting = (string)((TypedConstant)(ref val)).ValueInternal;
|
|
}
|
|
else if ((targetAttributeSignatureIndex = attribute.GetTargetAttributeSignatureIndex(this, AttributeDescription.AssemblyFlagsAttribute)) != -1)
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
object valueInternal = ((TypedConstant)(ref val)).ValueInternal;
|
|
AssemblyFlags assemblyFlagsAttributeSetting = ((targetAttributeSignatureIndex != 0 && targetAttributeSignatureIndex != 1) ? ((AssemblyFlags)(uint)valueInternal) : ((AssemblyFlags)(AssemblyNameFlags)valueInternal));
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblyFlagsAttributeSetting = assemblyFlagsAttributeSetting;
|
|
}
|
|
else if (attribute.IsSecurityAttribute(_compilation))
|
|
{
|
|
attribute.DecodeSecurityAttribute<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>((Symbol)this, _compilation, ref arguments);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.ClassInterfaceAttribute))
|
|
{
|
|
attribute.DecodeClassInterfaceAttribute(arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.TypeLibVersionAttribute))
|
|
{
|
|
ValidateIntegralAttributeNonNegativeArguments(attribute, arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.ComCompatibleVersionAttribute))
|
|
{
|
|
ValidateIntegralAttributeNonNegativeArguments(attribute, arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.GuidAttribute))
|
|
{
|
|
attribute.DecodeGuidAttribute(arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CompilationRelaxationsAttribute))
|
|
{
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().HasCompilationRelaxationsAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.ReferenceAssemblyAttribute))
|
|
{
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().HasReferenceAssemblyAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.RuntimeCompatibilityAttribute))
|
|
{
|
|
bool runtimeCompatibilityWrapNonExceptionThrows = true;
|
|
ImmutableArray<KeyValuePair<string, TypedConstant>>.Enumerator enumerator = ((AttributeData)attribute).CommonNamedArguments.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
KeyValuePair<string, TypedConstant> current = enumerator.Current;
|
|
if (current.Key == "WrapNonExceptionThrows")
|
|
{
|
|
val = current.Value;
|
|
runtimeCompatibilityWrapNonExceptionThrows = ((TypedConstant)(ref val)).DecodeValue<bool>((SpecialType)7);
|
|
}
|
|
}
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().RuntimeCompatibilityWrapNonExceptionThrows = runtimeCompatibilityWrapNonExceptionThrows;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.DebuggableAttribute))
|
|
{
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().HasDebuggableAttribute = true;
|
|
}
|
|
else if (!isFromNetModule && attribute.IsTargetAttribute(this, AttributeDescription.TypeForwardedToAttribute))
|
|
{
|
|
DecodeTypeForwardedToAttribute(ref arguments);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CaseSensitiveExtensionAttribute))
|
|
{
|
|
if (arguments.AttributeSyntaxOpt != null)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_ExplicitExtension, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
}
|
|
}
|
|
else if ((targetAttributeSignatureIndex = attribute.GetTargetAttributeSignatureIndex(this, AttributeDescription.AssemblyAlgorithmIdAttribute)) != -1)
|
|
{
|
|
val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
object valueInternal2 = ((TypedConstant)(ref val)).ValueInternal;
|
|
AssemblyHashAlgorithm value = ((targetAttributeSignatureIndex != 0) ? ((AssemblyHashAlgorithm)(uint)valueInternal2) : ((AssemblyHashAlgorithm)valueInternal2));
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().AssemblyAlgorithmIdAttributeSetting = value;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.ExperimentalAttribute))
|
|
{
|
|
ObsoleteAttributeData experimentalAttributeData = ((AttributeData)attribute).DecodeExperimentalAttribute();
|
|
arguments.GetOrCreateData<CommonAssemblyWellKnownAttributeData<NamedTypeSymbol>>().ExperimentalAttributeData = experimentalAttributeData;
|
|
}
|
|
}
|
|
|
|
private static void ValidateIntegralAttributeNonNegativeArguments(CSharpAttributeData attribute, AttributeSyntax nodeOpt, BindingDiagnosticBag diagnostics)
|
|
{
|
|
int length = ((AttributeData)attribute).CommonConstructorArguments.Length;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
if (((AttributeData)attribute).GetConstructorArgument<int>(i, (SpecialType)13) < 0)
|
|
{
|
|
Location attributeArgumentSyntaxLocation = ((AttributeData)(object)attribute).GetAttributeArgumentSyntaxLocation(i, nodeOpt);
|
|
diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntaxLocation, (nodeOpt != null) ? nodeOpt.GetErrorDisplayName() : "");
|
|
}
|
|
}
|
|
}
|
|
|
|
internal void NoteFieldAccess(FieldSymbol field, bool read, bool write)
|
|
{
|
|
if (!(field.ContainingType is SourceMemberContainerTypeSymbol sourceMemberContainerTypeSymbol))
|
|
{
|
|
return;
|
|
}
|
|
sourceMemberContainerTypeSymbol.EnsureFieldDefinitionsNoted();
|
|
if (_unusedFieldWarnings.IsDefault)
|
|
{
|
|
if (read)
|
|
{
|
|
_unreadFields.Remove(field);
|
|
}
|
|
if (write)
|
|
{
|
|
_unassignedFieldsMap.TryRemove(field, out var _);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal void NoteFieldDefinition(FieldSymbol field, bool isInternal, bool isUnread)
|
|
{
|
|
_unassignedFieldsMap.TryAdd(field, isInternal);
|
|
if (isUnread)
|
|
{
|
|
_unreadFields.Add(field);
|
|
}
|
|
}
|
|
|
|
internal override bool IsNetModule()
|
|
{
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
return EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind);
|
|
}
|
|
|
|
internal ImmutableArray<Diagnostic> GetUnusedFieldWarnings(CancellationToken cancellationToken)
|
|
{
|
|
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ea: Invalid comparison between Unknown and I4
|
|
if (_unusedFieldWarnings.IsDefault)
|
|
{
|
|
ForceComplete(null, cancellationToken);
|
|
DiagnosticBag instance = DiagnosticBag.GetInstance();
|
|
bool flag = InternalsAreVisible || IsNetModule();
|
|
HashSet<FieldSymbol> hashSet = null;
|
|
int length;
|
|
foreach (FieldSymbol key in _unassignedFieldsMap.Keys)
|
|
{
|
|
_unassignedFieldsMap.TryGetValue(key, out var value);
|
|
if ((value && flag) || !key.CanBeReferencedByName || !(key.ContainingType is SourceNamedTypeSymbol sourceNamedTypeSymbol) || key is TupleErrorFieldSymbol)
|
|
{
|
|
continue;
|
|
}
|
|
bool flag2 = _unreadFields.Contains(key);
|
|
if (flag2)
|
|
{
|
|
if (hashSet == null)
|
|
{
|
|
hashSet = new HashSet<FieldSymbol>();
|
|
}
|
|
hashSet.Add(key);
|
|
}
|
|
if (sourceNamedTypeSymbol.HasStructLayoutAttribute || sourceNamedTypeSymbol.HasInlineArrayAttribute(out length))
|
|
{
|
|
continue;
|
|
}
|
|
Symbol associatedSymbol = key.AssociatedSymbol;
|
|
if ((object)associatedSymbol != null && (int)associatedSymbol.Kind == 5)
|
|
{
|
|
if (flag2)
|
|
{
|
|
instance.Add(ErrorCode.WRN_UnreferencedEvent, associatedSymbol.GetFirstLocationOrNone(), associatedSymbol);
|
|
}
|
|
}
|
|
else if (flag2)
|
|
{
|
|
instance.Add(ErrorCode.WRN_UnreferencedField, key.GetFirstLocationOrNone(), key);
|
|
}
|
|
else
|
|
{
|
|
instance.Add(ErrorCode.WRN_UnassignedInternalField, key.GetFirstLocationOrNone(), key, DefaultValue(key.Type));
|
|
}
|
|
}
|
|
KeyEnumerator<FieldSymbol> enumerator2 = _unreadFields.GetEnumerator();
|
|
while (enumerator2.MoveNext())
|
|
{
|
|
FieldSymbol current2 = enumerator2.Current;
|
|
if ((hashSet == null || !hashSet.Contains(current2)) && current2.CanBeReferencedByName && current2.ContainingType is SourceNamedTypeSymbol { HasStructLayoutAttribute: false } sourceNamedTypeSymbol2 && !sourceNamedTypeSymbol2.HasInlineArrayAttribute(out length))
|
|
{
|
|
instance.Add(ErrorCode.WRN_UnreferencedFieldAssg, current2.GetFirstLocationOrNone(), current2);
|
|
}
|
|
}
|
|
ImmutableInterlocked.InterlockedInitialize(ref _unusedFieldWarnings, instance.ToReadOnlyAndFree());
|
|
}
|
|
return _unusedFieldWarnings;
|
|
}
|
|
|
|
private static string DefaultValue(TypeSymbol type)
|
|
{
|
|
//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_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Invalid comparison between Unknown and I4
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Invalid comparison between Unknown and I4
|
|
if (type.IsReferenceType)
|
|
{
|
|
return "null";
|
|
}
|
|
SpecialType specialType = type.SpecialType;
|
|
if ((int)specialType != 7)
|
|
{
|
|
if (specialType - 9 <= 10)
|
|
{
|
|
return "0";
|
|
}
|
|
return "";
|
|
}
|
|
return "false";
|
|
}
|
|
|
|
internal override NamedTypeSymbol? TryLookupForwardedMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol>? visitedAssemblies)
|
|
{
|
|
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
|
|
int num = ((MetadataTypeName)(ref emittedName)).ForcedArity;
|
|
if (((MetadataTypeName)(ref emittedName)).UseCLSCompliantNameArityEncoding)
|
|
{
|
|
if (num == -1)
|
|
{
|
|
num = ((MetadataTypeName)(ref emittedName)).InferredArity;
|
|
}
|
|
else if (num != ((MetadataTypeName)(ref emittedName)).InferredArity)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
if (_lazyForwardedTypesFromSource == null)
|
|
{
|
|
HashSet<NamedTypeSymbol> forwardedTypes = GetForwardedTypes();
|
|
IDictionary<string, NamedTypeSymbol> dictionary;
|
|
if (forwardedTypes != null)
|
|
{
|
|
dictionary = new Dictionary<string, NamedTypeSymbol>((IEqualityComparer<string>?)StringOrdinalComparer.Instance);
|
|
foreach (NamedTypeSymbol item in forwardedTypes)
|
|
{
|
|
NamedTypeSymbol originalDefinition = item.OriginalDefinition;
|
|
string key = MetadataHelpers.BuildQualifiedName(originalDefinition.ContainingSymbol.ToDisplayString(SymbolDisplayFormat.QualifiedNameOnlyFormat), originalDefinition.MetadataName);
|
|
dictionary[key] = originalDefinition;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dictionary = SpecializedCollections.EmptyDictionary<string, NamedTypeSymbol>();
|
|
}
|
|
_lazyForwardedTypesFromSource = dictionary;
|
|
}
|
|
if (_lazyForwardedTypesFromSource.TryGetValue(((MetadataTypeName)(ref emittedName)).FullName, out NamedTypeSymbol value))
|
|
{
|
|
if ((num == -1 || value.Arity == num) && (!((MetadataTypeName)(ref emittedName)).UseCLSCompliantNameArityEncoding || value.Arity == 0 || value.MangleName))
|
|
{
|
|
return value;
|
|
}
|
|
}
|
|
else if (!EnumBounds.IsNetModule(((CompilationOptions)_compilation.Options).OutputKind))
|
|
{
|
|
for (int num2 = _modules.Length - 1; num2 > 0; num2--)
|
|
{
|
|
PEModuleSymbol pEModuleSymbol = (PEModuleSymbol)_modules[num2];
|
|
var (assemblySymbol, assemblySymbol2) = pEModuleSymbol.GetAssembliesForForwardedType(ref emittedName);
|
|
if ((object)assemblySymbol != null)
|
|
{
|
|
if ((object)assemblySymbol2 != null)
|
|
{
|
|
return CreateMultipleForwardingErrorTypeSymbol(ref emittedName, pEModuleSymbol, assemblySymbol, assemblySymbol2);
|
|
}
|
|
if (visitedAssemblies != null && ((IEnumerable<AssemblySymbol>)visitedAssemblies).Contains(assemblySymbol))
|
|
{
|
|
return CreateCycleInTypeForwarderErrorTypeSymbol(ref emittedName);
|
|
}
|
|
visitedAssemblies = new ConsList<AssemblySymbol>((AssemblySymbol)this, visitedAssemblies ?? ConsList<AssemblySymbol>.Empty);
|
|
return assemblySymbol.LookupDeclaredOrForwardedTopLevelMetadataType(ref emittedName, visitedAssemblies);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
internal override IEnumerable<NamedTypeSymbol> GetAllTopLevelForwardedTypes()
|
|
{
|
|
return PEModuleBuilder.GetForwardedTypes(this, null);
|
|
}
|
|
|
|
public override AssemblyMetadata GetMetadata()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected override ISymbol CreateISymbol()
|
|
{
|
|
return (ISymbol)(object)new Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.SourceAssemblySymbol(this);
|
|
}
|
|
}
|