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)); }
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"); }
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)); }
private string GetManifestResourceNameCSharp(ConfigurationSettings configSetting, string dependentFile) { // defer to the resource management code in CscTask CscTask csc = new CscTask(); csc.Project = _solutionTask.Project; 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.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); }