Browse Source

Add extension method to get metadata TypeAttributes for an ITypeDefinition

pull/3235/head
Siegfried Pammer 12 months ago
parent
commit
13fd903016
  1. 10
      ICSharpCode.Decompiler/NRExtensions.cs

10
ICSharpCode.Decompiler/NRExtensions.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic; using System.Reflection.Metadata;
using ICSharpCode.Decompiler.Documentation; using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -99,5 +99,13 @@ namespace ICSharpCode.Decompiler
return null; return null;
return docProvider.GetDocumentation(entity); return docProvider.GetDocumentation(entity);
} }
internal static System.Reflection.TypeAttributes GetMetadataAttributes(this ITypeDefinition type)
{
var metadata = type.ParentModule.MetadataFile?.Metadata;
if (metadata == null || type.MetadataToken.IsNil)
return 0;
return metadata.GetTypeDefinition((TypeDefinitionHandle)type.MetadataToken).Attributes;
}
} }
} }

Loading…
Cancel
Save