/// <summary> /// Resolves assembly strong name key file path. /// </summary> /// <returns>Normalized key file path or null if not found.</returns> internal static string ResolveStrongNameKeyFile(string path, StrongNameFileSystem fileSystem, ImmutableArray <string> keyFileSearchPaths) { // Dev11: key path is simply appended to the search paths, even if it starts with the current (parent) directory ("." or ".."). // This is different from PathUtilities.ResolveRelativePath. if (PathUtilities.IsAbsolute(path)) { if (fileSystem.FileExists(path)) { return(FileUtilities.TryNormalizeAbsolutePath(path)); } return(path); } foreach (var searchPath in keyFileSearchPaths) { string combinedPath = PathUtilities.CombineAbsoluteAndRelativePaths(searchPath, path); Debug.Assert(combinedPath == null || PathUtilities.IsAbsolute(combinedPath)); if (fileSystem.FileExists(combinedPath)) { return(FileUtilities.TryNormalizeAbsolutePath(combinedPath)); } } return(null); }
internal StrongNameProvider GetStrongNameProvider(StrongNameFileSystem fileSystem) { // https://github.com/dotnet/roslyn/issues/23521 // Disable the portable strong name provider until we can find and fix the // root cause of the bug return(new DesktopStrongNameProvider(KeyFileSearchPaths, null, fileSystem)); }
internal StrongNameProvider GetStrongNameProvider(StrongNameFileSystem fileSystem) { bool fallback = ParseOptionsCore.Features.ContainsKey("UseLegacyStrongNameProvider") || CompilationOptionsCore.CryptoKeyContainer != null; return(fallback ? (StrongNameProvider) new DesktopStrongNameProvider(KeyFileSearchPaths, null, fileSystem) : (StrongNameProvider) new PortableStrongNameProvider(KeyFileSearchPaths, fileSystem)); }
internal DesktopStrongNameProvider(ImmutableArray <string> keyFileSearchPaths, StrongNameFileSystem strongNameFileSystem) { if (!keyFileSearchPaths.IsDefault && keyFileSearchPaths.Any(path => !PathUtilities.IsAbsolute(path))) { throw new ArgumentException(CodeAnalysisResources.AbsolutePathExpected, nameof(keyFileSearchPaths)); } FileSystem = strongNameFileSystem ?? StrongNameFileSystem.Instance; _keyFileSearchPaths = keyFileSearchPaths.NullToEmpty(); }
internal StrongNameProvider GetStrongNameProvider( StrongNameFileSystem fileSystem, string tempDirectory) { bool fallback = !(CoreClrShim.IsRunningOnCoreClr || PlatformInformation.IsRunningOnMono) || ParseOptionsCore.Features.ContainsKey("UseLegacyStrongNameProvider") || CompilationOptionsCore.CryptoKeyContainer != null; return(fallback ? new DesktopStrongNameProvider(KeyFileSearchPaths, tempDirectory, fileSystem) : (StrongNameProvider) new PortableStrongNameProvider(KeyFileSearchPaths, fileSystem)); }
internal StrongNameKeys CommonCreateKeys(StrongNameFileSystem fileSystem, string keyFilePath, ImmutableArray <string> keyFileSearchPaths, CommonMessageProvider messageProvider) { try { string resolvedKeyFile = fileSystem.ResolveStrongNameKeyFile(keyFilePath, keyFileSearchPaths); if (resolvedKeyFile == null) { return(new StrongNameKeys(StrongNameKeys.GetKeyFileError(messageProvider, keyFilePath, CodeAnalysisResources.FileNotFound))); } Debug.Assert(PathUtilities.IsAbsolute(resolvedKeyFile)); var fileContent = ImmutableArray.Create(fileSystem.ReadAllBytes(resolvedKeyFile)); return(StrongNameKeys.CreateHelper(fileContent, keyFilePath)); } catch (Exception ex) { return(new StrongNameKeys(StrongNameKeys.GetKeyFileError(messageProvider, keyFilePath, ex.Message))); } }
internal StrongNameProvider GetStrongNameProvider(StrongNameFileSystem fileSystem) => new DesktopStrongNameProvider(KeyFileSearchPaths, fileSystem);
internal DesktopStrongNameProvider(ImmutableArray <string> keyFileSearchPaths, StrongNameFileSystem strongNameFileSystem) { if (!keyFileSearchPaths.IsDefault && keyFileSearchPaths.Any(static path => !PathUtilities.IsAbsolute(path)))
public PortableStrongNameProvider(ImmutableArray <string> keySearchPaths, StrongNameFileSystem strongNameFileSystem) { FileSystem = strongNameFileSystem ?? StrongNameFileSystem.Instance; _keyFileSearchPaths = keySearchPaths.NullToEmpty(); }