Browse Source

Rename TypeAttributeOptions -> TypeSystemOptions

pull/1198/head
Daniel Grunwald 7 years ago
parent
commit
5c0190b186
  1. 20
      ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
  2. 56
      ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
  3. 60
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeReference.cs
  4. 47
      ICSharpCode.Decompiler/TypeSystem/MetadataLoader.cs

20
ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs

@ -25,18 +25,6 @@ using SRM = System.Reflection.Metadata;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary>
/// Options for converting builtin
/// </summary>
[Flags]
enum TypeAttributeOptions
{
None = 0,
Dynamic = 1,
Tuple = 2,
Default = Dynamic | Tuple
}
/// <summary> /// <summary>
/// Introduces 'dynamic' and tuple types based on attribute values. /// Introduces 'dynamic' and tuple types based on attribute values.
/// </summary> /// </summary>
@ -47,20 +35,20 @@ namespace ICSharpCode.Decompiler.TypeSystem
ICompilation compilation, ICompilation compilation,
SRM.CustomAttributeHandleCollection? attributes, SRM.CustomAttributeHandleCollection? attributes,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
TypeAttributeOptions options) TypeSystemOptions options)
{ {
if (options == TypeAttributeOptions.None) { if ((options & (TypeSystemOptions.Dynamic | TypeSystemOptions.Tuple)) == TypeSystemOptions.None) {
return inputType; return inputType;
} }
bool hasDynamicAttribute = false; bool hasDynamicAttribute = false;
bool[] dynamicAttributeData = null; bool[] dynamicAttributeData = null;
bool useTupleTypes = (options & TypeAttributeOptions.Tuple) != 0; bool useTupleTypes = (options & TypeSystemOptions.Tuple) != 0;
string[] tupleElementNames = null; string[] tupleElementNames = null;
if (attributes != null) { if (attributes != null) {
foreach (var attrHandle in attributes.Value) { foreach (var attrHandle in attributes.Value) {
var attr = metadata.GetCustomAttribute(attrHandle); var attr = metadata.GetCustomAttribute(attrHandle);
var attrType = attr.GetAttributeType(metadata); var attrType = attr.GetAttributeType(metadata);
if ((options & TypeAttributeOptions.Dynamic) != 0 if ((options & TypeSystemOptions.Dynamic) != 0
&& attrType.IsTopLevelType(metadata, "System.Runtime.CompilerServices", "DynamicAttribute")) { && attrType.IsTopLevelType(metadata, "System.Runtime.CompilerServices", "DynamicAttribute")) {
hasDynamicAttribute = true; hasDynamicAttribute = true;
var ctor = attr.DecodeValue(Metadata.MetadataExtensions.minimalCorlibTypeProvider); var ctor = attr.DecodeValue(Metadata.MetadataExtensions.minimalCorlibTypeProvider);

56
ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs

@ -29,6 +29,40 @@ using System.Collections.Immutable;
namespace ICSharpCode.Decompiler.TypeSystem namespace ICSharpCode.Decompiler.TypeSystem
{ {
/// <summary>
/// Options that control how metadata is represented in the type system.
/// </summary>
[Flags]
public enum TypeSystemOptions
{
/// <summary>
/// No options enabled; stay as close to the metadata as possible.
/// </summary>
None = 0,
/// <summary>
/// [DynamicAttribute] is used to replace 'object' types with the 'dynamic' type.
///
/// If this option is not active, the 'dynamic' type is not used, and the attribute is preserved.
/// </summary>
Dynamic = 1,
/// <summary>
/// Tuple types are represented using the TupleType class.
/// [TupleElementNames] is used to name the tuple elements.
///
/// If this option is not active, the tuples are represented using their underlying type, and the attribute is preserved.
/// </summary>
Tuple = 2,
/// <summary>
/// If this option is active, [ExtensionAttribute] is removed and methods are marked as IsExtensionMethod.
/// Otherwise, the attribute is preserved but the methods are not marked.
/// </summary>
ExtensionMethods = 4,
/// <summary>
/// Default settings: all features enabled.
/// </summary>
Default = Dynamic | Tuple | ExtensionMethods
}
/// <summary> /// <summary>
/// Manages the NRefactory type system for the decompiler. /// Manages the NRefactory type system for the decompiler.
/// </summary> /// </summary>
@ -40,7 +74,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
readonly Metadata.PEFile moduleDefinition; readonly Metadata.PEFile moduleDefinition;
readonly ICompilation compilation; readonly ICompilation compilation;
readonly ITypeResolveContext context; readonly ITypeResolveContext context;
readonly TypeAttributeOptions typeAttributeOptions; readonly TypeSystemOptions typeSystemOptions;
Dictionary<SRM.EntityHandle, IField> fieldLookupCache = new Dictionary<SRM.EntityHandle, IField>(); Dictionary<SRM.EntityHandle, IField> fieldLookupCache = new Dictionary<SRM.EntityHandle, IField>();
Dictionary<SRM.EntityHandle, IProperty> propertyLookupCache = new Dictionary<SRM.EntityHandle, IProperty>(); Dictionary<SRM.EntityHandle, IProperty> propertyLookupCache = new Dictionary<SRM.EntityHandle, IProperty>();
@ -58,17 +92,17 @@ namespace ICSharpCode.Decompiler.TypeSystem
if (settings == null) if (settings == null)
throw new ArgumentNullException(nameof(settings)); throw new ArgumentNullException(nameof(settings));
this.moduleDefinition = moduleDefinition; this.moduleDefinition = moduleDefinition;
typeAttributeOptions = TypeAttributeOptions.None; typeSystemOptions = TypeSystemOptions.None;
if (settings.Dynamic) if (settings.Dynamic)
typeAttributeOptions |= TypeAttributeOptions.Dynamic; typeSystemOptions |= TypeSystemOptions.Dynamic;
if (settings.TupleTypes) if (settings.TupleTypes)
typeAttributeOptions |= TypeAttributeOptions.Tuple; typeSystemOptions |= TypeSystemOptions.Tuple;
if (settings.ExtensionMethods)
typeSystemOptions |= TypeSystemOptions.ExtensionMethods;
MetadataLoader loader = new MetadataLoader { MetadataLoader loader = new MetadataLoader {
IncludeInternalMembers = true, IncludeInternalMembers = true,
ShortenInterfaceImplNames = false, ShortenInterfaceImplNames = false,
UseDynamicType = settings.Dynamic, Options = typeSystemOptions,
UseTupleTypes = settings.TupleTypes,
UseExtensionMethods = settings.ExtensionMethods,
}; };
IUnresolvedAssembly mainAssembly = loader.LoadModule(moduleDefinition); IUnresolvedAssembly mainAssembly = loader.LoadModule(moduleDefinition);
// Load referenced assemblies and type-forwarder references. // Load referenced assemblies and type-forwarder references.
@ -160,8 +194,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
typeReference, typeReference,
moduleDefinition.Metadata, moduleDefinition.Metadata,
context, context,
typeAttributes: null, typeSystemOptions
typeAttributeOptions
); );
} }
@ -172,8 +205,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
declaringTypeReference, declaringTypeReference,
moduleDefinition.Metadata, moduleDefinition.Metadata,
context, context,
typeAttributes: null, typeSystemOptions & ~(TypeSystemOptions.Dynamic | TypeSystemOptions.Tuple)
attributeOptions: TypeAttributeOptions.None
); );
} }
#endregion #endregion
@ -226,7 +258,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
field = new FakeField(compilation) { field = new FakeField(compilation) {
DeclaringType = declaringType, DeclaringType = declaringType,
Name = metadata.GetString(fieldDef.Name), Name = metadata.GetString(fieldDef.Name),
ReturnType = FieldTypeReference.Resolve(fieldDefHandle, metadata, context, typeAttributeOptions), ReturnType = FieldTypeReference.Resolve(fieldDefHandle, metadata, context, typeSystemOptions),
IsStatic = (fieldDef.Attributes & System.Reflection.FieldAttributes.Static) != 0, IsStatic = (fieldDef.Attributes & System.Reflection.FieldAttributes.Static) != 0,
}; };
} }

60
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeReference.cs

@ -30,30 +30,30 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
readonly SRM.EntityHandle type; readonly SRM.EntityHandle type;
readonly SRM.MetadataReader metadata; readonly SRM.MetadataReader metadata;
readonly SRM.CustomAttributeHandleCollection? typeAttributes; readonly SRM.CustomAttributeHandleCollection? typeAttributes;
readonly TypeAttributeOptions attributeOptions; readonly TypeSystemOptions options;
public MetadataTypeReference(SRM.EntityHandle type, public MetadataTypeReference(SRM.EntityHandle type,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
SRM.CustomAttributeHandleCollection? typeAttributes, SRM.CustomAttributeHandleCollection? typeAttributes,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
this.type = type; this.type = type;
this.metadata = metadata; this.metadata = metadata;
this.typeAttributes = typeAttributes; this.typeAttributes = typeAttributes;
this.attributeOptions = attributeOptions; this.options = options;
} }
public IType Resolve(ITypeResolveContext context) public IType Resolve(ITypeResolveContext context)
{ {
return Resolve(type, metadata, context, return Resolve(type, metadata, context,
typeAttributes, attributeOptions); options, typeAttributes);
} }
public static IType Resolve(SRM.EntityHandle type, public static IType Resolve(SRM.EntityHandle type,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
ITypeResolveContext context, ITypeResolveContext context,
SRM.CustomAttributeHandleCollection? typeAttributes, TypeSystemOptions options,
TypeAttributeOptions attributeOptions) SRM.CustomAttributeHandleCollection? typeAttributes = null)
{ {
if (type.IsNil) if (type.IsNil)
return SpecialType.UnknownType; return SpecialType.UnknownType;
@ -76,7 +76,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
break; break;
} }
ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation, ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation,
typeAttributes, metadata, attributeOptions); typeAttributes, metadata, options);
return ty; return ty;
} }
} }
@ -85,35 +85,35 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{ {
readonly SRM.EntityHandle fieldHandle; readonly SRM.EntityHandle fieldHandle;
readonly SRM.MetadataReader metadata; readonly SRM.MetadataReader metadata;
readonly TypeAttributeOptions attributeOptions; readonly TypeSystemOptions options;
public FieldTypeReference(SRM.FieldDefinitionHandle fieldHandle, public FieldTypeReference(SRM.FieldDefinitionHandle fieldHandle,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
this.fieldHandle = fieldHandle; this.fieldHandle = fieldHandle;
this.metadata = metadata; this.metadata = metadata;
this.attributeOptions = attributeOptions; this.options = options;
} }
public FieldTypeReference(SRM.MemberReferenceHandle fieldReferenceHandle, public FieldTypeReference(SRM.MemberReferenceHandle fieldReferenceHandle,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
TypeAttributeOptions attributeOptions) TypeSystemOptions attributeOptions)
{ {
this.fieldHandle = fieldReferenceHandle; this.fieldHandle = fieldReferenceHandle;
this.metadata = metadata; this.metadata = metadata;
this.attributeOptions = attributeOptions; this.options = attributeOptions;
} }
IType ITypeReference.Resolve(ITypeResolveContext context) IType ITypeReference.Resolve(ITypeResolveContext context)
{ {
if (fieldHandle.Kind == SRM.HandleKind.FieldDefinition) { if (fieldHandle.Kind == SRM.HandleKind.FieldDefinition) {
return Resolve((SRM.FieldDefinitionHandle)fieldHandle, metadata, context, attributeOptions); return Resolve((SRM.FieldDefinitionHandle)fieldHandle, metadata, context, options);
} else { } else {
var memberRef = metadata.GetMemberReference((SRM.MemberReferenceHandle)fieldHandle); var memberRef = metadata.GetMemberReference((SRM.MemberReferenceHandle)fieldHandle);
IType ty = memberRef.DecodeFieldSignature(new TypeProvider(context.CurrentAssembly), context); IType ty = memberRef.DecodeFieldSignature(new TypeProvider(context.CurrentAssembly), context);
ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation, ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation,
memberRef.GetCustomAttributes(), metadata, attributeOptions); memberRef.GetCustomAttributes(), metadata, options);
return ty; return ty;
} }
} }
@ -121,12 +121,12 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public static IType Resolve(SRM.FieldDefinitionHandle fieldHandle, public static IType Resolve(SRM.FieldDefinitionHandle fieldHandle,
SRM.MetadataReader metadata, SRM.MetadataReader metadata,
ITypeResolveContext context, ITypeResolveContext context,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
var fieldDef = metadata.GetFieldDefinition(fieldHandle); var fieldDef = metadata.GetFieldDefinition(fieldHandle);
IType ty = fieldDef.DecodeSignature(new TypeProvider(context.CurrentAssembly), context); IType ty = fieldDef.DecodeSignature(new TypeProvider(context.CurrentAssembly), context);
ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation, ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, context.Compilation,
fieldDef.GetCustomAttributes(), metadata, attributeOptions); fieldDef.GetCustomAttributes(), metadata, options);
return ty; return ty;
} }
} }
@ -138,22 +138,22 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{ {
readonly SRM.EntityHandle handle; readonly SRM.EntityHandle handle;
readonly SRM.MetadataReader metadata; readonly SRM.MetadataReader metadata;
readonly TypeAttributeOptions attributeOptions; readonly TypeSystemOptions options;
public UnresolvedMethodSignature(SRM.MethodDefinitionHandle handle, SRM.MetadataReader metadata, public UnresolvedMethodSignature(SRM.MethodDefinitionHandle handle, SRM.MetadataReader metadata,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
this.handle = handle; this.handle = handle;
this.metadata = metadata; this.metadata = metadata;
this.attributeOptions = attributeOptions; this.options = options;
} }
public UnresolvedMethodSignature(SRM.PropertyDefinitionHandle handle, SRM.MetadataReader metadata, public UnresolvedMethodSignature(SRM.PropertyDefinitionHandle handle, SRM.MetadataReader metadata,
TypeAttributeOptions attributeOptions) TypeSystemOptions attributeOptions)
{ {
this.handle = handle; this.handle = handle;
this.metadata = metadata; this.metadata = metadata;
this.attributeOptions = attributeOptions; this.options = attributeOptions;
} }
public SRM.MethodSignature<IType> Resolve(ITypeResolveContext context) public SRM.MethodSignature<IType> Resolve(ITypeResolveContext context)
@ -165,12 +165,12 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
case SRM.HandleKind.MethodDefinition: case SRM.HandleKind.MethodDefinition:
return GetSignature( return GetSignature(
metadata.GetMethodDefinition((SRM.MethodDefinitionHandle)handle), metadata.GetMethodDefinition((SRM.MethodDefinitionHandle)handle),
metadata, context, attributeOptions metadata, context, options
); );
case SRM.HandleKind.PropertyDefinition: case SRM.HandleKind.PropertyDefinition:
return GetSignature( return GetSignature(
metadata.GetPropertyDefinition((SRM.PropertyDefinitionHandle)handle), metadata.GetPropertyDefinition((SRM.PropertyDefinitionHandle)handle),
metadata, context, attributeOptions metadata, context, options
); );
default: default:
throw new InvalidOperationException(); throw new InvalidOperationException();
@ -181,16 +181,16 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public static SRM.MethodSignature<IType> GetSignature(SRM.MethodDefinition methodDef, public static SRM.MethodSignature<IType> GetSignature(SRM.MethodDefinition methodDef,
SRM.MetadataReader metadata, ITypeResolveContext context, SRM.MetadataReader metadata, ITypeResolveContext context,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
var typeProvider = new TypeProvider(context.CurrentAssembly); var typeProvider = new TypeProvider(context.CurrentAssembly);
var signature = methodDef.DecodeSignature(typeProvider, context); var signature = methodDef.DecodeSignature(typeProvider, context);
return ApplyAttributes(signature, methodDef.GetParameters(), context.Compilation, metadata, attributeOptions); return ApplyAttributes(signature, methodDef.GetParameters(), context.Compilation, metadata, options);
} }
public static SRM.MethodSignature<IType> GetSignature(SRM.PropertyDefinition propertyDef, public static SRM.MethodSignature<IType> GetSignature(SRM.PropertyDefinition propertyDef,
SRM.MetadataReader metadata, ITypeResolveContext context, SRM.MetadataReader metadata, ITypeResolveContext context,
TypeAttributeOptions attributeOptions) TypeSystemOptions options)
{ {
var typeProvider = new TypeProvider(context.CurrentAssembly); var typeProvider = new TypeProvider(context.CurrentAssembly);
var signature = propertyDef.DecodeSignature(typeProvider, context); var signature = propertyDef.DecodeSignature(typeProvider, context);
@ -205,10 +205,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
parameterHandles = setter.GetParameters(); parameterHandles = setter.GetParameters();
} }
} }
return ApplyAttributes(signature, parameterHandles, context.Compilation, metadata, attributeOptions); return ApplyAttributes(signature, parameterHandles, context.Compilation, metadata, options);
} }
static SRM.MethodSignature<IType> ApplyAttributes(SRM.MethodSignature<IType> signature, SRM.ParameterHandleCollection? parameterHandles, ICompilation compilation, SRM.MetadataReader metadata, TypeAttributeOptions attributeOptions) static SRM.MethodSignature<IType> ApplyAttributes(SRM.MethodSignature<IType> signature, SRM.ParameterHandleCollection? parameterHandles, ICompilation compilation, SRM.MetadataReader metadata, TypeSystemOptions options)
{ {
SRM.CustomAttributeHandleCollection? returnTypeAttributes = null; SRM.CustomAttributeHandleCollection? returnTypeAttributes = null;
var parameterAttributes = new SRM.CustomAttributeHandleCollection?[signature.ParameterTypes.Length]; var parameterAttributes = new SRM.CustomAttributeHandleCollection?[signature.ParameterTypes.Length];
@ -223,11 +223,11 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
} }
} }
IType returnType = ApplyAttributeTypeVisitor.ApplyAttributesToType( IType returnType = ApplyAttributeTypeVisitor.ApplyAttributesToType(
signature.ReturnType, compilation, returnTypeAttributes, metadata, attributeOptions signature.ReturnType, compilation, returnTypeAttributes, metadata, options
); );
var parameterTypes = signature.ParameterTypes.SelectWithIndex( var parameterTypes = signature.ParameterTypes.SelectWithIndex(
(i, p) => ApplyAttributeTypeVisitor.ApplyAttributesToType( (i, p) => ApplyAttributeTypeVisitor.ApplyAttributesToType(
p, compilation, parameterAttributes[i], metadata, attributeOptions p, compilation, parameterAttributes[i], metadata, options
) )
).ToImmutableArray(); ).ToImmutableArray();
return new SRM.MethodSignature<IType>( return new SRM.MethodSignature<IType>(

47
ICSharpCode.Decompiler/TypeSystem/MetadataLoader.cs

@ -50,19 +50,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
public bool IncludeInternalMembers { get; set; } public bool IncludeInternalMembers { get; set; }
/// <summary> /// <summary>
/// Gets/Sets whether to use the <c>dynamic</c> type. /// Gets/Sets type system options.
/// </summary> /// </summary>
public bool UseDynamicType { get; set; } = true; public TypeSystemOptions Options { get; set; }
/// <summary>
/// Gets/Sets whether to use the tuple types.
/// </summary>
public bool UseTupleTypes { get; set; } = true;
/// <summary>
/// Gets/Sets whether to use extension methods.
/// </summary>
public bool UseExtensionMethods { get; set; } = true;
/// <summary> /// <summary>
/// Gets/Sets the cancellation token used by the assembly loader. /// Gets/Sets the cancellation token used by the assembly loader.
@ -136,9 +126,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
this.IncludeInternalMembers = loader.IncludeInternalMembers; this.IncludeInternalMembers = loader.IncludeInternalMembers;
this.LazyLoad = loader.LazyLoad; this.LazyLoad = loader.LazyLoad;
this.ShortenInterfaceImplNames = loader.ShortenInterfaceImplNames; this.ShortenInterfaceImplNames = loader.ShortenInterfaceImplNames;
this.UseDynamicType = loader.UseDynamicType; this.Options = loader.Options;
this.UseTupleTypes = loader.UseTupleTypes;
this.UseExtensionMethods = loader.UseExtensionMethods;
this.currentModule = loader.currentModule; this.currentModule = loader.currentModule;
this.currentMetadata = loader.currentMetadata; this.currentMetadata = loader.currentMetadata;
this.currentAssembly = loader.currentAssembly; this.currentAssembly = loader.currentAssembly;
@ -298,18 +286,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </param> /// </param>
public ITypeReference ReadTypeReference(EntityHandle type, CustomAttributeHandleCollection? typeAttributes = null) public ITypeReference ReadTypeReference(EntityHandle type, CustomAttributeHandleCollection? typeAttributes = null)
{ {
return new MetadataTypeReference(type, currentMetadata, typeAttributes, TypeAttributeOptions); return new MetadataTypeReference(type, currentMetadata, typeAttributes, Options);
}
private TypeAttributeOptions TypeAttributeOptions {
get {
TypeAttributeOptions options = TypeAttributeOptions.None;
if (UseDynamicType)
options |= TypeAttributeOptions.Dynamic;
if (UseTupleTypes)
options |= TypeAttributeOptions.Tuple;
return options;
}
} }
#endregion #endregion
@ -695,11 +672,11 @@ namespace ICSharpCode.Decompiler.TypeSystem
case "System.Runtime.CompilerServices": case "System.Runtime.CompilerServices":
switch (typeName.Name) { switch (typeName.Name) {
case "DynamicAttribute": case "DynamicAttribute":
return UseDynamicType; return (Options & TypeSystemOptions.Dynamic) != 0;
case "TupleElementNamesAttribute": case "TupleElementNamesAttribute":
return UseTupleTypes; return (Options & TypeSystemOptions.Tuple) != 0;
case "ExtensionAttribute": case "ExtensionAttribute":
return UseExtensionMethods; return (Options & TypeSystemOptions.ExtensionMethods) != 0;
case "DecimalConstantAttribute": case "DecimalConstantAttribute":
return true; return true;
default: default:
@ -827,7 +804,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
foreach (FieldDefinitionHandle h in typeDefinition.GetFields()) { foreach (FieldDefinitionHandle h in typeDefinition.GetFields()) {
var enumField = currentMetadata.GetFieldDefinition(h); var enumField = currentMetadata.GetFieldDefinition(h);
if (!enumField.HasFlag(FieldAttributes.Static)) { if (!enumField.HasFlag(FieldAttributes.Static)) {
baseTypes.Add(new FieldTypeReference(h, currentMetadata, TypeAttributeOptions.None)); baseTypes.Add(new FieldTypeReference(h, currentMetadata, TypeSystemOptions.None));
break; break;
} }
} }
@ -1233,7 +1210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
TranslateModifiers(handle, m); TranslateModifiers(handle, m);
var signature = method.DecodeSignature(TypeCodeProvider.Instance, default); var signature = method.DecodeSignature(TypeCodeProvider.Instance, default);
var unresolvedSig = new UnresolvedMethodSignature(handle, currentMetadata, TypeAttributeOptions); var unresolvedSig = new UnresolvedMethodSignature(handle, currentMetadata, Options);
var (retType, parameters) = TranslateSignature(signature, unresolvedSig, method.GetParameters()); var (retType, parameters) = TranslateSignature(signature, unresolvedSig, method.GetParameters());
m.ReturnType = retType; m.ReturnType = retType;
m.Parameters.AddRange(parameters); m.Parameters.AddRange(parameters);
@ -1354,7 +1331,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
bool HasExtensionAttribute(MetadataReader metadata, CustomAttributeHandleCollection attributes) bool HasExtensionAttribute(MetadataReader metadata, CustomAttributeHandleCollection attributes)
{ {
if (!UseExtensionMethods) if ((Options & TypeSystemOptions.ExtensionMethods) == 0)
return false; return false;
foreach (var h in attributes) { foreach (var h in attributes) {
var attr = metadata.GetCustomAttribute(h); var attr = metadata.GetCustomAttribute(h);
@ -1506,7 +1483,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
f.Accessibility = GetAccessibility(field.Attributes); f.Accessibility = GetAccessibility(field.Attributes);
f.IsReadOnly = (field.Attributes & FieldAttributes.InitOnly) == FieldAttributes.InitOnly; f.IsReadOnly = (field.Attributes & FieldAttributes.InitOnly) == FieldAttributes.InitOnly;
f.IsStatic = (field.Attributes & FieldAttributes.Static) == FieldAttributes.Static; f.IsStatic = (field.Attributes & FieldAttributes.Static) == FieldAttributes.Static;
f.ReturnType = new FieldTypeReference(handle, currentMetadata, TypeAttributeOptions); f.ReturnType = new FieldTypeReference(handle, currentMetadata, Options);
var constantHandle = field.GetDefaultValue(); var constantHandle = field.GetDefaultValue();
if (!constantHandle.IsNil) { if (!constantHandle.IsNil) {
var constant = currentMetadata.GetConstant(constantHandle); var constant = currentMetadata.GetConstant(constantHandle);
@ -1629,7 +1606,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} }
var signature = property.DecodeSignature(TypeCodeProvider.Instance, default); var signature = property.DecodeSignature(TypeCodeProvider.Instance, default);
var unresolvedSig = new UnresolvedMethodSignature(handle, currentMetadata, TypeAttributeOptions); var unresolvedSig = new UnresolvedMethodSignature(handle, currentMetadata, Options);
var (retType, parameters) = TranslateSignature(signature, unresolvedSig, parameterHandles); var (retType, parameters) = TranslateSignature(signature, unresolvedSig, parameterHandles);
p.ReturnType = retType; p.ReturnType = retType;
p.Parameters.AddRange(parameters); p.Parameters.AddRange(parameters);

Loading…
Cancel
Save