Files

1638 lines
74 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
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.Threading;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Emit.NoPia;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Symbols;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Emit;
internal abstract class PEModuleBuilder : PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>
{
protected readonly ConcurrentDictionary<Symbol, IModuleReference> AssemblyOrModuleSymbolToModuleRefMap = new ConcurrentDictionary<Symbol, IModuleReference>();
private readonly ConcurrentDictionary<Symbol, object> _genericInstanceMap = new ConcurrentDictionary<Symbol, object>(SymbolEqualityComparer.ConsiderEverything);
private readonly ConcurrentDictionary<ImportChain, ImmutableArray<UsedNamespaceOrType>> _translatedImportsMap = new ConcurrentDictionary<ImportChain, ImmutableArray<UsedNamespaceOrType>>((IEqualityComparer<ImportChain>?)ReferenceEqualityComparer.Instance);
private readonly ConcurrentSet<TypeSymbol> _reportedErrorTypesMap = new ConcurrentSet<TypeSymbol>();
private readonly EmbeddedTypesManager _embeddedTypesManagerOpt;
private readonly string _metadataName;
private ImmutableArray<ExportedType> _lazyExportedTypes;
private Dictionary<FieldSymbol, NamedTypeSymbol> _fixedImplementationTypes;
private int _needsGeneratedAttributes;
private bool _needsGeneratedAttributes_IsFrozen;
public override EmbeddedTypesManager EmbeddedTypesManagerOpt => _embeddedTypesManagerOpt;
public override string Name => _metadataName;
internal sealed override string ModuleName => _metadataName;
internal sealed override AssemblySymbol CorLibrary => base.SourceModule.ContainingSourceAssembly.CorLibrary;
public sealed override bool GenerateVisualBasicStylePdb => false;
public sealed override IEnumerable<string> LinkedAssembliesDebugInfo => SpecializedCollections.EmptyEnumerable<string>();
public sealed override string DefaultNamespace => null;
internal virtual bool IgnoreAccessibility => false;
internal EmbeddableAttributes GetNeedsGeneratedAttributes()
{
_needsGeneratedAttributes_IsFrozen = true;
return GetNeedsGeneratedAttributesInternal();
}
private EmbeddableAttributes GetNeedsGeneratedAttributesInternal()
{
return (EmbeddableAttributes)(_needsGeneratedAttributes | (int)base.Compilation.GetNeedsGeneratedAttributes());
}
private void SetNeedsGeneratedAttributes(EmbeddableAttributes attributes)
{
ThreadSafeFlagOperations.Set(ref _needsGeneratedAttributes, (int)attributes);
}
internal PEModuleBuilder(SourceModuleSymbol sourceModule, EmitOptions emitOptions, OutputKind outputKind, ModulePropertiesForSerialization serializationProperties, IEnumerable<ResourceDescription> manifestResources)
: base(sourceModule.ContainingSourceAssembly.DeclaringCompilation, sourceModule, serializationProperties, manifestResources, outputKind, emitOptions, new ModuleCompilationState())
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
string metadataName = sourceModule.MetadataName;
_metadataName = ((metadataName != "?") ? metadataName : (emitOptions.OutputNameOverride ?? metadataName));
ConcurrentDictionaryExtensions.Add<Symbol, IModuleReference>(AssemblyOrModuleSymbolToModuleRefMap, (Symbol)sourceModule, (IModuleReference)(object)this);
if (sourceModule.AnyReferencedAssembliesAreLinked)
{
_embeddedTypesManagerOpt = new EmbeddedTypesManager(this);
}
}
internal sealed override ICustomAttribute SynthesizeAttribute(WellKnownMember attributeConstructor)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return (ICustomAttribute)(object)base.Compilation.TrySynthesizeAttribute(attributeConstructor);
}
public sealed override IEnumerable<ICustomAttribute> GetSourceAssemblyAttributes(bool isRefAssembly)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return (IEnumerable<ICustomAttribute>)base.SourceModule.ContainingSourceAssembly.GetCustomAttributesToEmit(this, isRefAssembly, EnumBounds.IsNetModule(((CommonPEModuleBuilder)this).OutputKind));
}
public sealed override IEnumerable<SecurityAttribute> GetSourceAssemblySecurityAttributes()
{
return base.SourceModule.ContainingSourceAssembly.GetSecurityAttributes();
}
public sealed override IEnumerable<ICustomAttribute> GetSourceModuleAttributes()
{
return (IEnumerable<ICustomAttribute>)base.SourceModule.GetCustomAttributesToEmit(this);
}
public sealed override ImmutableArray<UsedNamespaceOrType> GetImports()
{
return ImmutableArray<UsedNamespaceOrType>.Empty;
}
protected sealed override IEnumerable<IAssemblyReference> GetAssemblyReferencesFromAddedModules(DiagnosticBag diagnostics)
{
ImmutableArray<ModuleSymbol> modules = base.SourceModule.ContainingAssembly.Modules;
for (int i = 1; i < modules.Length; i++)
{
ImmutableArray<AssemblySymbol>.Enumerator enumerator = modules[i].GetReferencedAssemblySymbols().GetEnumerator();
while (enumerator.MoveNext())
{
AssemblySymbol current = enumerator.Current;
yield return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).Translate(current, diagnostics);
}
}
}
private void ValidateReferencedAssembly(AssemblySymbol assembly, AssemblyReference asmRef, DiagnosticBag diagnostics)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Invalid comparison between Unknown and I4
AssemblyIdentity identity = base.SourceModule.ContainingAssembly.Identity;
AssemblyIdentity identity2 = asmRef.Identity;
if (identity.IsStrongName && !identity2.IsStrongName && asmRef.Identity.ContentType != AssemblyContentType.WindowsRuntime)
{
diagnostics.Add((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.WRN_ReferencedAssemblyDoesNotHaveStrongName, assembly), NoLocation.Singleton);
}
if ((int)((CommonPEModuleBuilder)this).OutputKind != 3 && !string.IsNullOrEmpty(identity2.CultureName) && !string.Equals(identity2.CultureName, identity.CultureName, StringComparison.OrdinalIgnoreCase))
{
diagnostics.Add((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.WRN_RefCultureMismatch, assembly, identity2.CultureName), NoLocation.Singleton);
}
Machine machine = assembly.Machine;
if ((object)assembly != assembly.CorLibrary && (machine != Machine.I386 || assembly.Bit32Required))
{
Machine machine2 = base.SourceModule.Machine;
if ((machine2 != Machine.I386 || base.SourceModule.Bit32Required) && machine2 != machine)
{
diagnostics.Add((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.WRN_ConflictingMachineAssembly, assembly), NoLocation.Singleton);
}
}
if (_embeddedTypesManagerOpt != null && ((CommonEmbeddedTypesManager)_embeddedTypesManagerOpt).IsFrozen)
{
((EmbeddedTypesManager<PEModuleBuilder, ModuleCompilationState, EmbeddedTypesManager, SyntaxNode, CSharpAttributeData, Symbol, AssemblySymbol, NamedTypeSymbol, FieldSymbol, MethodSymbol, EventSymbol, PropertySymbol, ParameterSymbol, TypeParameterSymbol, EmbeddedType, EmbeddedField, EmbeddedMethod, EmbeddedEvent, EmbeddedProperty, EmbeddedParameter, EmbeddedTypeParameter>)_embeddedTypesManagerOpt).ReportIndirectReferencesToLinkedAssemblies(assembly, diagnostics);
}
}
internal sealed override IEnumerable<INestedTypeDefinition> GetSynthesizedNestedTypes(NamedTypeSymbol container)
{
return null;
}
public sealed override IEnumerable<(ITypeDefinition, ImmutableArray<DebugSourceDocument>)> GetTypeToDebugDocumentMap(EmitContext context)
{
//IL_000f: 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)
ArrayBuilder<ITypeDefinition> typesToProcess = ArrayBuilder<ITypeDefinition>.GetInstance();
ArrayBuilder<DebugSourceDocument> debugDocuments = ArrayBuilder<DebugSourceDocument>.GetInstance();
PooledHashSet<DebugSourceDocument> methodDocumentList = PooledHashSet<DebugSourceDocument>.GetInstance();
ArrayBuilder<NamespaceOrTypeSymbol> namespacesAndTopLevelTypesToProcess = ArrayBuilder<NamespaceOrTypeSymbol>.GetInstance();
ArrayBuilderExtensions.Push<NamespaceOrTypeSymbol>(namespacesAndTopLevelTypesToProcess, (NamespaceOrTypeSymbol)base.SourceModule.GlobalNamespace);
while (namespacesAndTopLevelTypesToProcess.Count > 0)
{
NamespaceOrTypeSymbol namespaceOrTypeSymbol = ArrayBuilderExtensions.Pop<NamespaceOrTypeSymbol>(namespacesAndTopLevelTypesToProcess);
SymbolKind kind = namespaceOrTypeSymbol.Kind;
if ((int)kind != 11)
{
if ((int)kind == 12)
{
if (!(GetSmallestSourceLocationOrNull(namespaceOrTypeSymbol) != (Location)null))
{
continue;
}
ImmutableArray<Symbol>.Enumerator enumerator = namespaceOrTypeSymbol.GetMembers().GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SymbolKind kind2 = current.Kind;
if (kind2 - 11 <= 1)
{
ArrayBuilderExtensions.Push<NamespaceOrTypeSymbol>(namespacesAndTopLevelTypesToProcess, (NamespaceOrTypeSymbol)current);
continue;
}
throw ExceptionUtilities.UnexpectedValue((object)current.Kind);
}
continue;
}
throw ExceptionUtilities.UnexpectedValue((object)namespaceOrTypeSymbol.Kind);
}
ITypeDefinition val = (ITypeDefinition)namespaceOrTypeSymbol.GetCciAdapter();
ArrayBuilderExtensions.Push<ITypeDefinition>(typesToProcess, val);
GetDocumentsForMethodsAndNestedTypes(methodDocumentList, typesToProcess, context);
ImmutableArray<Location>.Enumerator enumerator2 = namespaceOrTypeSymbol.Locations.GetEnumerator();
while (enumerator2.MoveNext())
{
Location current2 = enumerator2.Current;
if (current2.IsInSource)
{
FileLinePositionSpan lineSpan = current2.GetLineSpan();
DebugSourceDocument val2 = ((CommonPEModuleBuilder)this).DebugDocumentsBuilder.TryGetDebugDocument(((FileLinePositionSpan)(ref lineSpan)).Path, (string)null);
if (val2 != null && !((HashSet<DebugSourceDocument>)(object)methodDocumentList).Contains(val2))
{
debugDocuments.Add(val2);
}
}
}
if (debugDocuments.Count > 0)
{
yield return (val, debugDocuments.ToImmutable());
}
debugDocuments.Clear();
((HashSet<DebugSourceDocument>)(object)methodDocumentList).Clear();
}
namespacesAndTopLevelTypesToProcess.Free();
debugDocuments.Free();
methodDocumentList.Free();
typesToProcess.Free();
}
private static void GetDocumentsForMethodsAndNestedTypes(PooledHashSet<DebugSourceDocument> documentList, ArrayBuilder<ITypeDefinition> typesToProcess, EmitContext context)
{
//IL_000d: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
while (typesToProcess.Count > 0)
{
ITypeDefinition val = ArrayBuilderExtensions.Pop<ITypeDefinition>(typesToProcess);
foreach (IMethodDefinition method in val.GetMethods(context))
{
IMethodBody body = method.GetBody(context);
if (body != null)
{
ImmutableArray<SequencePoint>.Enumerator enumerator2 = body.SequencePoints.GetEnumerator();
while (enumerator2.MoveNext())
{
SequencePoint current = enumerator2.Current;
((HashSet<DebugSourceDocument>)(object)documentList).Add(current.Document);
}
}
}
foreach (INestedTypeDefinition nestedType in val.GetNestedTypes(context))
{
ArrayBuilderExtensions.Push<ITypeDefinition>(typesToProcess, (ITypeDefinition)(object)nestedType);
}
}
}
public sealed override MultiDictionary<DebugSourceDocument, DefinitionWithLocation> GetSymbolToLocationMap()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_01bc: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected I4, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Invalid comparison between Unknown and I4
//IL_0074: 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_007b: 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)
//IL_0081: Invalid comparison between Unknown and I4
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
MultiDictionary<DebugSourceDocument, DefinitionWithLocation> result = new MultiDictionary<DebugSourceDocument, DefinitionWithLocation>();
Stack<NamespaceOrTypeSymbol> stack = new Stack<NamespaceOrTypeSymbol>();
stack.Push(base.SourceModule.GlobalNamespace);
Location val = null;
while (stack.Count > 0)
{
NamespaceOrTypeSymbol namespaceOrTypeSymbol = stack.Pop();
SymbolKind kind = namespaceOrTypeSymbol.Kind;
ImmutableArray<Symbol>.Enumerator enumerator;
if ((int)kind != 11)
{
if ((int)kind == 12)
{
val = GetSmallestSourceLocationOrNull(namespaceOrTypeSymbol);
if (!(val != (Location)null))
{
continue;
}
enumerator = namespaceOrTypeSymbol.GetMembers().GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SymbolKind kind2 = current.Kind;
if (kind2 - 11 <= 1)
{
stack.Push((NamespaceOrTypeSymbol)current);
continue;
}
throw ExceptionUtilities.UnexpectedValue((object)current.Kind);
}
continue;
}
throw ExceptionUtilities.UnexpectedValue((object)namespaceOrTypeSymbol.Kind);
}
val = GetSmallestSourceLocationOrNull(namespaceOrTypeSymbol);
if (!(val != (Location)null))
{
continue;
}
AddSymbolLocation(result, val, (IDefinition)namespaceOrTypeSymbol.GetCciAdapter());
enumerator = namespaceOrTypeSymbol.GetMembers().GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current2 = enumerator.Current;
SymbolKind kind2 = current2.Kind;
switch (kind2 - 5)
{
default:
if ((int)kind2 != 15)
{
break;
}
AddSymbolLocation(result, current2);
continue;
case 6:
stack.Push((NamespaceOrTypeSymbol)current2);
continue;
case 4:
if (((MethodSymbol)current2).ShouldEmit())
{
AddSymbolLocation(result, current2);
}
continue;
case 1:
if (!(current2 is TupleErrorFieldSymbol))
{
AddSymbolLocation(result, current2);
}
continue;
case 0:
{
AddSymbolLocation(result, current2);
FieldSymbol associatedField = ((EventSymbol)current2).AssociatedField;
if ((object)associatedField != null)
{
AddSymbolLocation(result, associatedField);
}
continue;
}
case 2:
case 3:
case 5:
break;
}
throw ExceptionUtilities.UnexpectedValue((object)current2.Kind);
}
}
return result;
}
private void AddSymbolLocation(MultiDictionary<DebugSourceDocument, DefinitionWithLocation> result, Symbol symbol)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Location smallestSourceLocationOrNull = GetSmallestSourceLocationOrNull(symbol);
if (smallestSourceLocationOrNull != (Location)null)
{
AddSymbolLocation(result, smallestSourceLocationOrNull, (IDefinition)symbol.GetCciAdapter());
}
}
private void AddSymbolLocation(MultiDictionary<DebugSourceDocument, DefinitionWithLocation> result, Location location, IDefinition definition)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
FileLinePositionSpan lineSpan = location.GetLineSpan();
DebugSourceDocument val = ((CommonPEModuleBuilder)this).DebugDocumentsBuilder.TryGetDebugDocument(((FileLinePositionSpan)(ref lineSpan)).Path, location.SourceTree.FilePath);
if (val != null)
{
LinePosition val2 = ((FileLinePositionSpan)(ref lineSpan)).StartLinePosition;
int line = ((LinePosition)(ref val2)).Line;
val2 = ((FileLinePositionSpan)(ref lineSpan)).StartLinePosition;
int character = ((LinePosition)(ref val2)).Character;
val2 = ((FileLinePositionSpan)(ref lineSpan)).EndLinePosition;
int line2 = ((LinePosition)(ref val2)).Line;
val2 = ((FileLinePositionSpan)(ref lineSpan)).EndLinePosition;
result.Add(val, new DefinitionWithLocation(definition, line, character, line2, ((LinePosition)(ref val2)).Character));
}
}
private Location GetSmallestSourceLocationOrNull(Symbol symbol)
{
CSharpCompilation declaringCompilation = symbol.DeclaringCompilation;
Location val = null;
ImmutableArray<Location>.Enumerator enumerator = symbol.Locations.GetEnumerator();
while (enumerator.MoveNext())
{
Location current = enumerator.Current;
if (current.IsInSource && (val == (Location)null || ((Compilation)declaringCompilation).CompareSourceLocations(val, current) > 0))
{
val = current;
}
}
return val;
}
internal virtual NamedTypeSymbol GetDynamicOperationContextType(NamedTypeSymbol contextType)
{
return contextType;
}
internal virtual VariableSlotAllocator TryCreateVariableSlotAllocator(MethodSymbol method, MethodSymbol topLevelMethod, DiagnosticBag diagnostics)
{
return null;
}
internal virtual MethodInstrumentation GetMethodBodyInstrumentations(MethodSymbol method)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
MethodInstrumentation result = default(MethodInstrumentation);
((MethodInstrumentation)(ref result)).set_Kinds(((CommonPEModuleBuilder)this).EmitOptions.InstrumentationKinds);
return result;
}
internal virtual ImmutableArray<AnonymousTypeKey> GetPreviousAnonymousTypes()
{
return ImmutableArray<AnonymousTypeKey>.Empty;
}
internal virtual ImmutableArray<SynthesizedDelegateKey> GetPreviousAnonymousDelegates()
{
return ImmutableArray<SynthesizedDelegateKey>.Empty;
}
internal virtual int GetNextAnonymousTypeIndex()
{
return 0;
}
internal virtual bool TryGetAnonymousTypeName(AnonymousTypeManager.AnonymousTypeTemplateSymbol template, out string name, out int index)
{
name = null;
index = -1;
return false;
}
public sealed override IEnumerable<INamespaceTypeDefinition> GetAnonymousTypeDefinitions(EmitContext context)
{
if (((EmitContext)(ref context)).MetadataOnly)
{
return SpecializedCollections.EmptyEnumerable<INamespaceTypeDefinition>();
}
return (IEnumerable<INamespaceTypeDefinition>)(object)base.Compilation.AnonymousTypeManager.GetAllCreatedTemplates();
}
public override IEnumerable<INamespaceTypeDefinition> GetTopLevelSourceTypeDefinitions(EmitContext context)
{
Stack<NamespaceSymbol> namespacesToProcess = new Stack<NamespaceSymbol>();
namespacesToProcess.Push(base.SourceModule.GlobalNamespace);
while (namespacesToProcess.Count > 0)
{
NamespaceSymbol namespaceSymbol = namespacesToProcess.Pop();
ImmutableArray<Symbol>.Enumerator enumerator = namespaceSymbol.GetMembers().GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if ((int)current.Kind == 12)
{
namespacesToProcess.Push((NamespaceSymbol)current);
}
else
{
yield return (INamespaceTypeDefinition)(object)((NamedTypeSymbol)current).GetCciAdapter();
}
}
}
}
private static void GetExportedTypes(NamespaceOrTypeSymbol symbol, int parentIndex, ArrayBuilder<ExportedType> builder)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
int parentIndex2;
if ((int)symbol.Kind == 11)
{
if ((int)symbol.DeclaredAccessibility != 6)
{
return;
}
parentIndex2 = builder.Count;
builder.Add(new ExportedType((ITypeReference)symbol.GetCciAdapter(), parentIndex, false));
}
else
{
parentIndex2 = -1;
}
ImmutableArray<Symbol>.Enumerator enumerator = symbol.GetMembers().GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current is NamespaceOrTypeSymbol symbol2)
{
GetExportedTypes(symbol2, parentIndex2, builder);
}
}
}
public sealed override ImmutableArray<ExportedType> GetExportedTypes(DiagnosticBag diagnostics)
{
if (_lazyExportedTypes.IsDefault)
{
_lazyExportedTypes = CalculateExportedTypes();
if (_lazyExportedTypes.Length > 0)
{
ReportExportedTypeNameCollisions(_lazyExportedTypes, diagnostics);
}
}
return _lazyExportedTypes;
}
private ImmutableArray<ExportedType> CalculateExportedTypes()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
SourceAssemblySymbol containingSourceAssembly = base.SourceModule.ContainingSourceAssembly;
ArrayBuilder<ExportedType> instance = ArrayBuilder<ExportedType>.GetInstance();
if (!EnumBounds.IsNetModule(((CommonPEModuleBuilder)this).OutputKind))
{
ImmutableArray<ModuleSymbol> modules = containingSourceAssembly.Modules;
for (int i = 1; i < modules.Length; i++)
{
GetExportedTypes(modules[i].GlobalNamespace, -1, instance);
}
}
GetForwardedTypes(containingSourceAssembly, instance);
return instance.ToImmutableAndFree();
}
internal static HashSet<NamedTypeSymbol> GetForwardedTypes(SourceAssemblySymbol sourceAssembly, ArrayBuilder<ExportedType>? builder)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
HashSet<NamedTypeSymbol> hashSet = new HashSet<NamedTypeSymbol>();
GetForwardedTypes(hashSet, sourceAssembly.GetSourceDecodedWellKnownAttributeData(), builder);
if (!EnumBounds.IsNetModule(((CompilationOptions)sourceAssembly.DeclaringCompilation.Options).OutputKind))
{
GetForwardedTypes(hashSet, sourceAssembly.GetNetModuleDecodedWellKnownAttributeData(), builder);
}
return hashSet;
}
private void ReportExportedTypeNameCollisions(ImmutableArray<ExportedType> exportedTypes, DiagnosticBag diagnostics)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
SourceAssemblySymbol containingSourceAssembly = base.SourceModule.ContainingSourceAssembly;
Dictionary<string, NamedTypeSymbol> dictionary = new Dictionary<string, NamedTypeSymbol>((IEqualityComparer<string>?)StringOrdinalComparer.Instance);
ImmutableArray<ExportedType>.Enumerator enumerator = exportedTypes.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)(object)((IReference)enumerator.Current.Type).GetInternalSymbol();
if (!namedTypeSymbol.IsTopLevelType())
{
continue;
}
string text = MetadataHelpers.BuildQualifiedName(((INamespaceTypeReference)namedTypeSymbol.GetCciAdapter()).NamespaceName, MetadataWriter.GetMetadataName((INamedTypeReference)(object)namedTypeSymbol.GetCciAdapter(), 0));
NamedTypeSymbol value;
if (base.ContainsTopLevelType(text))
{
if ((object)namedTypeSymbol.ContainingAssembly == containingSourceAssembly)
{
diagnostics.Add(ErrorCode.ERR_ExportedTypeConflictsWithDeclaration, NoLocation.Singleton, namedTypeSymbol, namedTypeSymbol.ContainingModule);
}
else
{
diagnostics.Add(ErrorCode.ERR_ForwardedTypeConflictsWithDeclaration, NoLocation.Singleton, namedTypeSymbol);
}
}
else if (dictionary.TryGetValue(text, out value))
{
if ((object)namedTypeSymbol.ContainingAssembly == containingSourceAssembly)
{
diagnostics.Add(ErrorCode.ERR_ExportedTypesConflict, NoLocation.Singleton, namedTypeSymbol, namedTypeSymbol.ContainingModule, value, value.ContainingModule);
}
else if ((object)value.ContainingAssembly == containingSourceAssembly)
{
diagnostics.Add(ErrorCode.ERR_ForwardedTypeConflictsWithExportedType, NoLocation.Singleton, namedTypeSymbol, namedTypeSymbol.ContainingAssembly, value, value.ContainingModule);
}
else
{
diagnostics.Add(ErrorCode.ERR_ForwardedTypesConflict, NoLocation.Singleton, namedTypeSymbol, namedTypeSymbol.ContainingAssembly, value, value.ContainingAssembly);
}
}
else
{
dictionary.Add(text, namedTypeSymbol);
}
}
}
private static void GetForwardedTypes(HashSet<NamedTypeSymbol> seenTopLevelTypes, CommonAssemblyWellKnownAttributeData<NamedTypeSymbol> wellKnownAttributeData, ArrayBuilder<ExportedType>? builder)
{
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
if (wellKnownAttributeData == null || !(wellKnownAttributeData.ForwardedTypes?.Count > 0))
{
return;
}
ArrayBuilder<(NamedTypeSymbol, int)> instance = ArrayBuilder<(NamedTypeSymbol, int)>.GetInstance();
IEnumerable<NamedTypeSymbol> enumerable = wellKnownAttributeData.ForwardedTypes;
if (builder != null)
{
enumerable = enumerable.OrderBy((NamedTypeSymbol t) => ((Symbol)t.OriginalDefinition).ToDisplayString(SymbolDisplayFormat.QualifiedNameArityFormat));
}
foreach (NamedTypeSymbol item in enumerable)
{
NamedTypeSymbol originalDefinition = item.OriginalDefinition;
if (!seenTopLevelTypes.Add(originalDefinition) || builder == null)
{
continue;
}
ArrayBuilderExtensions.Push<(NamedTypeSymbol, int)>(instance, (originalDefinition, -1));
while (instance.Count > 0)
{
var (namedTypeSymbol, num) = ArrayBuilderExtensions.Pop<(NamedTypeSymbol, int)>(instance);
if ((int)namedTypeSymbol.DeclaredAccessibility != 1)
{
int count = builder.Count;
builder.Add(new ExportedType((ITypeReference)(object)namedTypeSymbol.GetCciAdapter(), num, true));
ImmutableArray<NamedTypeSymbol> typeMembers = namedTypeSymbol.GetTypeMembers();
for (int num2 = typeMembers.Length - 1; num2 >= 0; num2--)
{
ArrayBuilderExtensions.Push<(NamedTypeSymbol, int)>(instance, (typeMembers[num2], count));
}
}
}
}
instance.Free();
}
internal IEnumerable<AssemblySymbol> GetReferencedAssembliesUsedSoFar()
{
ImmutableArray<AssemblySymbol>.Enumerator enumerator = base.SourceModule.GetReferencedAssemblySymbols().GetEnumerator();
while (enumerator.MoveNext())
{
AssemblySymbol current = enumerator.Current;
if (!current.IsLinked && !current.IsMissing && AssemblyOrModuleSymbolToModuleRefMap.ContainsKey(current))
{
yield return current;
}
}
}
private NamedTypeSymbol GetUntranslatedSpecialType(SpecialType specialType, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol specialType2 = base.SourceModule.ContainingAssembly.GetSpecialType(specialType);
DiagnosticInfo diagnosticInfo = specialType2.GetUseSiteInfo().DiagnosticInfo;
if (diagnosticInfo != null)
{
Symbol.ReportUseSiteDiagnostic(diagnosticInfo, diagnostics, (syntaxNodeOpt != null) ? syntaxNodeOpt.Location : NoLocation.Singleton);
}
return specialType2;
}
internal sealed override INamedTypeReference GetSpecialType(SpecialType specialType, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return Translate(GetUntranslatedSpecialType(specialType, syntaxNodeOpt, diagnostics), syntaxNodeOpt, diagnostics, fromImplements: false, needDeclaration: true);
}
public sealed override IMethodReference GetInitArrayHelper()
{
return (IMethodReference)(object)((MethodSymbol)base.Compilation.GetWellKnownTypeMember((WellKnownMember)125))?.GetCciAdapter();
}
public sealed override bool IsPlatformType(ITypeReference typeRef, PlatformType platformType)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
if (((IReference)typeRef).GetInternalSymbol() is NamedTypeSymbol namedTypeSymbol)
{
if ((int)platformType == 61)
{
return (object)namedTypeSymbol == base.Compilation.GetWellKnownType((WellKnownType)61);
}
return (int)namedTypeSymbol.SpecialType == (sbyte)platformType;
}
return false;
}
protected sealed override IAssemblyReference GetCorLibraryReferenceToEmit(EmitContext context)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
AssemblySymbol corLibrary = ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).CorLibrary;
if (!corLibrary.IsMissing && !corLibrary.IsLinked && (object)corLibrary != base.SourceModule.ContainingAssembly)
{
return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).Translate(corLibrary, context.Diagnostics);
}
return null;
}
internal sealed override IAssemblyReference Translate(AssemblySymbol assembly, DiagnosticBag diagnostics)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
if ((object)base.SourceModule.ContainingAssembly == assembly)
{
return (IAssemblyReference)this;
}
if (AssemblyOrModuleSymbolToModuleRefMap.TryGetValue(assembly, out var value))
{
return (IAssemblyReference)value;
}
AssemblyReference assemblyReference = new AssemblyReference(assembly);
AssemblyReference assemblyReference2 = (AssemblyReference)(object)AssemblyOrModuleSymbolToModuleRefMap.GetOrAdd(assembly, (IModuleReference)(object)assemblyReference);
if (assemblyReference2 == assemblyReference)
{
ValidateReferencedAssembly(assembly, assemblyReference2, diagnostics);
}
AssemblyOrModuleSymbolToModuleRefMap.TryAdd(assembly.Modules[0], (IModuleReference)(object)assemblyReference2);
return (IAssemblyReference)(object)assemblyReference2;
}
internal IModuleReference Translate(ModuleSymbol module, DiagnosticBag diagnostics)
{
if ((object)base.SourceModule == module)
{
return (IModuleReference)(object)this;
}
if ((object)module == null)
{
return null;
}
if (AssemblyOrModuleSymbolToModuleRefMap.TryGetValue(module, out var value))
{
return value;
}
value = TranslateModule(module, diagnostics);
return AssemblyOrModuleSymbolToModuleRefMap.GetOrAdd(module, value);
}
protected virtual IModuleReference TranslateModule(ModuleSymbol module, DiagnosticBag diagnostics)
{
AssemblySymbol containingAssembly = module.ContainingAssembly;
if ((object)containingAssembly != null && (object)containingAssembly.Modules[0] == module)
{
IModuleReference val = (IModuleReference)(object)new AssemblyReference(containingAssembly);
IModuleReference orAdd = AssemblyOrModuleSymbolToModuleRefMap.GetOrAdd(containingAssembly, val);
if (orAdd == val)
{
ValidateReferencedAssembly(containingAssembly, (AssemblyReference)(object)val, diagnostics);
}
else
{
val = orAdd;
}
return val;
}
return (IModuleReference)(object)new ModuleReference(this, module);
}
internal INamedTypeReference Translate(NamedTypeSymbol namedTypeSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, bool fromImplements = false, bool needDeclaration = false)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
//IL_0041: 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: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Expected O, but got Unknown
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
if (namedTypeSymbol.IsAnonymousType)
{
namedTypeSymbol = AnonymousTypeManager.TranslateAnonymousTypeSymbol(namedTypeSymbol);
}
else if (namedTypeSymbol.IsTupleType)
{
CheckTupleUnderlyingType(namedTypeSymbol, syntaxNodeOpt, diagnostics);
}
if ((int)namedTypeSymbol.OriginalDefinition.Kind == 4)
{
ErrorTypeSymbol errorTypeSymbol = (ErrorTypeSymbol)namedTypeSymbol.OriginalDefinition;
DiagnosticInfo val = errorTypeSymbol.GetUseSiteInfo().DiagnosticInfo ?? errorTypeSymbol.ErrorInfo;
if (val == null && (int)namedTypeSymbol.Kind == 4)
{
errorTypeSymbol = (ErrorTypeSymbol)namedTypeSymbol;
val = errorTypeSymbol.GetUseSiteInfo().DiagnosticInfo ?? errorTypeSymbol.ErrorInfo;
}
if (_reportedErrorTypesMap.Add((TypeSymbol)errorTypeSymbol))
{
diagnostics.Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(((object)val) ?? ((object)new CSDiagnosticInfo(ErrorCode.ERR_BogusType, string.Empty))), (syntaxNodeOpt == null) ? NoLocation.Singleton : syntaxNodeOpt.Location));
}
return (INamedTypeReference)(object)ErrorType.Singleton;
}
if (!namedTypeSymbol.IsDefinition)
{
if (!namedTypeSymbol.IsUnboundGenericType)
{
return (INamedTypeReference)GetCciAdapter(namedTypeSymbol);
}
namedTypeSymbol = namedTypeSymbol.OriginalDefinition;
}
else if (!needDeclaration)
{
NamedTypeSymbol containingType = namedTypeSymbol.ContainingType;
object value;
if (namedTypeSymbol.Arity > 0)
{
if (_genericInstanceMap.TryGetValue(namedTypeSymbol, out value))
{
return (INamedTypeReference)value;
}
INamedTypeReference value2 = (INamedTypeReference)(object)(((object)containingType == null) ? new GenericNamespaceTypeInstanceReference(namedTypeSymbol) : ((!IsGenericType(containingType)) ? ((NamedTypeReference)new GenericNestedTypeInstanceReference(namedTypeSymbol)) : ((NamedTypeReference)new SpecializedGenericNestedTypeInstanceReference(namedTypeSymbol))));
return (INamedTypeReference)_genericInstanceMap.GetOrAdd(namedTypeSymbol, value2);
}
if (IsGenericType(containingType))
{
if (_genericInstanceMap.TryGetValue(namedTypeSymbol, out value))
{
return (INamedTypeReference)value;
}
INamedTypeReference value2 = (INamedTypeReference)(object)new SpecializedNestedTypeReference(namedTypeSymbol);
return (INamedTypeReference)_genericInstanceMap.GetOrAdd(namedTypeSymbol, value2);
}
NamedTypeSymbol nativeIntegerUnderlyingType = namedTypeSymbol.NativeIntegerUnderlyingType;
if ((object)nativeIntegerUnderlyingType != null)
{
namedTypeSymbol = nativeIntegerUnderlyingType;
}
}
return (INamedTypeReference)(((object)_embeddedTypesManagerOpt?.EmbedTypeIfNeedTo(namedTypeSymbol, fromImplements, syntaxNodeOpt, diagnostics)) ?? ((object)namedTypeSymbol.GetCciAdapter()));
}
private object GetCciAdapter(Symbol symbol)
{
return _genericInstanceMap.GetOrAdd(symbol, (Symbol s) => s.GetCciAdapter());
}
private void CheckTupleUnderlyingType(NamedTypeSymbol namedTypeSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = namedTypeSymbol.BaseTypeNoUseSiteDiagnostics;
if (((object)baseTypeNoUseSiteDiagnostics != null && (int)baseTypeNoUseSiteDiagnostics.SpecialType == 5) || !_reportedErrorTypesMap.Add((TypeSymbol)namedTypeSymbol))
{
return;
}
Location location = ((syntaxNodeOpt == null) ? NoLocation.Singleton : syntaxNodeOpt.Location);
if ((object)baseTypeNoUseSiteDiagnostics != null)
{
DiagnosticInfo diagnosticInfo = baseTypeNoUseSiteDiagnostics.GetUseSiteInfo().DiagnosticInfo;
if (diagnosticInfo != null && (int)diagnosticInfo.Severity == 3)
{
diagnostics.Add(diagnosticInfo, location);
return;
}
}
diagnostics.Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_PredefinedValueTupleTypeMustBeStruct, namedTypeSymbol.MetadataName), location));
}
public static bool IsGenericType(NamedTypeSymbol toCheck)
{
while ((object)toCheck != null)
{
if (toCheck.Arity > 0)
{
return true;
}
toCheck = toCheck.ContainingType;
}
return false;
}
internal static IGenericParameterReference Translate(TypeParameterSymbol param)
{
if (!param.IsDefinition)
{
throw new InvalidOperationException(string.Format(CSharpResources.GenericParameterDefinition, param.Name));
}
return (IGenericParameterReference)(object)param.GetCciAdapter();
}
internal sealed override ITypeReference Translate(TypeSymbol typeSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_000c: 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)
//IL_0024: Expected I4, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_008a: 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_0027: Invalid comparison between Unknown and I4
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
SymbolKind kind = typeSymbol.Kind;
if ((int)kind <= 11)
{
switch (kind - 1)
{
default:
if ((int)kind != 11)
{
break;
}
goto case 3;
case 2:
return Translate(syntaxNodeOpt, diagnostics);
case 0:
return (ITypeReference)(object)Translate((ArrayTypeSymbol)typeSymbol);
case 3:
return (ITypeReference)(object)Translate((NamedTypeSymbol)typeSymbol, syntaxNodeOpt, diagnostics);
case 1:
break;
}
}
else
{
if ((int)kind == 14)
{
return (ITypeReference)(object)Translate((PointerTypeSymbol)typeSymbol);
}
if ((int)kind == 17)
{
return (ITypeReference)(object)Translate((TypeParameterSymbol)typeSymbol);
}
if ((int)kind == 20)
{
return (ITypeReference)(object)Translate((FunctionPointerTypeSymbol)typeSymbol);
}
}
throw ExceptionUtilities.UnexpectedValue((object)typeSymbol.Kind);
}
internal IFieldReference Translate(FieldSymbol fieldSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, bool needDeclaration = false)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
if (!fieldSymbol.IsDefinition)
{
return (IFieldReference)GetCciAdapter(fieldSymbol);
}
if (needDeclaration || !IsGenericType(fieldSymbol.ContainingType))
{
return (IFieldReference)(((object)((EmbeddedTypesManager<PEModuleBuilder, ModuleCompilationState, EmbeddedTypesManager, SyntaxNode, CSharpAttributeData, Symbol, AssemblySymbol, NamedTypeSymbol, FieldSymbol, MethodSymbol, EventSymbol, PropertySymbol, ParameterSymbol, TypeParameterSymbol, EmbeddedType, EmbeddedField, EmbeddedMethod, EmbeddedEvent, EmbeddedProperty, EmbeddedParameter, EmbeddedTypeParameter>)_embeddedTypesManagerOpt)?.EmbedFieldIfNeedTo(fieldSymbol.GetCciAdapter(), syntaxNodeOpt, diagnostics)) ?? ((object)fieldSymbol.GetCciAdapter()));
}
if (_genericInstanceMap.TryGetValue(fieldSymbol, out var value))
{
return (IFieldReference)value;
}
IFieldReference value2 = (IFieldReference)(object)new SpecializedFieldReference(fieldSymbol);
return (IFieldReference)_genericInstanceMap.GetOrAdd(fieldSymbol, value2);
}
public static TypeMemberVisibility MemberVisibility(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected I4, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
Accessibility declaredAccessibility = symbol.DeclaredAccessibility;
switch (declaredAccessibility - 1)
{
case 5:
return (TypeMemberVisibility)6;
case 0:
{
NamedTypeSymbol containingType = symbol.ContainingType;
if ((object)containingType != null && (int)containingType.TypeKind == 12)
{
return (TypeMemberVisibility)6;
}
return (TypeMemberVisibility)1;
}
case 3:
if (!symbol.ContainingAssembly.IsInteractive)
{
return (TypeMemberVisibility)3;
}
return (TypeMemberVisibility)6;
case 2:
if ((int)symbol.ContainingType.TypeKind != 12)
{
return (TypeMemberVisibility)4;
}
return (TypeMemberVisibility)6;
case 1:
return (TypeMemberVisibility)2;
case 4:
if (!symbol.ContainingAssembly.IsInteractive)
{
return (TypeMemberVisibility)5;
}
return (TypeMemberVisibility)6;
default:
throw ExceptionUtilities.UnexpectedValue((object)symbol.DeclaredAccessibility);
}
}
internal sealed override IMethodReference Translate(MethodSymbol symbol, DiagnosticBag diagnostics, bool needDeclaration)
{
return Translate(symbol, null, diagnostics, null, needDeclaration);
}
internal IMethodReference Translate(MethodSymbol methodSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, BoundArgListOperator optArgList = null, bool needDeclaration = false)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Invalid comparison between Unknown and I4
IMethodReference val = Translate(methodSymbol, syntaxNodeOpt, diagnostics, needDeclaration);
if (optArgList != null && optArgList.Arguments.Length > 0)
{
IParameterTypeInformation[] array = (IParameterTypeInformation[])(object)new IParameterTypeInformation[optArgList.Arguments.Length];
int num = methodSymbol.ParameterCount;
for (int i = 0; i < array.Length; i++)
{
array[i] = (IParameterTypeInformation)(object)new ArgListParameterTypeInformation(num, !optArgList.ArgumentRefKindsOpt.IsDefaultOrEmpty && (int)optArgList.ArgumentRefKindsOpt[i] > 0, ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).Translate(optArgList.Arguments[i].Type, syntaxNodeOpt, diagnostics));
num++;
}
return (IMethodReference)(object)new ExpandedVarargsMethodReference(val, ImmutableArrayExtensions.AsImmutableOrNull<IParameterTypeInformation>(array));
}
return val;
}
private IMethodReference Translate(MethodSymbol methodSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, bool needDeclaration)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
NamedTypeSymbol containingType = methodSymbol.ContainingType;
if ((object)containingType != null && containingType.IsAnonymousType)
{
methodSymbol = AnonymousTypeManager.TranslateAnonymousTypeMethodSymbol(methodSymbol);
}
if (!methodSymbol.IsDefinition)
{
return (IMethodReference)GetCciAdapter(methodSymbol);
}
if (!needDeclaration)
{
bool isGenericMethod = methodSymbol.IsGenericMethod;
bool flag = IsGenericType(containingType);
if (isGenericMethod || flag)
{
if (_genericInstanceMap.TryGetValue(methodSymbol, out var value))
{
return (IMethodReference)value;
}
IMethodReference value2 = (IMethodReference)(object)((!isGenericMethod) ? new SpecializedMethodReference(methodSymbol) : ((!flag) ? ((MethodReference)new GenericMethodInstanceReference(methodSymbol)) : ((MethodReference)new SpecializedGenericMethodInstanceReference(methodSymbol))));
return (IMethodReference)_genericInstanceMap.GetOrAdd(methodSymbol, value2);
}
if (methodSymbol is NativeIntegerMethodSymbol { UnderlyingMethod: { } underlyingMethod })
{
methodSymbol = underlyingMethod;
}
}
if (_embeddedTypesManagerOpt != null)
{
return ((EmbeddedTypesManager<PEModuleBuilder, ModuleCompilationState, EmbeddedTypesManager, SyntaxNode, CSharpAttributeData, Symbol, AssemblySymbol, NamedTypeSymbol, FieldSymbol, MethodSymbol, EventSymbol, PropertySymbol, ParameterSymbol, TypeParameterSymbol, EmbeddedType, EmbeddedField, EmbeddedMethod, EmbeddedEvent, EmbeddedProperty, EmbeddedParameter, EmbeddedTypeParameter>)_embeddedTypesManagerOpt).EmbedMethodIfNeedTo(methodSymbol.GetCciAdapter(), syntaxNodeOpt, diagnostics);
}
return (IMethodReference)(object)methodSymbol.GetCciAdapter();
}
internal IMethodReference TranslateOverriddenMethodReference(MethodSymbol methodSymbol, CSharpSyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
if (IsGenericType(methodSymbol.ContainingType))
{
if (methodSymbol.IsDefinition)
{
if (_genericInstanceMap.TryGetValue(methodSymbol, out var value))
{
return (IMethodReference)value;
}
IMethodReference value2 = (IMethodReference)(object)new SpecializedMethodReference(methodSymbol);
return (IMethodReference)_genericInstanceMap.GetOrAdd(methodSymbol, value2);
}
return (IMethodReference)(object)new SpecializedMethodReference(methodSymbol);
}
if (_embeddedTypesManagerOpt != null)
{
return ((EmbeddedTypesManager<PEModuleBuilder, ModuleCompilationState, EmbeddedTypesManager, SyntaxNode, CSharpAttributeData, Symbol, AssemblySymbol, NamedTypeSymbol, FieldSymbol, MethodSymbol, EventSymbol, PropertySymbol, ParameterSymbol, TypeParameterSymbol, EmbeddedType, EmbeddedField, EmbeddedMethod, EmbeddedEvent, EmbeddedProperty, EmbeddedParameter, EmbeddedTypeParameter>)_embeddedTypesManagerOpt).EmbedMethodIfNeedTo(methodSymbol.GetCciAdapter(), (SyntaxNode)(object)syntaxNodeOpt, diagnostics);
}
return (IMethodReference)(object)methodSymbol.GetCciAdapter();
}
internal ImmutableArray<IParameterTypeInformation> Translate(ImmutableArray<ParameterSymbol> @params)
{
if (!@params.Any() || !MustBeWrapped(@params.First()))
{
return StaticCast<IParameterTypeInformation>.From<ParameterSymbol>(@params);
}
return TranslateAll(@params);
}
private static bool MustBeWrapped(ParameterSymbol param)
{
if (param.IsDefinition && ContainerIsGeneric(param.ContainingSymbol))
{
return true;
}
return false;
}
private ImmutableArray<IParameterTypeInformation> TranslateAll(ImmutableArray<ParameterSymbol> @params)
{
ArrayBuilder<IParameterTypeInformation> instance = ArrayBuilder<IParameterTypeInformation>.GetInstance();
ImmutableArray<ParameterSymbol>.Enumerator enumerator = @params.GetEnumerator();
while (enumerator.MoveNext())
{
ParameterSymbol current = enumerator.Current;
instance.Add(CreateParameterTypeInformationWrapper(current));
}
return instance.ToImmutableAndFree();
}
private IParameterTypeInformation CreateParameterTypeInformationWrapper(ParameterSymbol param)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (_genericInstanceMap.TryGetValue(param, out var value))
{
return (IParameterTypeInformation)value;
}
IParameterTypeInformation value2 = (IParameterTypeInformation)(object)new ParameterTypeInformation(param);
return (IParameterTypeInformation)_genericInstanceMap.GetOrAdd(param, value2);
}
private static bool ContainerIsGeneric(Symbol container)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)container.Kind != 9 || !((MethodSymbol)container).IsGenericMethod)
{
return IsGenericType(container.ContainingType);
}
return true;
}
internal ITypeReference Translate(SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
{
return (ITypeReference)(object)((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).GetSpecialType((SpecialType)1, syntaxNodeOpt, diagnostics);
}
internal IArrayTypeReference Translate(ArrayTypeSymbol symbol)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
return (IArrayTypeReference)GetCciAdapter(symbol);
}
internal IPointerTypeReference Translate(PointerTypeSymbol symbol)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
return (IPointerTypeReference)GetCciAdapter(symbol);
}
internal IFunctionPointerTypeReference Translate(FunctionPointerTypeSymbol symbol)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
return (IFunctionPointerTypeReference)GetCciAdapter(symbol);
}
public NamedTypeSymbol SetFixedImplementationType(SourceMemberFieldSymbol field)
{
if (_fixedImplementationTypes == null)
{
Interlocked.CompareExchange(ref _fixedImplementationTypes, new Dictionary<FieldSymbol, NamedTypeSymbol>(), null);
}
lock (_fixedImplementationTypes)
{
if (_fixedImplementationTypes.TryGetValue(field, out var value))
{
return value;
}
value = new FixedFieldImplementationType(field);
_fixedImplementationTypes.Add(field, value);
base.AddSynthesizedDefinition(value.ContainingType, (INestedTypeDefinition)(object)value.GetCciAdapter());
return value;
}
}
protected override IMethodDefinition CreatePrivateImplementationDetailsStaticConstructor(PrivateImplementationDetails details, SyntaxNode syntaxOpt, DiagnosticBag diagnostics)
{
return (IMethodDefinition)(object)new SynthesizedPrivateImplementationDetailsStaticConstructor(base.SourceModule, details, GetUntranslatedSpecialType((SpecialType)6, syntaxOpt, diagnostics)).GetCciAdapter();
}
internal abstract SynthesizedAttributeData SynthesizeEmbeddedAttribute();
internal SynthesizedAttributeData SynthesizeIsReadOnlyAttribute(Symbol symbol)
{
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
return TrySynthesizeIsReadOnlyAttribute();
}
internal SynthesizedAttributeData SynthesizeRequiresLocationAttribute(ParameterSymbol symbol)
{
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
return TrySynthesizeRequiresLocationAttribute();
}
internal SynthesizedAttributeData SynthesizeIsUnmanagedAttribute(Symbol symbol)
{
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
return TrySynthesizeIsUnmanagedAttribute();
}
internal SynthesizedAttributeData SynthesizeIsByRefLikeAttribute(Symbol symbol)
{
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
return TrySynthesizeIsByRefLikeAttribute();
}
internal SynthesizedAttributeData SynthesizeNullableAttributeIfNecessary(Symbol symbol, byte? nullableContextValue, TypeWithAnnotations type)
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
ArrayBuilder<byte> instance = ArrayBuilder<byte>.GetInstance();
type.AddNullableTransforms(instance);
SynthesizedAttributeData result;
if (!instance.Any())
{
result = null;
}
else
{
byte? commonValue = MostCommonNullableValueBuilder.GetCommonValue(instance);
if (commonValue.HasValue)
{
result = SynthesizeNullableAttributeIfNecessary(nullableContextValue, commonValue.GetValueOrDefault());
}
else
{
NamedTypeSymbol specialType = base.Compilation.GetSpecialType((SpecialType)10);
ArrayTypeSymbol arrayTypeSymbol = ArrayTypeSymbol.CreateSZArray(specialType.ContainingAssembly, TypeWithAnnotations.Create(specialType));
ImmutableArray<TypedConstant> immutableArray = ArrayBuilderExtensions.SelectAsArray<byte, NamedTypeSymbol, TypedConstant>(instance, (Func<byte, NamedTypeSymbol, TypedConstant>)((byte flag, NamedTypeSymbol byteType) => new TypedConstant((ITypeSymbolInternal)(object)byteType, (TypedConstantKind)1, (object)flag)), specialType);
result = SynthesizeNullableAttribute((WellKnownMember)390, ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)arrayTypeSymbol, immutableArray)));
}
}
instance.Free();
return result;
}
internal SynthesizedAttributeData SynthesizeNullableAttributeIfNecessary(byte? nullableContextValue, byte nullableValue)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (nullableValue == nullableContextValue || (!nullableContextValue.HasValue && nullableValue == 0))
{
return null;
}
NamedTypeSymbol specialType = base.Compilation.GetSpecialType((SpecialType)10);
return SynthesizeNullableAttribute((WellKnownMember)389, ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)specialType, (TypedConstantKind)1, (object)nullableValue)));
}
internal virtual SynthesizedAttributeData SynthesizeNullableAttribute(WellKnownMember member, ImmutableArray<TypedConstant> arguments)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return base.Compilation.TrySynthesizeAttribute(member, arguments, default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
}
internal SynthesizedAttributeData SynthesizeNullableContextAttribute(Symbol symbol, byte value)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
ModuleSymbol sourceModule = base.Compilation.SourceModule;
if ((object)sourceModule != symbol && (object)sourceModule != symbol.ContainingModule)
{
return null;
}
return SynthesizeNullableContextAttribute(ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)base.Compilation.GetSpecialType((SpecialType)10), (TypedConstantKind)1, (object)value)));
}
internal virtual SynthesizedAttributeData SynthesizeNullableContextAttribute(ImmutableArray<TypedConstant> arguments)
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)391, arguments, default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
}
internal SynthesizedAttributeData SynthesizePreserveBaseOverridesAttribute()
{
return base.Compilation.TrySynthesizeAttribute((SpecialMember)126, isOptionalUse: true);
}
internal SynthesizedAttributeData SynthesizeNativeIntegerAttribute(Symbol symbol, TypeSymbol type)
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
ArrayBuilder<bool> instance = ArrayBuilder<bool>.GetInstance();
CSharpCompilation.NativeIntegerTransformsEncoder.Encode(instance, type);
SynthesizedAttributeData result;
if (instance.Count == 1 && instance[0])
{
result = SynthesizeNativeIntegerAttribute((WellKnownMember)462, ImmutableArray<TypedConstant>.Empty);
}
else
{
NamedTypeSymbol specialType = base.Compilation.GetSpecialType((SpecialType)7);
ImmutableArray<TypedConstant> immutableArray = ArrayBuilderExtensions.SelectAsArray<bool, NamedTypeSymbol, TypedConstant>(instance, (Func<bool, NamedTypeSymbol, TypedConstant>)((bool flag, NamedTypeSymbol constantType) => new TypedConstant((ITypeSymbolInternal)(object)constantType, (TypedConstantKind)1, (object)flag)), specialType);
ImmutableArray<TypedConstant> arguments = ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)ArrayTypeSymbol.CreateSZArray(specialType.ContainingAssembly, TypeWithAnnotations.Create(specialType)), immutableArray));
result = SynthesizeNativeIntegerAttribute((WellKnownMember)463, arguments);
}
instance.Free();
return result;
}
internal virtual SynthesizedAttributeData SynthesizeNativeIntegerAttribute(WellKnownMember member, ImmutableArray<TypedConstant> arguments)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return base.Compilation.TrySynthesizeAttribute(member, arguments, default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
}
internal SynthesizedAttributeData SynthesizeScopedRefAttribute(ParameterSymbol symbol, ScopedKind scope)
{
if ((object)base.Compilation.SourceModule != symbol.ContainingModule)
{
return null;
}
return SynthesizeScopedRefAttribute((WellKnownMember)471);
}
internal virtual SynthesizedAttributeData SynthesizeScopedRefAttribute(WellKnownMember member)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return base.Compilation.TrySynthesizeAttribute(member, default(ImmutableArray<TypedConstant>), default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
}
internal virtual SynthesizedAttributeData SynthesizeRefSafetyRulesAttribute(ImmutableArray<TypedConstant> arguments)
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)472, arguments, default(ImmutableArray<KeyValuePair<WellKnownMember, TypedConstant>>), isOptionalUse: true);
}
internal bool ShouldEmitNullablePublicOnlyAttribute()
{
if (base.Compilation.GetUsesNullableAttributes())
{
return base.Compilation.EmitNullablePublicOnly;
}
return false;
}
internal virtual SynthesizedAttributeData SynthesizeNullablePublicOnlyAttribute(ImmutableArray<TypedConstant> arguments)
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)392, arguments);
}
protected virtual SynthesizedAttributeData TrySynthesizeIsReadOnlyAttribute()
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)394);
}
protected virtual SynthesizedAttributeData TrySynthesizeRequiresLocationAttribute()
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)395);
}
protected virtual SynthesizedAttributeData TrySynthesizeIsUnmanagedAttribute()
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)409);
}
protected virtual SynthesizedAttributeData TrySynthesizeIsByRefLikeAttribute()
{
return base.Compilation.TrySynthesizeAttribute((WellKnownMember)396);
}
private void EnsureEmbeddableAttributeExists(EmbeddableAttributes attribute)
{
if ((GetNeedsGeneratedAttributesInternal() & attribute) == 0 && base.Compilation.CheckIfAttributeShouldBeEmbedded(attribute, null, null))
{
SetNeedsGeneratedAttributes(attribute);
}
}
internal void EnsureIsReadOnlyAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.IsReadOnlyAttribute);
}
internal void EnsureRequiresLocationAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.RequiresLocationAttribute);
}
internal void EnsureIsUnmanagedAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.IsUnmanagedAttribute);
}
internal void EnsureNullableAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.NullableAttribute);
}
internal void EnsureNullableContextAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.NullableContextAttribute);
}
internal void EnsureNativeIntegerAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.NativeIntegerAttribute);
}
internal void EnsureScopedRefAttributeExists()
{
EnsureEmbeddableAttributeExists(EmbeddableAttributes.ScopedRefAttribute);
}
internal MethodSymbol EnsureThrowSwitchExpressionExceptionExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "ThrowSwitchExpressionException", delegate(SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, SyntheticBoundNodeFactory syntheticBoundNodeFactory)
{
TypeSymbol returnType = syntheticBoundNodeFactory.SpecialType((SpecialType)6);
TypeSymbol paramType = syntheticBoundNodeFactory.SpecialType((SpecialType)1);
return new SynthesizedThrowSwitchExpressionExceptionMethod(sourceModule, privateImplClass, returnType, paramType);
}, factory, diagnostics);
}
private MethodSymbol EnsurePrivateImplClassMethodExists<TArg>(SyntaxNode syntaxNode, string methodName, Func<SourceModuleSymbol, PrivateImplementationDetails, TArg, MethodSymbol> createMethodSymbol, TArg arg, DiagnosticBag diagnostics)
{
PrivateImplementationDetails privateImplClass = base.GetPrivateImplClass(syntaxNode, diagnostics);
IMethodDefinition method = privateImplClass.GetMethod(methodName);
if (method != null)
{
return (MethodSymbol)(object)((IReference)method).GetInternalSymbol();
}
MethodSymbol methodSymbol = createMethodSymbol(base.SourceModule, privateImplClass, arg);
privateImplClass.TryAddSynthesizedMethod((IMethodDefinition)(object)methodSymbol.GetCciAdapter());
return (MethodSymbol)(object)((IReference)privateImplClass.GetMethod(methodName)).GetInternalSymbol();
}
internal MethodSymbol EnsureThrowSwitchExpressionExceptionParameterlessExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "ThrowSwitchExpressionExceptionParameterless", delegate(SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, SyntheticBoundNodeFactory syntheticBoundNodeFactory)
{
TypeSymbol returnType = syntheticBoundNodeFactory.SpecialType((SpecialType)6);
return new SynthesizedParameterlessThrowMethod(sourceModule, privateImplClass, returnType, "ThrowSwitchExpressionExceptionParameterless", syntheticBoundNodeFactory.WellKnownMethod((WellKnownMember)455));
}, factory, diagnostics);
}
internal MethodSymbol EnsureThrowInvalidOperationExceptionExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "ThrowInvalidOperationException", delegate(SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, SyntheticBoundNodeFactory syntheticBoundNodeFactory)
{
TypeSymbol returnType = syntheticBoundNodeFactory.SpecialType((SpecialType)6);
return new SynthesizedParameterlessThrowMethod(sourceModule, privateImplClass, returnType, "ThrowInvalidOperationException", syntheticBoundNodeFactory.WellKnownMethod((WellKnownMember)453));
}, factory, diagnostics);
}
internal MethodSymbol EnsureInlineArrayAsSpanExists(SyntaxNode syntaxNode, NamedTypeSymbol spanType, NamedTypeSymbol intType, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayAsSpan", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, (NamedTypeSymbol spanType, NamedTypeSymbol intType) arg) => new SynthesizedInlineArrayAsSpanMethod(sourceModule, privateImplClass, "InlineArrayAsSpan", arg.spanType, arg.intType), (spanType, intType), diagnostics);
}
internal NamedTypeSymbol EnsureInlineArrayTypeExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, int arrayLength, DiagnosticBag diagnostics)
{
string text = GeneratedNames.MakeSynthesizedInlineArrayName(arrayLength, ((CommonPEModuleBuilder)this).CurrentGenerationOrdinal);
PrivateImplementationDetails privateImplClass = base.GetPrivateImplClass(syntaxNode, diagnostics);
INamespaceTypeDefinition synthesizedType = privateImplClass.GetSynthesizedType(text);
if (synthesizedType == null)
{
MethodSymbol inlineArrayAttributeConstructor = (MethodSymbol)factory.SpecialMember((SpecialMember)127);
SynthesizedInlineArrayTypeSymbol synthesizedInlineArrayTypeSymbol = new SynthesizedInlineArrayTypeSymbol(base.SourceModule, text, arrayLength, inlineArrayAttributeConstructor);
privateImplClass.TryAddSynthesizedType((INamespaceTypeDefinition)(object)synthesizedInlineArrayTypeSymbol.GetCciAdapter());
synthesizedType = privateImplClass.GetSynthesizedType(text);
}
return (NamedTypeSymbol)(object)((IReference)synthesizedType).GetInternalSymbol();
}
internal NamedTypeSymbol EnsureReadOnlyListTypeExists(SyntaxNode syntaxNode, bool hasKnownLength, DiagnosticBag diagnostics)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
string text = GeneratedNames.MakeSynthesizedReadOnlyListName(hasKnownLength, ((CommonPEModuleBuilder)this).CurrentGenerationOrdinal);
PrivateImplementationDetails privateImplClass = base.GetPrivateImplClass(syntaxNode, diagnostics);
INamespaceTypeDefinition synthesizedType = privateImplClass.GetSynthesizedType(text);
NamedTypeSymbol namedTypeSymbol;
if (synthesizedType == null)
{
namedTypeSymbol = SynthesizedReadOnlyListTypeSymbol.Create(base.SourceModule, text, hasKnownLength);
privateImplClass.TryAddSynthesizedType((INamespaceTypeDefinition)(object)namedTypeSymbol.GetCciAdapter());
synthesizedType = privateImplClass.GetSynthesizedType(text);
}
namedTypeSymbol = (NamedTypeSymbol)(object)((IReference)synthesizedType).GetInternalSymbol();
DiagnosticInfo diagnosticInfo = namedTypeSymbol.GetUseSiteInfo().DiagnosticInfo;
if (diagnosticInfo != null)
{
Symbol.ReportUseSiteDiagnostic(diagnosticInfo, diagnostics, syntaxNode.Location);
}
return namedTypeSymbol;
}
internal MethodSymbol EnsureInlineArrayAsReadOnlySpanExists(SyntaxNode syntaxNode, NamedTypeSymbol spanType, NamedTypeSymbol intType, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayAsReadOnlySpan", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, (NamedTypeSymbol spanType, NamedTypeSymbol intType) arg) => new SynthesizedInlineArrayAsReadOnlySpanMethod(sourceModule, privateImplClass, "InlineArrayAsReadOnlySpan", arg.spanType, arg.intType), (spanType, intType), diagnostics);
}
internal MethodSymbol EnsureInlineArrayElementRefExists(SyntaxNode syntaxNode, NamedTypeSymbol intType, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayElementRef", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, NamedTypeSymbol intType2) => new SynthesizedInlineArrayElementRefMethod(sourceModule, privateImplClass, "InlineArrayElementRef", intType2), intType, diagnostics);
}
internal MethodSymbol EnsureInlineArrayElementRefReadOnlyExists(SyntaxNode syntaxNode, NamedTypeSymbol intType, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayElementRefReadOnly", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, NamedTypeSymbol intType2) => new SynthesizedInlineArrayElementRefReadOnlyMethod(sourceModule, privateImplClass, "InlineArrayElementRefReadOnly", intType2), intType, diagnostics);
}
internal MethodSymbol EnsureInlineArrayFirstElementRefExists(SyntaxNode syntaxNode, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayFirstElementRef", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, object _) => new SynthesizedInlineArrayFirstElementRefMethod(sourceModule, privateImplClass, "InlineArrayFirstElementRef"), null, diagnostics);
}
internal MethodSymbol EnsureInlineArrayFirstElementRefReadOnlyExists(SyntaxNode syntaxNode, DiagnosticBag diagnostics)
{
return EnsurePrivateImplClassMethodExists(syntaxNode, "InlineArrayFirstElementRefReadOnly", (SourceModuleSymbol sourceModule, PrivateImplementationDetails privateImplClass, object _) => new SynthesizedInlineArrayFirstElementRefReadOnlyMethod(sourceModule, privateImplClass, "InlineArrayFirstElementRefReadOnly"), null, diagnostics);
}
public override IEnumerable<INamespaceTypeDefinition> GetAdditionalTopLevelTypeDefinitions(EmitContext context)
{
return (IEnumerable<INamespaceTypeDefinition>)(object)((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).GetAdditionalTopLevelTypes();
}
public override IEnumerable<INamespaceTypeDefinition> GetEmbeddedTypeDefinitions(EmitContext context)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return (IEnumerable<INamespaceTypeDefinition>)(object)((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)this).GetEmbeddedTypes(context.Diagnostics);
}
public sealed override ImmutableArray<NamedTypeSymbol> GetEmbeddedTypes(DiagnosticBag diagnostics)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies: false);
ImmutableArray<NamedTypeSymbol> embeddedTypes = GetEmbeddedTypes(instance);
diagnostics.AddRange(((BindingDiagnosticBag)instance).DiagnosticBag);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
return embeddedTypes;
}
internal virtual ImmutableArray<NamedTypeSymbol> GetEmbeddedTypes(BindingDiagnosticBag diagnostics)
{
return base.GetEmbeddedTypes(((BindingDiagnosticBag)diagnostics).DiagnosticBag);
}
internal bool TryGetTranslatedImports(ImportChain chain, out ImmutableArray<UsedNamespaceOrType> imports)
{
return _translatedImportsMap.TryGetValue(chain, out imports);
}
internal ImmutableArray<UsedNamespaceOrType> GetOrAddTranslatedImports(ImportChain chain, ImmutableArray<UsedNamespaceOrType> imports)
{
return _translatedImportsMap.GetOrAdd(chain, imports);
}
}