Exemplo n.º 1
0
        /// <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));
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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)));
            }
        }
Exemplo n.º 7
0
 internal StrongNameProvider GetStrongNameProvider(StrongNameFileSystem fileSystem)
 => new DesktopStrongNameProvider(KeyFileSearchPaths, fileSystem);
Exemplo n.º 8
0
 internal DesktopStrongNameProvider(ImmutableArray <string> keyFileSearchPaths, StrongNameFileSystem strongNameFileSystem)
 {
     if (!keyFileSearchPaths.IsDefault && keyFileSearchPaths.Any(static path => !PathUtilities.IsAbsolute(path)))
Exemplo n.º 9
0
 public PortableStrongNameProvider(ImmutableArray <string> keySearchPaths, StrongNameFileSystem strongNameFileSystem)
 {
     FileSystem          = strongNameFileSystem ?? StrongNameFileSystem.Instance;
     _keyFileSearchPaths = keySearchPaths.NullToEmpty();
 }