1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System.Collections.Generic;
6 using System.Diagnostics;
8 namespace System.Reflection.TypeLoading
11 /// Resource-only modules created by a MetadataLoadContext.
13 internal sealed class RoResourceModule : RoModule
15 private readonly RoAssembly _assembly;
18 // "fullyQualifiedName" determines the string returned by Module.FullyQualifiedName. It is typically set to the full path of the
19 // file on disk containing the module.
21 internal RoResourceModule(RoAssembly assembly, string fullyQualifiedName)
22 : base(fullyQualifiedName)
24 Debug.Assert(assembly != null);
25 Debug.Assert(fullyQualifiedName != null);
29 internal sealed override RoAssembly GetRoAssembly() => _assembly;
31 public sealed override int MDStreamVersion => throw new InvalidOperationException(SR.ResourceOnlyModule);
32 public sealed override int MetadataToken => 0x00000000;
33 public sealed override Guid ModuleVersionId => throw new InvalidOperationException(SR.ResourceOnlyModule);
34 public sealed override string ScopeName => Name;
35 public sealed override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
37 peKind = PortableExecutableKinds.NotAPortableExecutableImage;
41 public sealed override IEnumerable<CustomAttributeData> CustomAttributes => Array.Empty<CustomAttributeData>();
43 public sealed override FieldInfo GetField(string name, BindingFlags bindingAttr) => null;
44 public sealed override FieldInfo[] GetFields(BindingFlags bindingFlags) => Array.Empty<FieldInfo>();
45 public sealed override MethodInfo[] GetMethods(BindingFlags bindingFlags) => Array.Empty<MethodInfo>();
46 protected sealed override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) => null;
48 public sealed override bool IsResource() => true;
50 public sealed override Type[] GetTypes() => Array.Empty<Type>();
51 protected sealed override RoDefinitionType GetTypeCoreNoCache(ReadOnlySpan<byte> ns, ReadOnlySpan<byte> name, out Exception e)
53 e = new TypeLoadException(SR.Format(SR.TypeNotFound, ns.ToUtf16().AppendTypeName(name.ToUtf16()), Assembly));
57 internal sealed override IEnumerable<RoType> GetDefinedRoTypes() => null;