Fix exception message formatting in HasCustomAttribute

This commit is contained in:
Oliver Booth 2022-04-29 11:13:41 +01:00
parent ba6c400a79
commit 164c4e4455
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
3 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,4 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000 // Runtime Version:4.0.30319.42000
@ -160,7 +160,7 @@ namespace X10D {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to {{0}} does not inherit {typeof(Attribute)}. /// Looks up a localized string similar to {0} does not inherit {1}.
/// </summary> /// </summary>
internal static string TypeDoesNotInheritAttribute { internal static string TypeDoesNotInheritAttribute {
get { get {
@ -169,7 +169,7 @@ namespace X10D {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to {{0}} is not a class.. /// Looks up a localized string similar to {0} is not a class..
/// </summary> /// </summary>
internal static string TypeIsNotClass { internal static string TypeIsNotClass {
get { get {
@ -178,7 +178,7 @@ namespace X10D {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to {{0}} is not an interface.. /// Looks up a localized string similar to {0} is not an interface..
/// </summary> /// </summary>
internal static string TypeIsNotInterface { internal static string TypeIsNotInterface {
get { get {

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@ -27,13 +27,13 @@
<value>The buffer is too small to contain the data.</value> <value>The buffer is too small to contain the data.</value>
</data> </data>
<data name="TypeIsNotClass" xml:space="preserve"> <data name="TypeIsNotClass" xml:space="preserve">
<value>{{0}} is not a class.</value> <value>{0} is not a class.</value>
</data> </data>
<data name="TypeIsNotInterface" xml:space="preserve"> <data name="TypeIsNotInterface" xml:space="preserve">
<value>{{0}} is not an interface.</value> <value>{0} is not an interface.</value>
</data> </data>
<data name="TypeDoesNotInheritAttribute" xml:space="preserve"> <data name="TypeDoesNotInheritAttribute" xml:space="preserve">
<value>{{0}} does not inherit {typeof(Attribute)}</value> <value>{0} does not inherit {1}</value>
</data> </data>
<data name="HashAlgorithmNoCreateMethod" xml:space="preserve"> <data name="HashAlgorithmNoCreateMethod" xml:space="preserve">
<value>HashAlgorithm does not offer Create method.</value> <value>HashAlgorithm does not offer Create method.</value>

View File

@ -1,4 +1,4 @@
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
namespace X10D.Reflection; namespace X10D.Reflection;
@ -53,9 +53,8 @@ public static class MemberInfoExtensions
if (!attribute.Inherits<Attribute>()) if (!attribute.Inherits<Attribute>())
{ {
throw new ArgumentException( throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, ExceptionMessages.TypeDoesNotInheritAttribute,
string.Format(CultureInfo.CurrentCulture, ExceptionMessages.TypeDoesNotInheritAttribute, attribute), attribute, typeof(Attribute)), nameof(attribute));
nameof(attribute));
} }
return member.GetCustomAttribute(attribute) is not null; return member.GetCustomAttribute(attribute) is not null;