diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs index c073c3ae1..c56524281 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs @@ -47,6 +47,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } private static dynamic field; + private static volatile dynamic volatileField; private static object objectField; public dynamic Property { get; set; } diff --git a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs index 459ce0fdc..5235da470 100644 --- a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs +++ b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Daniel Grunwald +// Copyright (c) 2018 Daniel Grunwald // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software @@ -40,8 +40,7 @@ namespace ICSharpCode.Decompiler.TypeSystem SRM.MetadataReader metadata, TypeSystemOptions options, Nullability nullableContext, - bool typeChildrenOnly = false, - bool isSignatureReturnType = false) + bool typeChildrenOnly = false) { bool hasDynamicAttribute = false; bool[] dynamicAttributeData = null; @@ -134,14 +133,6 @@ namespace ICSharpCode.Decompiler.TypeSystem options, tupleElementNames, nullability, nullableAttributeData ); - if (isSignatureReturnType && hasDynamicAttribute - && inputType.SkipModifiers().Kind == TypeKind.ByReference - && attributes.Value.HasKnownAttribute(metadata, KnownAttribute.IsReadOnly)) - { - // crazy special case: `ref readonly` return takes one dynamic index more than - // a non-readonly `ref` return. - visitor.dynamicTypeIndex++; - } if (typeChildrenOnly) { return inputType.VisitChildren(visitor); @@ -190,6 +181,7 @@ namespace ICSharpCode.Decompiler.TypeSystem public override IType VisitModOpt(ModifiedType type) { + dynamicTypeIndex++; if ((options & TypeSystemOptions.KeepModifiers) != 0) return base.VisitModOpt(type); else @@ -198,6 +190,7 @@ namespace ICSharpCode.Decompiler.TypeSystem public override IType VisitModReq(ModifiedType type) { + dynamicTypeIndex++; if ((options & TypeSystemOptions.KeepModifiers) != 0) return base.VisitModReq(type); else diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs index f6a23d073..c8e045753 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataField.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Daniel Grunwald +// Copyright (c) 2018 Daniel Grunwald // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software @@ -225,7 +225,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation if (ty is ModifiedType mod && mod.Modifier.Name == "IsVolatile" && mod.Modifier.Namespace == "System.Runtime.CompilerServices") { Volatile.Write(ref this.isVolatile, true); - ty = mod.ElementType; } ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, Compilation, fieldDef.GetCustomAttributes(), metadata, module.OptionsForEntity(this), diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs index c3760e42e..3ebd754d7 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Daniel Grunwald +// Copyright (c) 2018 Daniel Grunwald // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software @@ -271,8 +271,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation } Debug.Assert(i == parameters.Length); var returnType = ApplyAttributeTypeVisitor.ApplyAttributesToType(signature.ReturnType, - module.Compilation, returnTypeAttributes, metadata, typeSystemOptions, nullableContext, - isSignatureReturnType: true); + module.Compilation, returnTypeAttributes, metadata, typeSystemOptions, nullableContext); return (returnType, parameters, signature.ReturnType as ModifiedType); } #endregion