public void CulturedResourcesFileWithRootNamespaceWithinSubfolder()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    FileUtilities.FixFilePath(@"SubFolder\MyResource.fr.resources"),
                    null,             // Link file name
                    false,
                    "RootNamespace",  // Root namespace
                    null,
                    null,
                    null,
                    null);

            Assert.Equal(@"RootNamespace.MyResource.fr.resources", result);
        }
        public void CulturedBitmapWithRootNamespaceNoDirectoryPrefix()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    FileUtilities.FixFilePath(@"SubFolder\SplashScreen.fr.bmp"),
                    null,             // Link file name
                    false,
                    "RootNamespace",  // Root namespace
                    null,
                    null,
                    null,
                    null);

            Assert.Equal(@"RootNamespace.SplashScreen.bmp", result);
        }
Пример #3
0
        public void CulturedResourcesFileWithRootNamespaceWithinSubfolder()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    fileName: FileUtilities.FixFilePath(@"SubFolder\MyResource.fr.resources"),
                    linkFileName: null,             // Link file name
                    prependCultureAsDirectory: false,
                    rootNamespace: "RootNamespace", // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null);

            Assert.Equal(@"RootNamespace.MyResource.fr.resources", result);
        }
Пример #4
0
        public void CulturedBitmapWithRootNamespaceNoDirectoryPrefix()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    fileName: FileUtilities.FixFilePath(@"SubFolder\SplashScreen.fr.bmp"),
                    linkFileName: null,             // Link file name
                    prependCultureAsDirectory: false,
                    rootNamespace: "RootNamespace", // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null);

            Assert.Equal(@"RootNamespace.SplashScreen.bmp", result);
        }
Пример #5
0
        private void AssertSimpleCase(string code, string expected)
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: "MyForm.resx",
                    linkFileName: null,             // Link file name
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace", // Root namespace
                    dependentUponFileName: "MyForm.vb",
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream(code),
                    log: null
                );

            Assert.Equal(expected, result);
        }
Пример #6
0
        public void ResourcesFileWithRootNamespace()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"MyResource.resources",
                    linkFileName: null,             // Link file name
                    prependCultureAsDirectory: false,
                    rootNamespace: "RootNamespace", // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null
                );

            Assert.Equal(@"RootNamespace.MyResource.resources", result);
        }
        public void ResourcesFileWithRootNamespace()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"MyResource.resources",
                    null,            // Link file name
                    false,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal(@"RootNamespace.MyResource.resources", result);
        }
        public void RootnamespaceWithCulture()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    FileUtilities.FixFilePath(@"SubFolder\MyForm.en-GB.ResX"),
                    null,
                    // Link file name
                    true,
                    "RootNamespace",
                    // Root namespace
                    null,
                    null,
                    null,
                    null);

            Assert.Equal("RootNamespace.MyForm.en-GB", result);
        }
        private void AssertSimpleCase(string code, string expected)
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.resx",
                    null,            // Link file name
                    true,
                    "RootNamespace", // Root namespace
                    "MyForm.vb",
                    null,
                    StreamHelpers.StringToStream(code),
                    null
                );

            Assert.Equal(expected, result);
        }
        public void Regress222308()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"..\..\XmlEditor\Setup\XmlEditor.rgs",
                    @"MyXmlEditor.rgs",
                    true,
                    "RootNamespace",        // Root namespace
                    null,
                    null,
                    null,
                    null

                );

            Assert.Equal("RootNamespace.MyXmlEditor.rgs", result);
        }
        public void CulturedBitmapWithRootNamespace()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\SplashScreen.fr.bmp",
                    null,            // Link file name
                    true,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    null,
                    null

                );

            Assert.Equal(@"fr\RootNamespace.SplashScreen.bmp", result);
        }
Пример #12
0
        public void Regress222308()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"..\..\XmlEditor\Setup\XmlEditor.rgs",
                    linkFileName: @"MyXmlEditor.rgs",
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null

                );

            Assert.Equal("RootNamespace.MyXmlEditor.rgs", result);
        }
Пример #13
0
        public void Regress459265()
        {
            MockEngine m = new MockEngine();
            CreateVisualBasicManifestResourceName c = new CreateVisualBasicManifestResourceName();

            c.BuildEngine = m;

            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.resx",
                    null,
                    true,
                    "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    "MyForm.vb",
                    null,
                    StreamHelpers.StringToStream(
                        @"Imports System

#if false
Namespace ClassLibrary1
#end if
#if Debug
Namespace ClassLibrary2
#else
Namespace ClassLibrary3
#end if 
    Class MyForm 
    End Class
End Namespace
"
                        ),
                    c.Log
                );

            Assert.IsTrue
            (
                m.Log.Contains
                (
                    String.Format(AssemblyResources.GetString("CreateManifestResourceName.DefinitionFoundWithinConditionalDirective"), "MyForm.vb", "MyForm.resx")
                )
            );
        }
        public void ResourceFilesWithManifestResourceNamesContainsAdditionalMetadata()
        {
            CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("strings.resx");

            t.ResourceFiles = new ITaskItem[] { i };
            t.RootNamespace = "ResourceRoot";
            bool success = t.Execute();

            Assert.True(success); // "Expected the task to succceed."

            ITaskItem[] resourceFiles = t.ResourceFilesWithManifestResourceNames;

            Assert.Equal(1, resourceFiles.Length);
            Assert.Equal(@"strings.resx", resourceFiles[0].ItemSpec);
            Assert.Equal(@"ResourceRoot.strings", resourceFiles[0].GetMetadata("ManifestResourceName"));
        }
Пример #15
0
        public void RootnamespaceWithCulture_RetainCultureInFileName()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"File.cs.vb",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null,
                    treatAsCultureNeutral: true // retain culture in name
                );

            // Visual basic does not carry subfolder.
            // See https://github.com/dotnet/msbuild/pull/5477
            result.ShouldBe("RootNamespace.File.cs.vb");
        }
Пример #16
0
        public void AddLogicalNameForNonResx()
        {
            CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("pic.bmp");

            i.SetMetadata("Type", "Non-Resx");

            t.ResourceFiles = new ITaskItem[] { i };
            t.RootNamespace = "ResourceRoot";
            bool success = t.Execute();

            Assert.IsTrue(success, "Expected the task to succceed.");

            ITaskItem[] resourceFiles = t.ResourceFilesWithManifestResourceNames;

            Assert.AreEqual(1, resourceFiles.Length);
            Assert.AreEqual(@"pic.bmp", resourceFiles[0].ItemSpec);
            Assert.AreEqual(@"ResourceRoot.pic.bmp", resourceFiles[0].GetMetadata("LogicalName"));
        }
Пример #17
0
        public void RootnamespaceWithCulture()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl(
                    fileName: FileUtilities.FixFilePath(@"SubFolder\MyForm.en-GB.ResX"),
                    linkFileName: null,
                    // Link file name
                    prependCultureAsDirectory:
                    // Link file name
                    true,
                    rootNamespace: "RootNamespace",
                    // Root namespace
                    dependentUponFileName:
                    // Root namespace
                    null,
                    culture: null,
                    binaryStream: null,
                    log: null);

            Assert.Equal("RootNamespace.MyForm.en-GB", result);
        }
        public void NoLogicalNameAddedForResx()
        {
            CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("strings.resx");

            i.SetMetadata("Type", "Resx");

            t.ResourceFiles = new ITaskItem[] { i };
            t.RootNamespace = "ResourceRoot";
            bool success = t.Execute();

            Assert.True(success); // "Expected the task to succceed."

            ITaskItem[] resourceFiles = t.ResourceFilesWithManifestResourceNames;

            Assert.Equal(1, resourceFiles.Length);
            Assert.Equal(@"strings.resx", resourceFiles[0].ItemSpec);
            Assert.Equal(String.Empty, resourceFiles[0].GetMetadata("LogicalName"));
        }
Пример #19
0
        public void Regress459265()
        {
            MockEngine m = new MockEngine();
            CreateVisualBasicManifestResourceName c = new CreateVisualBasicManifestResourceName();

            c.BuildEngine = m;

            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: "MyForm.resx",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    dependentUponFileName: "MyForm.vb",
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream(
                        @"Imports System

#if false
Namespace ClassLibrary1
#end if
#if Debug
Namespace ClassLibrary2
#else
Namespace ClassLibrary3
#end if 
    Class MyForm 
    End Class
End Namespace
"
                        ),
                    log: c.Log
                );

            Assert.Contains(
                String.Format(AssemblyResources.GetString("CreateManifestResourceName.DefinitionFoundWithinConditionalDirective"), "MyForm.vb", "MyForm.resx"),
                m.Log
                );
        }
Пример #20
0
        public void Regress419591()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: "MyForm.ro.resx",
                    linkFileName: null,             // Link file name
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace", // Root namespace
                    dependentUponFileName: "MyForm.ro.vb",
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream(
                        @"
    Class MyForm 
    End Class
"),
                    log: null

                );

            Assert.Equal("RootNamespace.MyForm", result);
        }
        public void Regress419591()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.ro.resx",
                    null,            // Link file name
                    true,
                    "RootNamespace", // Root namespace
                    "MyForm.ro.vb",
                    null,
                    StreamHelpers.StringToStream(
                        @"
    Class MyForm 
    End Class
"),
                    null

                );

            Assert.Equal("RootNamespace.MyForm", result);
        }
        public void Regress188319()
        {
            CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName();

            t.BuildEngine = new MockEngine();

            ITaskItem i = new TaskItem("SR1.resx");

            i.SetMetadata("BuildAction", "EmbeddedResource");
            i.SetMetadata("DependentUpon", "SR1.strings");        // Normally, this would be a C# file.
            t.ResourceFiles = new ITaskItem[] { i };
            t.RootNamespace = "CustomToolTest";

            bool success = t.Execute(new Microsoft.Build.Tasks.CreateFileStream(CreateFileStream));

            Assert.True(success); // "Expected the task to succceed."

            ITaskItem[] resourceNames = t.ManifestResourceNames;

            Assert.Equal(1, resourceNames.Length);
            Assert.Equal(@"CustomToolTest.SR1", resourceNames[0].ItemSpec);
        }
        public void PreserveLogicalNameForNonResx()
        {
            CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("pic.bmp");

            i.SetMetadata("LogicalName", "foo");
            i.SetMetadata("Type", "Non-Resx");

            t.ResourceFiles = new ITaskItem[] { i };
            t.RootNamespace = "ResourceRoot";
            bool success = t.Execute();

            Assert.True(success); // "Expected the task to succeed."

            ITaskItem[] resourceFiles = t.ResourceFilesWithManifestResourceNames;

            Assert.Single(resourceFiles);
            Assert.Equal(@"pic.bmp", resourceFiles[0].ItemSpec);
            Assert.Equal(@"foo", resourceFiles[0].GetMetadata("LogicalName"));
        }
Пример #24
0
        public void Basic()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"f:\myproject\SubFolder\MyForm.resx",
                    linkFileName: null,    // Link file name
                    prependCultureAsDirectory: true,
                    rootNamespace: null,   // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream(
                        @"
Namespace Nested.TestNamespace 
    Class TestClass 
    End Class
End Namespace
"),
                    log: null
                );

            Assert.Equal("Nested.TestNamespace.TestClass", result);
        }
        public void Basic()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.resx",
                    null,    // Link file name
                    true,
                    null,    // Root namespace
                    null,
                    null,
                    StreamHelpers.StringToStream(
                        @"
Namespace Nested.TestNamespace 
    Class TestClass 
    End Class
End Namespace
"),
                    null
                );

            Assert.Equal("Nested.TestNamespace.TestClass", result);
        }
        public void CulturedResourceFileFindByConvention()
        {
            using (var env = TestEnvironment.Create(_testOutput))
            {
                var csFile   = env.CreateFile("SR1.vb", @"
Namespace MyStuff
    Class Class2
    End Class
End Namespace");
                var resXFile = env.CreateFile("SR1.de.resx", "");

                ITaskItem i = new TaskItem(resXFile.Path);

                i.SetMetadata("BuildAction", "EmbeddedResource");

                // this data is set automatically through the AssignCulture task, so we manually set it here
                i.SetMetadata("WithCulture", "true");
                i.SetMetadata("Culture", "de");

                env.SetCurrentDirectory(Path.GetDirectoryName(resXFile.Path));

                CreateVisualBasicManifestResourceName t = new CreateVisualBasicManifestResourceName
                {
                    BuildEngine = new MockEngine(_testOutput),
                    UseDependentUponConvention = true,
                    ResourceFiles = new ITaskItem[] { i },
                };

                t.Execute().ShouldBeTrue("Expected the task to succeed");

                t.ManifestResourceNames.ShouldHaveSingleItem();

                // CreateManifestNameImpl appends culture to the end of the convention
                t.ManifestResourceNames[0].ItemSpec.ShouldBe("MyStuff.Class2.de", "Expected Namespace.Class.Culture");
            }
        }
        public void DependentWithEmbeddedCulture()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.fr-fr.resx",
                    null,            // Link file name
                    true,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    StreamHelpers.StringToStream(
                        @"
Namespace Nested.TestNamespace 
    Class TestClass 
    End Class
End Namespace
"),
                    null

                );

            Assert.Equal("RootNamespace.Nested.TestNamespace.TestClass.fr-fr", result);
        }
Пример #28
0
        public void DependentWithCultureMetadata()
        {
            string result =
                CreateVisualBasicManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.resx",
                    null,    // Link file name
                    true,
                    null,    // Root namespace
                    null,
                    "en-GB",
                    StreamHelpers.StringToStream(
                        @"
Namespace Nested.TestNamespace 
    Class TestClass 
    End Class
End Namespace
"),
                    null

                );

            Assert.AreEqual("Nested.TestNamespace.TestClass.en-GB", result);
        }