예제 #1
0
        public void Test_ManifestResourceName_CompiledResource_DynamicPrefix()
        {
            CscTask cscTask = new CscTask();

            cscTask.Project   = CreateEmptyProject();
            cscTask.CallStack = cscTask.Project.RootTargetCallStack;

            ResourceFileSet resources = new ResourceFileSet();

            resources.BaseDirectory = TempDirectory;
            resources.DynamicPrefix = true;

            // holds the path to the resource file
            string resourceFile = null;

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resources");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("ResourceFile.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.resources");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("ResourceFile.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resources");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resources");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resources");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.en-US.dunno.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));
        }
예제 #2
0
        public void Test_ManifestResourceName_Resx_StandAlone_Prefix()
        {
            CscTask cscTask = new CscTask();

            cscTask.Project = CreateEmptyProject();

            ResourceFileSet resources = new ResourceFileSet();

            resources.BaseDirectory = TempDirectory;
            resources.Prefix        = "TestNamespace";
            resources.DynamicPrefix = false;

            // holds the path to the resource file
            string resourceFile = null;

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.en-US.dunno.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));
        }
예제 #3
0
        private string GetManifestResourceNameCSharp(ConfigurationSettings configSetting, string dependentFile)
        {
            // defer to the resource management code in CscTask
            CscTask csc = new CscTask();

            csc.Project          = _solutionTask.Project;
            csc.CallStack        = _solutionTask.CallStack;
            csc.NamespaceManager = _solutionTask.NamespaceManager;
            csc.OutputFile       = new FileInfo(FileUtils.CombinePaths(configSetting.OutputDir.FullName,
                                                                       Project.ProjectSettings.OutputFileName));

            // set-up resource fileset
            ResourceFileSet resources = new ResourceFileSet();

            resources.Project          = _solutionTask.Project;
            resources.CallStack        = _solutionTask.CallStack;
            resources.NamespaceManager = _solutionTask.NamespaceManager;
            resources.Parent           = csc;
            resources.BaseDirectory    = new DirectoryInfo(Path.GetDirectoryName(Project.ProjectPath));
            resources.Prefix           = Project.ProjectSettings.RootNamespace;
            resources.DynamicPrefix    = true;

            // bug #1042917: use logical location of resource file to determine
            // manifest resource name
            return(csc.GetManifestResourceName(resources, InputFile.FullName,
                                               LogicalFile.FullName, dependentFile));
        }
예제 #4
0
        public void Test_ManifestResourceName_NonExistingResource()
        {
            CscTask cscTask = new CscTask();

            cscTask.Project = CreateEmptyProject();

            ResourceFileSet resources = new ResourceFileSet();

            resources.BaseDirectory = TempDirectory;
            resources.DynamicPrefix = true;

            cscTask.GetManifestResourceName(resources, "I_dont_exist.txt");
        }
예제 #5
0
        private void PerformDependentResxTests(CscTask cscTask, ResourceFileSet resources)
        {
            // holds the path to the resource file
            string resourceFile = null;

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("ResourceTest.HelloWorld.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("HelloWorld.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("ResourceTest.HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("ResourceTest.HelloWorld.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("HelloWorld.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("ResourceTest.HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile.en-US.dunno." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("ResourceTest.HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile.en-US.dunno." + cscTask.Extension));
            // assert manifest resource name
            Assert.AreEqual("HelloWorld.en-US.resources",
                            cscTask.GetManifestResourceName(resources, resourceFile));
        }