Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some missing attributes for types, fields and methods #37

Open
wants to merge 2 commits into
base: metadata-provider
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion MetadataProvider/AssemblyExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ private void ExtractType(SRM.TypeDefinitionHandle typedefHandle)
type.ContainingType = currentType;
type.ContainingAssembly = assembly;
type.ContainingNamespace = currentNamespace;
if (typedef.Attributes.HasFlag(SR.TypeAttributes.Abstract))
{
if (typedef.Attributes.HasFlag(SR.TypeAttributes.Sealed))
{
type.IsStatic = true;
}
else
{
type.IsAbstract = true;
}
}
else if (typedef.Attributes.HasFlag(SR.TypeAttributes.Sealed))
{
type.IsSealed = true;
}

type.BeforeFieldInit = typedef.Attributes.HasFlag(SR.TypeAttributes.BeforeFieldInit);
type.Serializable = typedef.Attributes.HasFlag(SR.TypeAttributes.Serializable);

currentType = type;

foreach (var handle in typedef.GetGenericParameters())
Expand Down Expand Up @@ -471,6 +490,10 @@ private void ExtractField(SRM.FieldDefinitionHandle handle)
field.IsStatic = fielddef.Attributes.HasFlag(SR.FieldAttributes.Static);
field.Visibility = GetVisibilityKind(fielddef.Attributes);
field.Value = ExtractFieldDefaultValue(fielddef);
field.IsReadonly = fielddef.Attributes.HasFlag(SR.FieldAttributes.InitOnly);
field.IsLiteral = fielddef.Attributes.HasFlag(SR.FieldAttributes.Literal);
field.SpecialName = fielddef.Attributes.HasFlag(SR.FieldAttributes.SpecialName);
field.RuntimeSpecialName = fielddef.Attributes.HasFlag(SR.FieldAttributes.RTSpecialName);

currentType.Fields.Add(field);
}
Expand Down Expand Up @@ -508,7 +531,11 @@ private void ExtractMethod(SRM.MethodDefinitionHandle methoddefHandle)
method.IsVirtual = methoddef.Attributes.HasFlag(SR.MethodAttributes.Virtual);
method.IsExternal = methoddef.Attributes.HasFlag(SR.MethodAttributes.PinvokeImpl);
method.IsConstructor = method.Name.EndsWith(".ctor");

method.HidesMember = methoddef.Attributes.HasFlag(SR.MethodAttributes.NewSlot);
method.IsSealed = methoddef.Attributes.HasFlag(SR.MethodAttributes.Final);
method.SpecialName = methoddef.Attributes.HasFlag(SR.MethodAttributes.SpecialName);
method.RuntimeSpecialName = methoddef.Attributes.HasFlag(SR.MethodAttributes.RTSpecialName);

currentType.Methods.Add(method);
currentMethod = method;

Expand Down
13 changes: 13 additions & 0 deletions Model/Types/TypeDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public class FieldDefinition : ITypeMemberDefinition, IFieldReference
public Constant Value { get; set; }

public bool IsStatic { get; set; }
public bool IsReadonly { get; set; }
public bool IsLiteral { get; set; }
public bool SpecialName { get; set; }
public bool RuntimeSpecialName { get; set; }

public FieldDefinition(string name, IType type)
{
Expand Down Expand Up @@ -412,6 +416,10 @@ public class MethodDefinition : ITypeMemberDefinition, IMethodReference, IGeneri
public bool IsVirtual { get; set; }
public bool IsConstructor { get; set; }
public bool IsExternal { get; set; }
public bool HidesMember { get; set; }
public bool IsSealed { get; set; }
public bool SpecialName { get; set; }
public bool RuntimeSpecialName { get; set; }
public MethodBody Body { get; set; }

public MethodDefinition(string name, IType returnType)
Expand Down Expand Up @@ -623,6 +631,11 @@ public class TypeDefinition : IBasicType, IGenericDefinition, ITypeMemberDefinit
public IList<MethodDefinition> Methods { get; private set; }
public IList<TypeDefinition> Types { get; private set; }
public IBasicType UnderlayingType { get; set; }
public bool IsStatic { get; set; }
public bool IsAbstract { get; set; }
public bool IsSealed { get; set; }
public bool BeforeFieldInit { get; set; }
public bool Serializable { get; set; }

public TypeDefinition(string name, TypeKind typeKind = TypeKind.Unknown, TypeDefinitionKind kind = TypeDefinitionKind.Unknown)
{
Expand Down