public void Errors()
        {
            Assert.Throws <ArgumentNullException>(() => _provider.NeedsShadowCopy(null));
            Assert.Throws <ArgumentException>(() => _provider.NeedsShadowCopy("c:foo.dll"));
            Assert.Throws <ArgumentException>(() => _provider.NeedsShadowCopy("bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.NeedsShadowCopy(@"\bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.NeedsShadowCopy(@"../bar.dll"));

            Assert.Throws <ArgumentNullException>(() => _provider.SuppressShadowCopy(null));
            Assert.Throws <ArgumentException>(() => _provider.SuppressShadowCopy("c:foo.dll"));
            Assert.Throws <ArgumentException>(() => _provider.SuppressShadowCopy("bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.SuppressShadowCopy(@"\bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.SuppressShadowCopy(@"../bar.dll"));

            Assert.Throws <ArgumentNullException>(() => _provider.GetReference(null));
            Assert.Throws <ArgumentException>(() => _provider.GetReference("c:foo.dll"));
            Assert.Throws <ArgumentException>(() => _provider.GetReference("bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.GetReference(@"\bar.dll"));
            Assert.Throws <ArgumentException>(() => _provider.GetReference(@"../bar.dll"));

            Assert.Throws <ArgumentOutOfRangeException>(() => _provider.GetMetadataShadowCopy(@"c:\foo.dll", (MetadataImageKind)Byte.MaxValue));
            Assert.Throws <ArgumentNullException>(() => _provider.GetMetadataShadowCopy(null, MetadataImageKind.Assembly));
            Assert.Throws <ArgumentException>(() => _provider.GetMetadataShadowCopy("c:foo.dll", MetadataImageKind.Assembly));
            Assert.Throws <ArgumentException>(() => _provider.GetMetadataShadowCopy("bar.dll", MetadataImageKind.Assembly));
            Assert.Throws <ArgumentException>(() => _provider.GetMetadataShadowCopy(@"\bar.dll", MetadataImageKind.Assembly));
            Assert.Throws <ArgumentException>(() => _provider.GetMetadataShadowCopy(@"../bar.dll", MetadataImageKind.Assembly));

            Assert.Throws <ArgumentOutOfRangeException>(() => _provider.GetMetadata(@"c:\foo.dll", (MetadataImageKind)Byte.MaxValue));
            Assert.Throws <ArgumentNullException>(() => _provider.GetMetadata(null, MetadataImageKind.Assembly));
            Assert.Throws <ArgumentException>(() => _provider.GetMetadata("c:foo.dll", MetadataImageKind.Assembly));
        }
Ejemplo n.º 2
0
 private MetadataReferenceResolver CreateMetadataReferenceResolver(ImmutableArray <string> searchPaths, string baseDirectory)
 {
     return(new RuntimeMetadataReferenceResolver(
                new RelativePathResolver(searchPaths, baseDirectory),
                null,                                                     // TODO
                new GacFileResolver(
                    architectures: GacFileResolver.Default.Architectures, // TODO (tomat)
                    preferredCulture: CultureInfo.CurrentCulture),        // TODO (tomat)
                (path, properties) => _metadataFileProvider.GetReference(path, properties)));
 }
Ejemplo n.º 3
0
            private AssemblyLoadResult LoadFromPathThrowing(string fullOriginalPath, bool addReference)
            {
                var result = _assemblyLoader.LoadFromPath(fullOriginalPath);

                if (addReference && result.IsSuccessful)
                {
                    var reference = _metadataFileProvider.GetReference(fullOriginalPath);
                    _options = _options.AddReferences(reference);
                }

                return(result);
            }