Exemplo n.º 1
0
        public void ResolveNewNamedResxResources()
        {
            var expected = new[]
            {
                "testproject.OwnResources.resources",
                "testproject.subfolder.nestedresource.resources",
                "thisIs.New.Resource.resources"
            };
            var rootDir           = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project = ProjectUtilities.GetProject(@"
{
    ""namedResource"": {
        ""thisIs.New.Resource"": ""../someresources/OtherResources.resx""
    }
}",
                                                          "testproject",
                                                          Path.Combine(testProjectFolder, "project.json"));

            var resolver          = new ResxResourceProvider();
            var embeddedResources = resolver.GetResources(project).Select(resource => resource.Name).ToArray();

            Assert.Equal(expected, embeddedResources);
        }
Exemplo n.º 2
0
        public void ResolveNewNamedResxResources()
        {
            var expected = new[]
            {
                "testproject.OwnResources.resources",
                "testproject.subfolder.nestedresource.resources",
                "thisIs.New.Resource.resources"
            };
            var rootDir = ProjectResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project = Project.GetProject(@"
            {
            ""namedResource"": {
            ""thisIs.New.Resource"": ""../someresources/OtherResources.resx""
            }
            }",
                "testproject",
                Path.Combine(testProjectFolder, "project.json"));

            var resolver = new ResxResourceProvider();
            var embeddedResources = resolver.GetResources(project).Select(resource => resource.Name).ToArray();

            Assert.Equal(expected, embeddedResources);
        }
Exemplo n.º 3
0
        private static AssemblyLoader CreateLoader(string projectDir)
        {
            var globalAssemblyCache = new DefaultGlobalAssemblyCache();

            var    loader           = new AssemblyLoader();
            string rootDirectory    = ResolveRootDirectory(projectDir);
            var    resolver         = new FrameworkReferenceResolver(globalAssemblyCache);
            var    resourceProvider = new ResxResourceProvider();
            var    roslynLoader     = new RoslynAssemblyLoader(rootDirectory, NoopWatcher.Instance, resolver, globalAssemblyCache, loader, resourceProvider);

            loader.Add(roslynLoader);
#if DESKTOP
            loader.Add(new MSBuildProjectAssemblyLoader(rootDirectory, NoopWatcher.Instance));
#endif
            loader.Add(new NuGetAssemblyLoader(projectDir));

            return(loader);
        }
Exemplo n.º 4
0
        public void ResolveResxResources()
        {
            var expected = new[]
            {
                "testproject.OwnResources.resources",
                "testproject.subfolder.nestedresource.resources",
                "testproject.OtherResources.resources"
            };
            var rootDir           = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project;
            bool    projectFound = Project.TryGetProject(testProjectFolder, out project);

            Assert.True(projectFound);

            var resolver          = new ResxResourceProvider();
            var embeddedResources = resolver.GetResources(project).Select(resource => resource.Name).ToArray();

            Assert.Equal(expected, embeddedResources);
        }
Exemplo n.º 5
0
        public void ResolveRenamedResxResources()
        {
            var rootDir           = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project = ProjectUtilities.GetProject(@"
{
    ""namedResource"": {
        ""renamedResource"": ""subfolder/nestedresource.resx""
    }
}",
                                                          "testproject",
                                                          Path.Combine(testProjectFolder, "project.json"));

            var resolver         = new ResxResourceProvider();
            var embeddedResource = resolver.GetResources(project);

            Assert.Equal("testproject.OwnResources.resources", embeddedResource[0].Name);

            // This resource should get a new name instead of "testproject.subfolder.nestedresource.resources"
            Assert.Equal("renamedResource.resources", embeddedResource[1].Name);
        }
Exemplo n.º 6
0
        public void ResolveRenamedResxResources()
        {
            var rootDir = ProjectResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project = Project.GetProject(@"
            {
            ""namedResource"": {
            ""renamedResource"": ""subfolder/nestedresource.resx""
            }
            }",
                "testproject",
                Path.Combine(testProjectFolder, "project.json"));

            var resolver = new ResxResourceProvider();
            var embeddedResource = resolver.GetResources(project);

            Assert.Equal("testproject.OwnResources.resources", embeddedResource[0].Name);

            // This resource should get a new name instead of "testproject.subfolder.nestedresource.resources"
            Assert.Equal("renamedResource.resources", embeddedResource[1].Name);
        }
Exemplo n.º 7
0
        private void Initialize(bool watchFiles)
        {
            _loader = new AssemblyLoader();
            string rootDirectory = ResolveRootDirectory(_projectDir);

#if DESKTOP // CORECLR_TODO: FileSystemWatcher
            if (watchFiles)
            {
                _watcher            = new FileWatcher(rootDirectory);
                _watcher.OnChanged += OnWatcherChanged;
            }
            else
#endif
            {
                _watcher = NoopWatcher.Instance;
            }

            var globalAssemblyCache = new DefaultGlobalAssemblyCache();

            var cachedLoader = new CachedCompilationLoader(rootDirectory);
            _loader.Add(cachedLoader);
            var resolver         = new FrameworkReferenceResolver(globalAssemblyCache);
            var resourceProvider = new ResxResourceProvider();
            var roslynLoader     = new RoslynAssemblyLoader(rootDirectory, _watcher, resolver, globalAssemblyCache, _loader, resourceProvider);
            _loader.Add(roslynLoader);
#if DESKTOP // CORECLR_TODO: Process
            _loader.Add(new MSBuildProjectAssemblyLoader(rootDirectory, _watcher));
#endif
            _loader.Add(new NuGetAssemblyLoader(_projectDir));

            _hostServices[HostServices.ResolveAssemblyReference] = new Func <string, object>(name =>
            {
                var an = new AssemblyName(name);

                return(_loader.ResolveReference(an.Name));
            });
        }
 public void OneTimeSetUp()
 {
     _provider = new ResxResourceProvider(TestResources.ResourceManager);
 }
Exemplo n.º 9
0
        public void ResolveResxResources()
        {
            var expected = new[]
            {
                "testproject.OwnResources.resources",
                "testproject.subfolder.nestedresource.resources",
                "testproject.OtherResources.resources"
            };
            var rootDir = ProjectResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var testProjectFolder = Path.Combine(rootDir, "misc", "ResourcesTestProjects", "testproject");

            Project project;
            bool projectFound = Project.TryGetProject(testProjectFolder, out project);
            Assert.True(projectFound);

            var resolver = new ResxResourceProvider();
            var embeddedResources = resolver.GetResources(project).Select(resource => resource.Name).ToArray();

            Assert.Equal(expected, embeddedResources);
        }