Exemple #1
0
        private string GetManifestResourceNameVB(ConfigurationSettings configSetting, string dependentFile)
        {
            // defer to the resource management code in VbcTask
            VbcTask vbc = new VbcTask();

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

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

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

            // bug #1042917: use logical location of resource file to determine
            // manifest resource name
            return(vbc.GetManifestResourceName(resources, InputFile.FullName,
                                               LogicalFile.FullName, dependentFile));
        }
Exemple #2
0
        public void Test_ManifestResourceName_CompiledResource_DynamicPrefix()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project       = CreateEmptyProject();
            vbcTask.RootNamespace = "TestRootNamespace";

            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",
                            vbcTask.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",
                            vbcTask.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",
                            vbcTask.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",
                            vbcTask.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",
                            vbcTask.GetManifestResourceName(resources, resourceFile));
        }
Exemple #3
0
            /// <summary>
            /// Parses the input, ensuring the class name is found
            /// </summary>
            public void VerifyFindClassname(string input, string expectedClassname)
            {
                VbcTask      vbTask = new VbcTask();
                StringReader reader = new StringReader(input);

                CompilerBase.ResourceLinkage linkage = vbTask.PerformSearchForResourceLinkage(reader);

                Assert.IsNotNull(linkage, "no resourcelinkage found for " + input);
                Assert.AreEqual(expectedClassname, linkage.ClassName);
            }
        public void Test_ManifestResourceName_NonResx_Prefix()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project       = CreateEmptyProject();
            vbcTask.CallStack     = vbcTask.Project.RootTargetCallStack;
            vbcTask.RootNamespace = "TestRootNamespace";

            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.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

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

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

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual(resources.Prefix + "." + "ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));
        }
Exemple #5
0
        public void Test_ManifestResourceName_NonExistingResource()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project = CreateEmptyProject();

            ResourceFileSet resources = new ResourceFileSet();

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

            vbcTask.GetManifestResourceName(resources, "I_dont_exist.txt");
        }
Exemple #6
0
        public void Test_ManifestResourceName_Resx_DynamicPrefix()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project       = CreateEmptyProject();
            vbcTask.RootNamespace = "TestRootNamespace";

            ResourceFileSet resources = new ResourceFileSet();

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

            PerformDependentResxTests(vbcTask, resources);
        }
Exemple #7
0
        public void Test_ManifestResourceName_Resx_Prefix()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project       = CreateEmptyProject();
            vbcTask.RootNamespace = "TestRootNamespace";

            ResourceFileSet resources = new ResourceFileSet();

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

            // prefix should be ignored for resx files
            PerformDependentResxTests(vbcTask, resources);
        }
Exemple #8
0
        private void PerformDependentResxTests(VbcTask vbcTask, 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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.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." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));
        }