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); }
/// <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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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"); }
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") ) ); }
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 ); }
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); }