Beispiel #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);
        }
Beispiel #2
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();
        }
Beispiel #3
0
 internal StrongNameProvider GetStrongNameProvider(StrongNameFileSystem fileSystem)
 => new DesktopStrongNameProvider(KeyFileSearchPaths, fileSystem);