/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/Test/Core/Compilation/MetadataReferenceExtensions.cs
47 строк
2 KB
Julien Couvreur
Warn for multiple blank lines in source (#65451)
17 ноя 2022, 22:55
Не верифицирован
17 ноя 2022, 22:55
a8824e8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using Roslyn.Test.Utilities; namespace Microsoft.CodeAnalysis.Test.Utilities { public static class MetadataReferenceExtensions { public static Guid GetModuleVersionId(this MetadataReference metadataReference) => GetManifestModuleMetadata(metadataReference).GetModuleVersionId(); public static AssemblyIdentity GetAssemblyIdentity(this MetadataReference reference) => reference.GetManifestModuleMetadata().MetadataReader.ReadAssemblyIdentityOrThrow(); public static ModuleMetadata GetManifestModuleMetadata(this MetadataReference reference) => reference is PortableExecutableReference peReference ? peReference.GetManifestModuleMetadata() : throw new InvalidOperationException(); public static ModuleMetadata GetManifestModuleMetadata(this PortableExecutableReference peReference) { switch (peReference.GetMetadata()) { case AssemblyMetadata assemblyMetadata: { if (assemblyMetadata.GetModules() is { Length: > 0 } modules) { return modules[0]; } } break; case ModuleMetadata moduleMetadata: return moduleMetadata; } throw new InvalidOperationException(); } } }