Remove reduncant `ArgumentNullOrEmpty` resource from Core project

- came from Rendering but Core already had `ArgumentCannotBeNullOrEmpty`
- moved wording from "argument must not be" to "value cannot be"

Also make similar resources consistent in this repo
- adjust Razor's `ArgumentCannotBeNullOrEmpty` resource to use same wording
  as Core, adding "The"
- update ModelBinding to also have `ArgumentCannotBeNullOrEmpty` and to use
  it consistently with Core and Razor
This commit is contained in:
dougbu 2014-04-08 12:03:50 -07:00
parent b25091f6c1
commit 4feb8f4f28
11 changed files with 19 additions and 38 deletions

View File

@ -314,22 +314,6 @@ namespace Microsoft.AspNet.Mvc.Core
return GetString("ActionSelector_GetCandidateActionsIsAmbiguous"); return GetString("ActionSelector_GetCandidateActionsIsAmbiguous");
} }
/// <summary>
/// The argument must not be null or empty.
/// </summary>
internal static string ArgumentNullOrEmpty
{
get { return GetString("ArgumentNullOrEmpty"); }
}
/// <summary>
/// The argument must not be null or empty.
/// </summary>
internal static string FormatArgumentNullOrEmpty()
{
return GetString("ArgumentNullOrEmpty");
}
/// <summary> /// <summary>
/// Property '{0}' is of type '{1}', but this method requires a value of type '{2}'. /// Property '{0}' is of type '{1}', but this method requires a value of type '{2}'.
/// </summary> /// </summary>
@ -511,7 +495,7 @@ namespace Microsoft.AspNet.Mvc.Core
var value = _resourceManager.GetString(name); var value = _resourceManager.GetString(name);
System.Diagnostics.Debug.Assert(value != null); System.Diagnostics.Debug.Assert(value != null);
if (formatterNames != null) if (formatterNames != null)
{ {
for (var i = 0; i < formatterNames.Length; i++) for (var i = 0; i < formatterNames.Length; i++)

View File

@ -502,7 +502,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name); var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name);
if (string.IsNullOrEmpty(fullName)) if (string.IsNullOrEmpty(fullName))
{ {
throw new ArgumentException(Resources.ArgumentNullOrEmpty, "name"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name");
} }
var tagBuilder = new TagBuilder("input"); var tagBuilder = new TagBuilder("input");

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
if (string.IsNullOrEmpty(tagName)) if (string.IsNullOrEmpty(tagName))
{ {
throw new ArgumentException(Resources.ArgumentNullOrEmpty, "tagName"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "tagName");
} }
TagName = tagName; TagName = tagName;
@ -114,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
if (string.IsNullOrEmpty(key)) if (string.IsNullOrEmpty(key))
{ {
throw new ArgumentException(Resources.ArgumentNullOrEmpty, "key"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "key");
} }
if (replaceExisting || !Attributes.ContainsKey(key)) if (replaceExisting || !Attributes.ContainsKey(key))

View File

@ -160,7 +160,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
if (string.IsNullOrEmpty(expression)) if (string.IsNullOrEmpty(expression))
{ {
throw new ArgumentException(Resources.ArgumentNullOrEmpty, "expression"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "expression");
} }
return ViewDataEvaluator.Eval(this, expression); return ViewDataEvaluator.Eval(this, expression);

View File

@ -174,9 +174,6 @@
<data name="ActionSelector_GetCandidateActionsIsAmbiguous" xml:space="preserve"> <data name="ActionSelector_GetCandidateActionsIsAmbiguous" xml:space="preserve">
<value>The supplied route values are ambiguous and can select multiple sets of actions.</value> <value>The supplied route values are ambiguous and can select multiple sets of actions.</value>
</data> </data>
<data name="ArgumentNullOrEmpty" xml:space="preserve">
<value>The argument must not be null or empty.</value>
</data>
<data name="ArgumentPropertyUnexpectedType" xml:space="preserve"> <data name="ArgumentPropertyUnexpectedType" xml:space="preserve">
<value>Property '{0}' is of type '{1}', but this method requires a value of type '{2}'.</value> <value>Property '{0}' is of type '{1}', but this method requires a value of type '{2}'.</value>
</data> </data>

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{ {
if (string.IsNullOrEmpty(propertyName)) if (string.IsNullOrEmpty(propertyName))
{ {
throw new ArgumentException(Resources.FormatArgumentNullOrEmpty("propertyName"), "propertyName"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "propertyName");
} }
var typeInfo = GetTypeInformation(containerType); var typeInfo = GetTypeInformation(containerType);

View File

@ -11,19 +11,19 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
= new ResourceManager("Microsoft.AspNet.Mvc.ModelBinding.Resources", typeof(Resources).GetTypeInfo().Assembly); = new ResourceManager("Microsoft.AspNet.Mvc.ModelBinding.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary> /// <summary>
/// The argument '{0}' is null or empty. /// The value cannot be null or empty.
/// </summary> /// </summary>
internal static string ArgumentNullOrEmpty internal static string ArgumentCannotBeNullOrEmpty
{ {
get { return GetString("ArgumentNullOrEmpty"); } get { return GetString("ArgumentCannotBeNullOrEmpty"); }
} }
/// <summary> /// <summary>
/// The argument '{0}' is null or empty. /// The value cannot be null or empty.
/// </summary> /// </summary>
internal static string FormatArgumentNullOrEmpty(object p0) internal static string FormatArgumentCannotBeNullOrEmpty()
{ {
return string.Format(CultureInfo.CurrentCulture, GetString("ArgumentNullOrEmpty"), p0); return GetString("ArgumentCannotBeNullOrEmpty");
} }
/// <summary> /// <summary>

View File

@ -117,8 +117,8 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="ArgumentNullOrEmpty" xml:space="preserve"> <data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
<value>The argument '{0}' is null or empty.</value> <value>The value cannot be null or empty.</value>
</data> </data>
<data name="Common_PropertyNotFound" xml:space="preserve"> <data name="Common_PropertyNotFound" xml:space="preserve">
<value>The property {0}.{1} could not be found.</value> <value>The property {0}.{1} could not be found.</value>

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.Razor
= new ResourceManager("Microsoft.AspNet.Mvc.Razor.Resources", typeof(Resources).GetTypeInfo().Assembly); = new ResourceManager("Microsoft.AspNet.Mvc.Razor.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary> /// <summary>
/// Value cannot be null or empty. /// The value cannot be null or empty.
/// </summary> /// </summary>
internal static string ArgumentCannotBeNullOrEmpty internal static string ArgumentCannotBeNullOrEmpty
{ {
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor
} }
/// <summary> /// <summary>
/// Value cannot be null or empty. /// The value cannot be null or empty.
/// </summary> /// </summary>
internal static string FormatArgumentCannotBeNullOrEmpty() internal static string FormatArgumentCannotBeNullOrEmpty()
{ {

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve"> <data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
<value>Value cannot be null or empty.</value> <value>The value cannot be null or empty.</value>
</data> </data>
<data name="LayoutCannotBeLocated" xml:space="preserve"> <data name="LayoutCannotBeLocated" xml:space="preserve">
<value>The layout view '{0}' could not be located.</value> <value>The layout view '{0}' could not be located.</value>

View File

@ -83,11 +83,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test.Binders
ExceptionAssert.ThrowsArgument( ExceptionAssert.ThrowsArgument(
() => provider.GetMetadataForProperty(modelAccessor: null, containerType: typeof(object), propertyName: null), () => provider.GetMetadataForProperty(modelAccessor: null, containerType: typeof(object), propertyName: null),
"propertyName", "propertyName",
"The argument 'propertyName' is null or empty."); "The value cannot be null or empty.");
ExceptionAssert.ThrowsArgument( ExceptionAssert.ThrowsArgument(
() => provider.GetMetadataForProperty(modelAccessor: null, containerType: typeof(object), propertyName: String.Empty), () => provider.GetMetadataForProperty(modelAccessor: null, containerType: typeof(object), propertyName: String.Empty),
"propertyName", "propertyName",
"The argument 'propertyName' is null or empty."); "The value cannot be null or empty.");
} }
[Fact] [Fact]