From 7fc86ffb7ecfdcaa156f1ff2d2ebccce176dc08e Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Sun, 25 Jun 2017 00:17:00 +0700 Subject: [PATCH] Use SR in System.Composition.Convention (dotnet/corefx#21499) Commit migrated from https://github.com/dotnet/corefx/commit/f94866d4e6d783bcb6ee4c32114c2161d5287abb --- .../Diagnostics/CompositionTrace.cs | 18 +- .../src/{ => Resources}/Strings.resx | 0 .../src/Strings.Designer.cs | 203 ------------------ .../src/System.Composition.Convention.csproj | 4 +- .../System/Composition/ExceptionBuilder.cs | 18 +- 5 files changed, 14 insertions(+), 229 deletions(-) rename src/libraries/System.Composition.Convention/src/{ => Resources}/Strings.resx (100%) delete mode 100644 src/libraries/System.Composition.Convention/src/Strings.Designer.cs diff --git a/src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTrace.cs b/src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTrace.cs index 46bccd9bc86..51b89673f7e 100644 --- a/src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTrace.cs +++ b/src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTrace.cs @@ -17,7 +17,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteInformation) { CompositionTraceSource.WriteInformation(CompositionTraceId.Registration_ConstructorConventionOverridden, - Strings.Registration_ConstructorConventionOverridden, + SR.Registration_ConstructorConventionOverridden, type.FullName); } } @@ -29,7 +29,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_TypeExportConventionOverridden, - Strings.Registration_TypeExportConventionOverridden, + SR.Registration_TypeExportConventionOverridden, type.FullName); } } @@ -41,7 +41,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberExportConventionOverridden, - Strings.Registration_MemberExportConventionOverridden, + SR.Registration_MemberExportConventionOverridden, member.Name, type.FullName); } } @@ -53,7 +53,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionOverridden, - Strings.Registration_MemberImportConventionOverridden, + SR.Registration_MemberImportConventionOverridden, member.Name, type.FullName); } } @@ -65,7 +65,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_OnSatisfiedImportNotificationOverridden, - Strings.Registration_OnSatisfiedImportNotificationOverridden, + SR.Registration_OnSatisfiedImportNotificationOverridden, member.Name, type.FullName); } } @@ -77,7 +77,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartCreationConventionOverridden, - Strings.Registration_PartCreationConventionOverridden, + SR.Registration_PartCreationConventionOverridden, type.FullName); } } @@ -89,7 +89,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionMatchedTwice, - Strings.Registration_MemberImportConventionMatchedTwice, + SR.Registration_MemberImportConventionMatchedTwice, member.Name, type.FullName); } } @@ -101,7 +101,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartMetadataConventionOverridden, - Strings.Registration_PartMetadataConventionOverridden, + SR.Registration_PartMetadataConventionOverridden, type.FullName); } } @@ -113,7 +113,7 @@ namespace Microsoft.Composition.Diagnostics if (CompositionTraceSource.CanWriteWarning) { CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_ParameterImportConventionOverridden, - Strings.Registration_ParameterImportConventionOverridden, + SR.Registration_ParameterImportConventionOverridden, parameter.Name, constructor.Name); } } diff --git a/src/libraries/System.Composition.Convention/src/Strings.resx b/src/libraries/System.Composition.Convention/src/Resources/Strings.resx similarity index 100% rename from src/libraries/System.Composition.Convention/src/Strings.resx rename to src/libraries/System.Composition.Convention/src/Resources/Strings.resx diff --git a/src/libraries/System.Composition.Convention/src/Strings.Designer.cs b/src/libraries/System.Composition.Convention/src/Strings.Designer.cs deleted file mode 100644 index 2c68b191228..00000000000 --- a/src/libraries/System.Composition.Convention/src/Strings.Designer.cs +++ /dev/null @@ -1,203 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.16815 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Internal { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("System.Composition.Convention.Strings", typeof(Strings).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to The value of argument '{0}' is not supported. The expression must use operator new.. - /// - internal static string Argument_ExpressionMustBeNew { - get { - return ResourceManager.GetString("Argument_ExpressionMustBeNew", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The value of argument '{0}' is not supported. The expression must be a property member expression.. - /// - internal static string Argument_ExpressionMustBePropertyMember { - get { - return ResourceManager.GetString("Argument_ExpressionMustBePropertyMember", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The value of argument '{0}' is not supported. The expression must be a void Method() member expression. - /// - internal static string Argument_ExpressionMustBeVoidMethodWithNoArguments - { - get - { - return ResourceManager.GetString("Argument_ExpressionMustBeVoidMethodWithNoArguments", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' cannot be an empty string ("").. - /// - internal static string ArgumentException_EmptyString { - get { - return ResourceManager.GetString("ArgumentException_EmptyString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The value of argument '{0}' ({1}) is not supported. Allowed values are : '{2}'.. - /// - internal static string ArgumentOutOfRange_InvalidEnumInSet { - get { - return ResourceManager.GetString("ArgumentOutOfRange_InvalidEnumInSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Internal error occurred. Additional information: '{0}'.. - /// - internal static string InternalExceptionMessage { - get { - return ResourceManager.GetString("InternalExceptionMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A constructor selection convention that would apply to Type '{0}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_ConstructorConventionOverridden { - get { - return ResourceManager.GetString("Registration_ConstructorConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An Export specification convention that would apply to Member '{0}' of type '{1}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_MemberExportConventionOverridden { - get { - return ResourceManager.GetString("Registration_MemberExportConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Only one import specification convention can apply to a single Member. More than one convention specification applies to this Member '{1}' of Type '{0}'.. - /// - internal static string Registration_MemberImportConventionMatchedTwice { - get { - return ResourceManager.GetString("Registration_MemberImportConventionMatchedTwice", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An Import specification convention that would apply to Member '{0}' of type '{1}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_MemberImportConventionOverridden { - get { - return ResourceManager.GetString("Registration_MemberImportConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A OnSatisfiedImport specification convention that would apply to Type '{0}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_OnSatisfiedImportNotificationOverridden { - get - { - return ResourceManager.GetString("Registration_OnSatisfiedImportNotificationOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A ParameterImport specification convention that would apply to Parameter '{0}' of Constructor '{1}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_ParameterImportConventionOverridden { - get { - return ResourceManager.GetString("Registration_ParameterImportConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A PartCreationPolicy specification convention that would apply to Type '{0}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_PartCreationConventionOverridden { - get { - return ResourceManager.GetString("Registration_PartCreationConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A PartMetadata specification convention that would apply to Type '{0}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_PartMetadataConventionOverridden { - get { - return ResourceManager.GetString("Registration_PartMetadataConventionOverridden", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An Export specification convention that would apply to type '{0}' has been overridden by attributes applied in the source file or by a prior convention.. - /// - internal static string Registration_TypeExportConventionOverridden { - get { - return ResourceManager.GetString("Registration_TypeExportConventionOverridden", resourceCulture); - } - } - - } -} diff --git a/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj index 4c4e1ad8c89..7a527198f36 100644 --- a/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj +++ b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj @@ -5,7 +5,7 @@ {E6592FAD-10B5-4B56-9287-D72DD136992F} Properties System.Composition.Convention - $(DefineConstants);netstandard10 + $(DefineConstants);netstandard10 netstandard1.0;portable-net45+win8+wp8+wpa81 @@ -39,7 +39,6 @@ - @@ -55,7 +54,6 @@ CommonStrings.Designer.cs Microsoft.Internal - diff --git a/src/libraries/System.Composition.Convention/src/System/Composition/ExceptionBuilder.cs b/src/libraries/System.Composition.Convention/src/System/Composition/ExceptionBuilder.cs index 4980e432dbd..73b56112fff 100644 --- a/src/libraries/System.Composition.Convention/src/System/Composition/ExceptionBuilder.cs +++ b/src/libraries/System.Composition.Convention/src/System/Composition/ExceptionBuilder.cs @@ -2,10 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Globalization; -using System.Reflection; - using Microsoft.Internal; namespace System.Composition @@ -14,30 +10,24 @@ namespace System.Composition { public static ArgumentException Argument_ExpressionMustBeNew(string parameterName) { - return CreateArgumentException(Strings.Argument_ExpressionMustBeNew, parameterName); + return CreateArgumentException(SR.Argument_ExpressionMustBeNew, parameterName); } public static ArgumentException Argument_ExpressionMustBePropertyMember(string parameterName) { - return CreateArgumentException(Strings.Argument_ExpressionMustBePropertyMember, parameterName); + return CreateArgumentException(SR.Argument_ExpressionMustBePropertyMember, parameterName); } - public static ArgumentException Argument_ExpressionMustBeVoidMethodWithNoArguments(string methodName) { - return CreateArgumentException(Strings.Argument_ExpressionMustBeVoidMethodWithNoArguments, methodName); + return CreateArgumentException(SR.Argument_ExpressionMustBeVoidMethodWithNoArguments, methodName); } private static ArgumentException CreateArgumentException(string message, string parameterName) { Assumes.NotNull(parameterName); - return new ArgumentException(Format(message, parameterName), parameterName); - } - - private static string Format(string format, params string[] arguments) - { - return String.Format(CultureInfo.CurrentCulture, format, arguments); + return new ArgumentException(SR.Format(message, parameterName), parameterName); } } }