Ejemplo n.º 1
0
        public void ResolveStrongNameKeyFile()
        {
            string fileName    = "f.snk";
            string dir         = @"C:\dir";
            string subdir      = @"C:\dir\subdir";
            string filePath    = dir + @"\" + fileName;
            string subFilePath = subdir + @"\" + fileName;

            var fs = new HashSet <string> {
                filePath, subFilePath
            };

            // with no search paths
            var provider = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(subdir)
                );
            var subdirSearchPath = ImmutableArray.Create(subdir);

            // using base directory; base path ignored
            var path = resolve(fileName, subdirSearchPath);

            Assert.Equal(subFilePath, path, StringComparer.OrdinalIgnoreCase);

            // search paths
            var searchPathsSP = ImmutableArray.Create(@"C:\goo", dir, subdir);

            path = resolve(fileName, searchPathsSP);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir, no search paths
            var searchPathsEmpty = ImmutableArray <string> .Empty;

            // relative path
            path = resolve(fileName, searchPathsEmpty);
            Assert.Null(path);

            // full path
            path = resolve(filePath, searchPathsEmpty);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir
            var searchPathsNullBaseSP = ImmutableArray.Create(dir, subdir);

            // relative path
            path = resolve(fileName, searchPathsNullBaseSP);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // full path
            path = resolve(filePath, searchPathsNullBaseSP);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            string resolve(string keyFilePath, ImmutableArray <string> searchPaths) =>
            DesktopStrongNameProvider.ResolveStrongNameKeyFile(
                keyFilePath,
                provider.FileSystem,
                searchPaths
                );
        }
Ejemplo n.º 2
0
        public void ResolveStrongNameKeyFile()
        {
            string fileName    = "f.snk";
            string dir         = @"C:\dir";
            string subdir      = @"C:\dir\subdir";
            string filePath    = dir + @"\" + fileName;
            string subFilePath = subdir + @"\" + fileName;

            var fs = new HashSet <string>
            {
                filePath,
                subFilePath
            };

            // with no search paths
            var provider = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(subdir));

            // using base directory; base path ignored
            var path = provider.ResolveStrongNameKeyFile(fileName);

            Assert.Equal(subFilePath, path, StringComparer.OrdinalIgnoreCase);

            // search paths
            var providerSP = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(@"C:\goo", dir, subdir));

            path = providerSP.ResolveStrongNameKeyFile(fileName);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir, no search paths
            var providerNullBase = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create <string>());

            // relative path
            path = providerNullBase.ResolveStrongNameKeyFile(fileName);
            Assert.Null(path);

            // full path
            path = providerNullBase.ResolveStrongNameKeyFile(filePath);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir
            var providerNullBaseSP = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(dir, subdir));

            // relative path
            path = providerNullBaseSP.ResolveStrongNameKeyFile(fileName);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // full path
            path = providerNullBaseSP.ResolveStrongNameKeyFile(filePath);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);
        }
        public void ResolveStrongNameKeyFile()
        {
            string fileName = "f.snk";
            string dir = @"C:\dir";
            string subdir = @"C:\dir\subdir";
            string filePath = dir + @"\" + fileName;
            string subFilePath = subdir + @"\" + fileName;

            var fs = new HashSet<string>
            {
                filePath,
                subFilePath
            };

            // with no search paths
            var provider = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(subdir));

            // using base directory; base path ignored
            var path = provider.ResolveStrongNameKeyFile(fileName);
            Assert.Equal(subFilePath, path, StringComparer.OrdinalIgnoreCase);

            // search paths
            var providerSP = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(@"C:\foo", dir, subdir));

            path = providerSP.ResolveStrongNameKeyFile(fileName);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir, no search paths
            var providerNullBase = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create<string>());

            // relative path
            path = providerNullBase.ResolveStrongNameKeyFile(fileName);
            Assert.Null(path);

            // full path
            path = providerNullBase.ResolveStrongNameKeyFile(filePath);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // null base dir
            var providerNullBaseSP = new VirtualizedStrongNameProvider(
                existingFullPaths: fs,
                searchPaths: ImmutableArray.Create(dir, subdir));

            // relative path
            path = providerNullBaseSP.ResolveStrongNameKeyFile(fileName);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);

            // full path
            path = providerNullBaseSP.ResolveStrongNameKeyFile(filePath);
            Assert.Equal(filePath, path, StringComparer.OrdinalIgnoreCase);
        }
        public void EmitWithDefaultTempPath()
        {
            string src = @"
class C
{
    public static void Main(string[] args) { }
}";
            var provider = new VirtualizedStrongNameProvider(tempPath: null);
            var options = TestOptions
                .DebugExe
                .WithStrongNameProvider(provider)
                .WithCryptoKeyFile(SigningTestHelpers.KeyPairFile);
            var comp = CreateCompilationWithMscorlib(src, options: options);
            comp.VerifyEmitDiagnostics();
        }
        public void EmitWithDefaultTempPath()
        {
            string src      = @"
class C
{
    public static void Main(string[] args) { }
}";
            var    provider = new VirtualizedStrongNameProvider(tempPath: null);
            var    options  = TestOptions
                              .DebugExe
                              .WithStrongNameProvider(provider)
                              .WithCryptoKeyFile(SigningTestHelpers.KeyPairFile);
            var comp = CreateCompilationWithMscorlib(src, options: options);

            comp.VerifyEmitDiagnostics();
        }
Ejemplo n.º 6
0
        public void EmitWithCustomTempPath()
        {
            string src      = @"
class C
{
    public static void Main(string[] args) { }
}";
            var    tempDir  = Temp.CreateDirectory();
            var    provider = new VirtualizedStrongNameProvider(tempPath: tempDir.Path);
            var    options  = TestOptions
                              .DebugExe
                              .WithStrongNameProvider(provider)
                              .WithCryptoKeyFile(SigningTestHelpers.KeyPairFile);
            var comp = CreateStandardCompilation(src, options: options);

            comp.VerifyEmitDiagnostics();
        }