From b65507e2e548503766ef891a5744df014ee8f103 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Thu, 20 Jul 2017 09:52:50 -0700 Subject: Update buildtools and UAP runners version to merge resources into pri file for UAP tests (#22418) * Update buildtools and UAP runners version to merge resources into pri file for UAP tests * Fix CI and Add new separator to ComponentResourceManager * Fix Typo in comment * Fix NETFX Ci failures --- .../ComponentModel/ComponentResourceManager.cs | 6 +-- .../tests/ComponentResourceManagerTests.cs | 44 +++++++++++++++--- .../tests/Resources/TestResx.Designer.cs | 52 ++++++++++++++++++---- .../tests/Resources/TestResx.resx | 26 ++++++++--- 4 files changed, 105 insertions(+), 23 deletions(-) (limited to 'src/System.ComponentModel.TypeConverter') diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs index 265da59ef2..a0a03edcc9 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentResourceManager.cs @@ -63,7 +63,7 @@ namespace System.ComponentModel /// /// This method examines all the resources for the provided culture. /// When it finds a resource with a key in the format of - /// "[objectName].[property name]" it will apply that resource's value + /// "[objectName].[property name]" or "[objectName]-[property name]" it will apply that resource's value /// to the corresponding property on the object. If there is no matching /// property the resource will be ignored. /// @@ -149,10 +149,10 @@ namespace System.ComponentModel } } - // Character after objectName.Length should be a ".", or else we should continue. + // Character after objectName.Length should be a "." or a '-', or else we should continue. // int idx = objectName.Length; - if (key.Length <= idx || key[idx] != '.') + if (key.Length <= idx || (key[idx] != '.' && key[idx] != '-')) { continue; } diff --git a/src/System.ComponentModel.TypeConverter/tests/ComponentResourceManagerTests.cs b/src/System.ComponentModel.TypeConverter/tests/ComponentResourceManagerTests.cs index d4534f2f99..1e0aef618f 100644 --- a/src/System.ComponentModel.TypeConverter/tests/ComponentResourceManagerTests.cs +++ b/src/System.ComponentModel.TypeConverter/tests/ComponentResourceManagerTests.cs @@ -42,9 +42,17 @@ namespace System.ComponentModel.Tests var value = new TestValue(); resourceManager.ApplyResources(value, "Object"); - Assert.Equal("One", value.GetSetProperty); + Assert.Equal("ObjectGetSetProperty", value.GetSetProperty); Assert.Null(value.GetOnlyProperty); Assert.Null(value.GetPrivateProperty()); + + if (!PlatformDetection.IsFullFramework) // https://github.com/dotnet/corefx/issues/22444 needs to be ported to netfx + { + resourceManager.ApplyResources(value, "Default"); + Assert.Equal("DefaultGetSetProperty", value.GetSetProperty); + Assert.Null(value.GetOnlyProperty); + Assert.Null(value.GetPrivateProperty()); + } } private class TestValue @@ -92,7 +100,15 @@ namespace System.ComponentModel.Tests resourceManager.ApplyResources(value, "Object"); Assert.Null(value.GetSetProperty); - Assert.Equal("One", value.getsetproperty); + Assert.Equal("ObjectGetSetProperty", value.getsetproperty); + + if (!PlatformDetection.IsFullFramework) // https://github.com/dotnet/corefx/issues/22444 needs to be ported to netfx + { + resourceManager.ApplyResources(value, "Default"); + + Assert.Null(value.GetSetProperty); + Assert.Equal("DefaultGetSetProperty", value.getsetproperty); + } } public class MulticaseBaseClass @@ -117,7 +133,13 @@ namespace System.ComponentModel.Tests var value = new TestComponent(); resourceManager.ApplyResources(value, "Object"); - Assert.Equal("One", value.GetSetProperty); + Assert.Equal("ObjectGetSetProperty", value.GetSetProperty); + + if (!PlatformDetection.IsFullFramework) // https://github.com/dotnet/corefx/issues/22444 needs to be ported to netfx + { + resourceManager.ApplyResources(value, "Default"); + Assert.Equal("DefaultGetSetProperty", value.GetSetProperty); + } } [Fact] @@ -130,7 +152,13 @@ namespace System.ComponentModel.Tests var value = new TestComponent { Site = new TestSite { DesignMode = false } }; resourceManager.ApplyResources(value, "Object"); - Assert.Equal("One", value.GetSetProperty); + Assert.Equal("ObjectGetSetProperty", value.GetSetProperty); + + if (!PlatformDetection.IsFullFramework) // https://github.com/dotnet/corefx/issues/22444 needs to be ported to netfx + { + resourceManager.ApplyResources(value, "Default"); + Assert.Equal("DefaultGetSetProperty", value.GetSetProperty); + } } [Fact] @@ -144,7 +172,13 @@ namespace System.ComponentModel.Tests var value = new TestComponent { Site = new TestSite { DesignMode = true } }; resourceManager.ApplyResources(value, "Object"); - Assert.Equal("One", value.GetSetProperty); + Assert.Equal("ObjectGetSetProperty", value.GetSetProperty); + + if (!PlatformDetection.IsFullFramework) // https://github.com/dotnet/corefx/issues/22444 needs to be ported to netfx + { + resourceManager.ApplyResources(value, "Default"); + Assert.Equal("DefaultGetSetProperty", value.GetSetProperty); + } } private class TestSite : ISite diff --git a/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.Designer.cs b/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.Designer.cs index b92d389fb5..49fff5dbce 100644 --- a/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.Designer.cs +++ b/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.Designer.cs @@ -66,21 +66,57 @@ namespace Resources { /// internal static string _ { get { - return ResourceManager.GetString("", resourceCulture); + return ResourceManager.GetString("_", resourceCulture); } } /// - /// Looks up a localized string similar to Value-One. + /// Looks up a localized string similar to Default. /// - internal static string Object { + internal static string Default { get { - return ResourceManager.GetString("Object", resourceCulture); + return ResourceManager.GetString("Default", resourceCulture); } } /// - /// Looks up a localized string similar to Third. + /// Looks up a localized string similar to DefaultGetOnlyProperty. + /// + internal static string Default_GetOnlyProperty { + get { + return ResourceManager.GetString("Default-GetOnlyProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DefaultGetSetProperty. + /// + internal static string Default_GetSetProperty { + get { + return ResourceManager.GetString("Default-GetSetProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DefaultNoSuchProperty. + /// + internal static string Default_NoSuchProperty { + get { + return ResourceManager.GetString("Default-NoSuchProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DefaultPrivateProperty. + /// + internal static string Default_PrivateProperty { + get { + return ResourceManager.GetString("Default-PrivateProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to ObjectGetOnlyProperty. /// internal static string Object_GetOnlyProperty { get { @@ -89,7 +125,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to One. + /// Looks up a localized string similar to ObjectGetSetProperty. /// internal static string Object_GetSetProperty { get { @@ -98,7 +134,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to Second. + /// Looks up a localized string similar to ObjectNoSuchProperty. /// internal static string Object_NoSuchProperty { get { @@ -107,7 +143,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to Third. + /// Looks up a localized string similar to ObjectPrivateProperty. /// internal static string Object_PrivateProperty { get { diff --git a/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.resx b/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.resx index cc748dee7e..a088c94d90 100644 --- a/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.resx +++ b/src/System.ComponentModel.TypeConverter/tests/Resources/TestResx.resx @@ -58,22 +58,34 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + No Name - - Value-One + + Default + + + DefaultGetSetProperty + + + DefaultNoSuchProperty + + + DefaultGetOnlyProperty + + + DefaultPrivateProperty - One + ObjectGetSetProperty - Second + ObjectNoSuchProperty - Third + ObjectGetOnlyProperty - Third + ObjectPrivateProperty \ No newline at end of file -- cgit v1.2.3