public override ImmutableArray <PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            Dictionary <string, PortableExecutableReference> map;

            if (PathUtilities.IsFilePath(reference))
            {
                if (_pathResolver != null)
                {
                    reference = _pathResolver.ResolvePath(reference, baseFilePath);
                    if (reference == null)
                    {
                        return(ImmutableArray <PortableExecutableReference> .Empty);
                    }
                }

                map = _files;
            }
            else
            {
                map = _assemblyNames;
            }

            PortableExecutableReference result;

            return(map.TryGetValue(reference, out result) ? ImmutableArray.Create(result) : ImmutableArray <PortableExecutableReference> .Empty);
        }
        public override ImmutableArray <PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            if (PathResolver != null && PathUtilities.IsFilePath(reference))
            {
                var resolvedPath = PathResolver.ResolvePath(reference, baseFilePath);
                if (resolvedPath == null)
                {
                    return(ImmutableArray <PortableExecutableReference> .Empty);
                }

                return(ImmutableArray.Create(_fileReferenceProvider(resolvedPath, properties)));
            }

            if (PackageResolver != null)
            {
                var paths = PackageResolver.ResolveNuGetPackage(reference);
                if (!paths.IsDefaultOrEmpty)
                {
                    return(paths.SelectAsArray(path => _fileReferenceProvider(path, properties)));
                }
            }

            if (GacFileResolver != null)
            {
                var path = GacFileResolver.Resolve(reference);
                if (path != null)
                {
                    return(ImmutableArray.Create(_fileReferenceProvider(path, properties)));
                }
            }

            return(ImmutableArray <PortableExecutableReference> .Empty);
        }
        public override ImmutableArray <PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            string packageName;
            string packageVersion;

            if (NuGetPackageResolver.TryParsePackageReference(reference, out packageName, out packageVersion))
            {
                if (PackageResolver != null)
                {
                    var paths = PackageResolver.ResolveNuGetPackage(packageName, packageVersion);
                    Debug.Assert(!paths.IsDefault);
                    return(paths.SelectAsArray(path => _fileReferenceProvider(path, properties)));
                }
            }
            else if (PathUtilities.IsFilePath(reference))
            {
                if (PathResolver != null)
                {
                    var resolvedPath = PathResolver.ResolvePath(reference, baseFilePath);
                    if (resolvedPath != null)
                    {
                        return(ImmutableArray.Create(_fileReferenceProvider(resolvedPath, properties)));
                    }
                }
            }
            else if (GacFileResolver != null)
            {
                var path = GacFileResolver.Resolve(reference);
                if (path != null)
                {
                    return(ImmutableArray.Create(_fileReferenceProvider(path, properties)));
                }
            }
            return(ImmutableArray <PortableExecutableReference> .Empty);
        }
        public override ImmutableArray <PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            var path = PathResolver.ResolvePath(reference, baseFilePath);

            if (path == null)
            {
                return(ImmutableArray <PortableExecutableReference> .Empty);
            }

            return(ImmutableArray.Create(_metadataService.GetReference(path, properties)));
        }
예제 #5
0
        public void ResolvePath_Order()
        {
            var dir  = Temp.CreateDirectory();
            var dir1 = dir.CreateDirectory("dir1");
            var dir2 = dir.CreateDirectory("dir2");

            var f1 = dir1.CreateFile("f.dll").Path;
            var f2 = dir2.CreateFile("f.dll").Path;

            var resolver = new RelativePathResolver(
                ImmutableArray.Create(dir1.Path, dir2.Path),
                baseDirectory: null);

            var path = resolver.ResolvePath("f.dll", null);

            Assert.Equal(f1, path);
        }
예제 #6
0
        public void ResolvePath_Order()
        {
            var dir = Temp.CreateDirectory();
            var dir1 = dir.CreateDirectory("dir1");
            var dir2 = dir.CreateDirectory("dir2");

            var f1 = dir1.CreateFile("f.dll").Path;
            var f2 = dir2.CreateFile("f.dll").Path;

            var resolver = new RelativePathResolver(
                ImmutableArray.Create(dir1.Path, dir2.Path),
                baseDirectory: null);

            var path = resolver.ResolvePath("f.dll", null);
            Assert.Equal(f1, path);
        }