public static string GetFullName(this ScopeDefinitionHandle scopeDefHandle, MetadataReader reader) { var scopeDef = scopeDefHandle.GetScopeDefinition(reader); Debug.Assert(!scopeDef.Name.IsNull(reader)); var assemblyName = new AssemblyName { Name = scopeDef.Name.GetConstantStringValue(reader).Value, CultureName = scopeDef.Culture.IsNull(reader) ? null : scopeDef.Culture.GetConstantStringValue(reader).Value, Version = new Version(scopeDef.MajorVersion, scopeDef.MinorVersion, scopeDef.BuildNumber, scopeDef.RevisionNumber) }; if (scopeDef.PublicKey.Count > 0) { var pkt = new byte[scopeDef.PublicKey.Count]; int index = 0; foreach (var b in scopeDef.PublicKey) { pkt[index++] = b; } assemblyName.SetPublicKeyToken(pkt); } else { assemblyName.SetPublicKeyToken(Array.Empty <byte>()); } return(assemblyName.FullName); }
private bool TryResolveNamespaceDefinitionCaseSensitive(MetadataReader reader, string[] namespaceParts, ScopeDefinitionHandle scopeDefinitionHandle, out NamespaceDefinition namespaceDefinition) { namespaceDefinition = scopeDefinitionHandle.GetScopeDefinition(reader).RootNamespaceDefinition.GetNamespaceDefinition(reader); NamespaceDefinitionHandleCollection candidates = namespaceDefinition.NamespaceDefinitions; int idx = namespaceParts.Length; while (idx-- != 0) { // Each iteration finds a match for one segment of the namespace chain. string expected = namespaceParts[idx]; bool foundMatch = false; foreach (NamespaceDefinitionHandle candidate in candidates) { namespaceDefinition = candidate.GetNamespaceDefinition(reader); if (namespaceDefinition.Name.StringOrNullEquals(expected, reader)) { // Found a match for this segment of the namespace chain. Move on to the next level. foundMatch = true; candidates = namespaceDefinition.NamespaceDefinitions; break; } } if (!foundMatch) { return(false); } } return(true); }
public static RuntimeAssemblyName ToRuntimeAssemblyName(this ScopeDefinitionHandle scopeDefinitionHandle, MetadataReader reader) { ScopeDefinition scopeDefinition = scopeDefinitionHandle.GetScopeDefinition(reader); return(CreateRuntimeAssemblyNameFromMetadata( reader, scopeDefinition.Name, scopeDefinition.MajorVersion, scopeDefinition.MinorVersion, scopeDefinition.BuildNumber, scopeDefinition.RevisionNumber, scopeDefinition.Culture, scopeDefinition.PublicKey, scopeDefinition.Flags )); }
private bool TryResolveNamespaceDefinitionCaseSensitive(MetadataReader reader, ScopeDefinitionHandle scopeDefinitionHandle, out NamespaceDefinition namespaceDefinition) { namespaceDefinition = scopeDefinitionHandle.GetScopeDefinition(reader).RootNamespaceDefinition.GetNamespaceDefinition(reader); IEnumerable<NamespaceDefinitionHandle> candidates = namespaceDefinition.NamespaceDefinitions; int idx = _namespaceParts.Length; while (idx-- != 0) { // Each iteration finds a match for one segment of the namespace chain. String expected = _namespaceParts[idx]; bool foundMatch = false; foreach (NamespaceDefinitionHandle candidate in candidates) { namespaceDefinition = candidate.GetNamespaceDefinition(reader); if (namespaceDefinition.Name.StringOrNullEquals(expected, reader)) { // Found a match for this segment of the namespace chain. Move on to the next level. foundMatch = true; candidates = namespaceDefinition.NamespaceDefinitions; break; } } if (!foundMatch) { return false; } } return true; }