Browse Source

Fix #1975: readonly modifier is added to structs even if language version is lower than C# 7.0

pull/1984/head
Siegfried Pammer 5 years ago
parent
commit
e2df79ef70
  1. 6
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs

6
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataTypeDefinition.cs

@ -106,8 +106,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -106,8 +106,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.Kind = TypeKind.Void;
} else {
this.Kind = TypeKind.Struct;
this.IsByRefLike = td.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.IsByRefLike);
this.IsReadOnly = td.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.IsReadOnly);
this.IsByRefLike = (module.TypeSystemOptions & TypeSystemOptions.RefStructs) == TypeSystemOptions.RefStructs
&& td.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.IsByRefLike);
this.IsReadOnly = (module.TypeSystemOptions & TypeSystemOptions.ReadOnlyStructsAndParameters) == TypeSystemOptions.ReadOnlyStructsAndParameters
&& td.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.IsReadOnly);
}
} else if (td.IsDelegate(metadata)) {
this.Kind = TypeKind.Delegate;

Loading…
Cancel
Save