コード例 #1
0
        public void Regress249540()
        {
            // Special character is 'Ä' in UTF8: 0xC3 84
            MemoryStream sourcesStream = (MemoryStream)StreamHelpers.StringToStream("namespace d??a { class Class {} }");

            // Instead, directly write the ANSI character into the memory buffer.
            sourcesStream.Seek(11, SeekOrigin.Begin);
            sourcesStream.WriteByte(0xc3);    // Plug the first byte of 'Ä' in.
            sourcesStream.WriteByte(0x84);    // Plug the second byte of 'Ä' in.
            sourcesStream.Seek(0, SeekOrigin.Begin);

            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"irrelevent",
                    null,
                    true,
                    null,    // Root namespace
                    null,
                    null,
                    sourcesStream,
                    null
                );

            Assert.Equal("d\u00C4a.Class", result);
        }
コード例 #2
0
        /// <summary>
        /// helper method for verifying manifest resource names
        /// </summary>
        private void VerifyExpectedManifestResourceName(string resourcePath, string expectedName)
        {
            string result   = CreateCSharpManifestResourceName.CreateManifestNameImpl(resourcePath, null, true, "Root", null, null, null, null);
            string expected = "Root." + expectedName;

            Assert.Equal(result, expected);
        }
コード例 #3
0
        public void Regress249540()
        {
            // Special character is 'Ä' in UTF8: 0xC3 84
            MemoryStream sourcesStream = (MemoryStream)StreamHelpers.StringToStream("namespace d??a { class Class {} }");

            // Instead, directly write the ANSI character into the memory buffer.
            sourcesStream.Seek(11, SeekOrigin.Begin);
            sourcesStream.WriteByte(0xc3);    // Plug the first byte of 'Ä' in.
            sourcesStream.WriteByte(0x84);    // Plug the second byte of 'Ä' in.
            sourcesStream.Seek(0, SeekOrigin.Begin);

            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"irrelevant",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: null,    // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: sourcesStream,
                    log: null
                );

            Assert.Equal("d\u00C4a.Class", result);
        }
コード例 #4
0
        public void CulturedResourcesFileWithRootNamespaceWithinSubfolder()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\MyResource.fr.resources",
                    null,            // Link file name
                    false,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal(@"RootNamespace.SubFolder.MyResource.fr.resources", result);
        }
コード例 #5
0
        public void Regress419591_EmptySource()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.en-GB.resx",
                    null,
                    true,
                    "RootNamespace",
                    "MyForm.en-GB.cs",
                    null,
                    StreamHelpers.StringToStream(""),
                    null
                );

            Assert.Equal("RootNamespace.MyForm.en-GB", result);
        }
コード例 #6
0
        public void Regress419591()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.en-GB.resx",
                    null,
                    true,
                    "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    "MyForm.en-GB.cs",
                    null,
                    StreamHelpers.StringToStream("namespace ClassLibrary1 { class MyForm {} }"),
                    null
                );

            Assert.Equal("ClassLibrary1.MyForm", result);
        }
コード例 #7
0
        public void CulturedBitmapWithRootNamespaceNoDirectoryPrefix()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\SplashScreen.fr.bmp",
                    null,            // Link file name
                    false,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal(@"RootNamespace.SubFolder.SplashScreen.bmp", result);
        }
コード例 #8
0
        public void CulturedBitmapWithRootNamespace()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\SplashScreen.fr.bmp",
                    null,
                    true,
                    "RootNamespace",        // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal(FileUtilities.FixFilePath(@"fr\RootNamespace.SubFolder.SplashScreen.bmp"), result);
        }
コード例 #9
0
        public void BitmapWithRootNamespace()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\SplashScreen.bmp",
                    null,
                    true,
                    "RootNamespace",        // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal("RootNamespace.SubFolder.SplashScreen.bmp", result);
        }
コード例 #10
0
        public void Basic()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.resx",
                    null,
                    true,
                    null,    // Root namespace
                    null,
                    null,
                    StreamHelpers.StringToStream("namespace MyStuff.Namespace { class Class {} }"),
                    null
                );

            Assert.Equal("MyStuff.Namespace.Class", result);
        }
コード例 #11
0
        public void Regress222308()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"..\..\XmlEditor\Setup\XmlEditor.rgs",
                    @"XmlEditor.rgs",
                    true,
                    "RootNamespace",        // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal("RootNamespace.XmlEditor.rgs", result);
        }
コード例 #12
0
        public void RootnamespaceWithCulture()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"SubFolder\MyForm.en-GB.ResX",
                    null,
                    true,
                    "RootNamespace",        // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal("RootNamespace.SubFolder.MyForm.en-GB", result);
        }
コード例 #13
0
        public void DependentWithEmbeddedCulture()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.fr-fr.resx",
                    null,
                    true,
                    "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    null,
                    null,
                    StreamHelpers.StringToStream("namespace MyStuff.Namespace { class Class {} }"),
                    null
                );

            Assert.Equal("MyStuff.Namespace.Class.fr-fr", result);
        }
コード例 #14
0
        public void ResourcesFileWithRootNamespace()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"MyResource.resources",
                    null,            // Link file name
                    false,
                    "RootNamespace", // Root namespace
                    null,
                    null,
                    null,
                    null
                );

            Assert.Equal(@"RootNamespace.MyResource.resources", result);
        }
コード例 #15
0
        public void ResourcesFileWithRootNamespace()
        {
            string result =
                CreateCSharpManifestResourceName.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);
        }
コード例 #16
0
        public void Regress419591()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: "MyForm.en-GB.resx",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    dependentUponFileName: "MyForm.en-GB.cs",
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream("namespace ClassLibrary1 { class MyForm {} }"),
                    log: null
                );

            Assert.Equal("ClassLibrary1.MyForm", result);
        }
コード例 #17
0
        public void RelativeDependentUpon()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"f:\myproject\SubFolder\MyForm.resx",
                    null,
                    true,
                    null,    // Root namespace
                    null,
                    null,
                    StreamHelpers.StringToStream("namespace Namespace { class Class {} }"),
                    null
                );

            Assert.AreEqual("Namespace.Class", result);
        }
コード例 #18
0
        public void Regress419591_EmptySource()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: "MyForm.en-GB.resx",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",
                    dependentUponFileName: "MyForm.en-GB.cs",
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream(""),
                    log: null
                );

            Assert.Equal("RootNamespace.MyForm.en-GB", result);
        }
コード例 #19
0
        public void CulturedBitmapWithRootNamespaceNoDirectoryPrefix()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"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.SubFolder.SplashScreen.bmp", result);
        }
コード例 #20
0
        public void Regress222308()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"..\..\XmlEditor\Setup\XmlEditor.rgs",
                    linkFileName: @"XmlEditor.rgs",
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null
                );

            Assert.Equal("RootNamespace.XmlEditor.rgs", result);
        }
コード例 #21
0
        public void CulturedBitmapWithRootNamespace()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"SubFolder\SplashScreen.fr.bmp",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null
                );

            Assert.Equal(FileUtilities.FixFilePath(@"fr\RootNamespace.SubFolder.SplashScreen.bmp"), result);
        }
コード例 #22
0
        public void Basic()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"f:\myproject\SubFolder\MyForm.resx",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: null,    // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream("namespace MyStuff.Namespace { class Class {} }"),
                    log: null
                );

            Assert.Equal("MyStuff.Namespace.Class", result);
        }
コード例 #23
0
        public void RootnamespaceWithCulture()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"SubFolder\MyForm.en-GB.ResX",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null
                );

            Assert.Equal("RootNamespace.SubFolder.MyForm.en-GB", result);
        }
コード例 #24
0
        public void DependentWithEmbeddedCulture()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"f:\myproject\SubFolder\MyForm.fr-fr.resx",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: StreamHelpers.StringToStream("namespace MyStuff.Namespace { class Class {} }"),
                    log: null
                );

            Assert.Equal("MyStuff.Namespace.Class.fr-fr", result);
        }
コード例 #25
0
        public void RootnamespaceWithCulture_RetainCultureInFileName()
        {
            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    fileName: @"Subfolder\File.cs.cshtml",
                    linkFileName: null,
                    prependCultureAsDirectory: true,
                    rootNamespace: "RootNamespace",        // Root namespace
                    dependentUponFileName: null,
                    culture: null,
                    binaryStream: null,
                    log: null,
                    treatAsCultureNeutral: true // retain culture in name
                );

            result.ShouldBe("RootNamespace.Subfolder.File.cs.cshtml");
        }
コード例 #26
0
        public void Regress459265()
        {
            MockEngine m = new MockEngine();
            CreateCSharpManifestResourceName c = new CreateCSharpManifestResourceName();

            c.BuildEngine = m;

            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    "MyForm.resx",
                    null,
                    true,
                    "RootNamespace",    // Root namespace (will be ignored because it's dependent)
                    "MyForm.cs",
                    null,
                    StreamHelpers.StringToStream(
                        @"using System;
#if false
namespace ClassLibrary1
#endif
#if Debug
namespace ClassLibrary2
#else
namespace ClassLibrary3
#endif 
{
    class MyForm 
    {
    }
}"
                        ),
                    c.Log
                );

            Assert.IsTrue
            (
                m.Log.Contains
                (
                    String.Format(AssemblyResources.GetString("CreateManifestResourceName.DefinitionFoundWithinConditionalDirective"), "MyForm.cs", "MyForm.resx")
                )
            );
        }
コード例 #27
0
        public void Regress459265()
        {
            MockEngine m = new MockEngine();
            CreateCSharpManifestResourceName c = new CreateCSharpManifestResourceName();

            c.BuildEngine = m;

            CreateCSharpManifestResourceName.CreateManifestNameImpl
            (
                fileName: "MyForm.resx",
                linkFileName: null,
                prependCultureAsDirectory: true,
                rootNamespace: "RootNamespace",        // Root namespace (will be ignored because it's dependent)
                dependentUponFileName: "MyForm.cs",
                culture: null,
                binaryStream: StreamHelpers.StringToStream(
                    @"using System;
#if false
namespace ClassLibrary1
#endif
#if Debug
namespace ClassLibrary2
#else
namespace ClassLibrary3
#endif
{
    class MyForm 
    {
    }
}"
                    ),
                log: c.Log
            );

            Assert.Contains(
                String.Format(AssemblyResources.GetString("CreateManifestResourceName.DefinitionFoundWithinConditionalDirective"), "MyForm.cs", "MyForm.resx"),
                m.Log
                );
        }
コード例 #28
0
        public void Regress172107()
        {
            // Can't embed the 'Ã' directly because the string is Unicode already and the Unicode<-->ANSI transform
            // isn't bidirectional.
            MemoryStream sourcesStream = (MemoryStream)StreamHelpers.StringToStream("namespace d?a { class Class {} }");

            // Instead, directly write the ANSI character into the memory buffer.
            sourcesStream.Seek(11, SeekOrigin.Begin);
            sourcesStream.WriteByte(0xc3);    // Plug the 'Ã' in
            sourcesStream.Seek(0, SeekOrigin.Begin);

            string result =
                CreateCSharpManifestResourceName.CreateManifestNameImpl
                (
                    @"irrelevant",
                    null,
                    true,
                    null,    // Root namespace
                    null,
                    null,
                    sourcesStream,
                    null
                );


            MemoryStream m = new MemoryStream();

            m.Write(new byte[] { 0x64, 0xc3, 0x61, 0x2e, 0x43, 0x6c, 0x61, 0x73, 0x73 }, 0, 9); // dÃa.Class in ANSI
            m.Flush();
            m.Seek(0, SeekOrigin.Begin);
#if FEATURE_ENCODING_DEFAULT
            StreamReader r = new StreamReader(m, System.Text.Encoding.Default, true); // HIGHCHAR: Test reads ANSI because that's the scenario.
#else
            StreamReader r = new StreamReader(m, System.Text.Encoding.ASCII, true);   // HIGHCHAR: Test reads ANSI because that's the scenario.
#endif
            string className = r.ReadToEnd();

            Assert.Equal(className, result);
        }