Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some Mono corelib strings to resources/nameof #34089

Merged
merged 5 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] nam
throw new ArgumentNullException(nameof(names));

if (names.Length == 0)
throw new ArgumentException();
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));

for (int i = 0; i < names.Length; i++)
if (names[i] == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@
<value>ILGenerator usage is invalid.</value>
</data>
<data name="InvalidOperation_BadInstructionOrIndexOutOfBound" xml:space="preserve">
<value>MSIL instruction is invalid or index is out of bounds.</value>
<value>Opcodes using a short-form index cannot address a local position over 255.</value>
</data>
<data name="InvalidOperation_BadInterfaceNotAbstract" xml:space="preserve">
<value>Interface must be declared abstract.</value>
Expand Down Expand Up @@ -2927,7 +2927,7 @@
<value>Cannot resolve {0} to a TypeInfo object.</value>
</data>
<data name="NotSupported_NYI" xml:space="preserve">
<value>This feature is not currently implemented.</value>
<value>This feature is not implemented.</value>
</data>
<data name="NotSupported_ObsoleteResourcesFile" xml:space="preserve">
<value>Found an obsolete .resources file in assembly '{0}'. Rebuild that .resources file then rebuild that assembly.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public object GetValue(int index)

var lb = GetLowerBound(0);
if (index < lb || index > GetUpperBound(0))
throw new IndexOutOfRangeException("Index has to be between upper and lower bound of the array.");
throw new IndexOutOfRangeException(SR.Argument_IndexOutOfArrayBounds);

if (GetType().GetElementType()!.IsPointer)
throw new NotSupportedException(SR.NotSupported_Type);
Expand Down Expand Up @@ -430,7 +430,7 @@ public void SetValue(object? value, int index)

var lb = GetLowerBound(0);
if (index < lb || index > GetUpperBound(0))
throw new IndexOutOfRangeException("Index has to be >= lower bound and <= upper bound of the array.");
throw new IndexOutOfRangeException(SR.Argument_IndexOutOfArrayBounds);

if (GetType().GetElementType()!.IsPointer)
throw new NotSupportedException(SR.NotSupported_Type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ private static AttributeUsageAttribute RetrieveAttributeUsageNoCache(Type attrib
// anyone from using IL ofcourse
if (attribs.Length > 1)
{
throw new FormatException("Duplicate AttributeUsageAttribute cannot be specified on an attribute type.");
throw new FormatException(SR.Format(SR.Format_AttributeUsage, attributeType.GetType().FullName));
}

return ((AttributeUsageAttribute)attribs[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,18 @@ private void Initialize(ConstructorInfo con, object[] constructorArgs,
if (fieldValues == null)
throw new ArgumentNullException(nameof(fieldValues));
if (con.GetParametersCount() != constructorArgs.Length)
throw new ArgumentException("Parameter count does not match " +
"passed in argument value count.");
throw new ArgumentException(SR.Argument_BadParameterCountsForConstructor);
if (namedProperties.Length != propertyValues.Length)
throw new ArgumentException("Array lengths must be the same.",
"namedProperties, propertyValues");
throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues");
danmoseley marked this conversation as resolved.
Show resolved Hide resolved
if (namedFields.Length != fieldValues.Length)
throw new ArgumentException("Array lengths must be the same.",
"namedFields, fieldValues");
throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedFields, fieldValues");
if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static ||
(con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
throw new ArgumentException("Cannot have private or static constructor.");
throw new ArgumentException(SR.Argument_BadConstructor);

// Here coreclr does
// if ((con.CallingConvention & CallingConventions.Standard) != CallingConventions.Standard)
// throw new ArgumentException(SR.Argument_BadConstructorCallConv);

Type atype = ctor.DeclaringType;
int i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ protected override PropertyInfo GetPropertyImpl(
Type returnType, Type[] types,
ParameterModifier[] modifiers)
{
throw CreateNotSupportedException();
throw new NotSupportedException(SR.NotSupported_DynamicModule);
}

protected override bool HasElementTypeImpl()
Expand Down Expand Up @@ -438,11 +438,6 @@ public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
}

private Exception CreateNotSupportedException()
{
return new NotSupportedException("The invoked member is not supported in a dynamic module.");
}

internal override bool IsUserType
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void SetConstant(object defaultValue)
RejectIfCreated();

/*if (defaultValue.GetType() != type)
throw new ArgumentException ("Constant doesn't match field type");*/
throw new ArgumentException("Constant doesn't match field type");*/
def_value = defaultValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ public virtual void Emit(OpCode opcode, LocalBuilder local)
if (local == null)
throw new ArgumentNullException(nameof(local));
if (local.ilgen != this)
throw new ArgumentException("Trying to emit a local from a different ILGenerator.");
throw new ArgumentException(SR.Argument_UnmatchedMethodForLocal, nameof(local));

uint pos = local.position;
if ((opcode == OpCodes.Ldloca_S || opcode == OpCodes.Ldloc_S || opcode == OpCodes.Stloc_S) && pos > 255)
throw new InvalidOperationException("Opcodes using a short-form index cannot address a local position over 255.");
throw new InvalidOperationException(SR.InvalidOperation_BadInstructionOrIndexOutOfBound);

bool load_addr = false;
bool is_store = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] nam
if (names == null)
throw new ArgumentNullException(nameof(names));
if (names.Length == 0)
throw new ArgumentException("", nameof(names));
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));
type.check_not_created();
generic_params = new GenericTypeParameterBuilder[names.Length];
for (int i = 0; i < names.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public override Type GetType(string className, bool throwOnError, bool ignoreCas
if (className == null)
throw new ArgumentNullException(nameof(className));
if (className.Length == 0)
throw new ArgumentException("className");
throw new ArgumentException(SR.Argument_EmptyName, nameof(className));

TypeBuilder result = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal TypeBuilder(ModuleBuilder mb, TypeAttributes attr, int table_idx)
pmodule = mb;
}

internal TypeBuilder(ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type)
internal TypeBuilder(ModuleBuilder mb, string fullname, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type)
{
int sep_index;
this.parent = ResolveUserType(parent);
Expand All @@ -110,20 +110,20 @@ internal TypeBuilder(ModuleBuilder mb, string name, TypeAttributes attr, Type pa
this.packing_size = packing_size;
this.nesting_type = nesting_type;

check_name("fullname", name);
check_name(nameof(fullname), fullname);

if (parent == null && (attr & TypeAttributes.Interface) != 0 && (attr & TypeAttributes.Abstract) == 0)
throw new InvalidOperationException("Interface must be declared abstract.");
throw new InvalidOperationException(SR.InvalidOperation_BadInterfaceNotAbstract);

sep_index = name.LastIndexOf('.');
sep_index = fullname.LastIndexOf('.');
if (sep_index != -1)
{
this.tname = name.Substring(sep_index + 1);
this.nspace = name.Substring(0, sep_index);
this.tname = fullname.Substring(sep_index + 1);
this.nspace = fullname.Substring(0, sep_index);
}
else
{
this.tname = name;
this.tname = fullname;
this.nspace = string.Empty;
}
if (interfaces != null)
Expand All @@ -138,7 +138,7 @@ internal TypeBuilder(ModuleBuilder mb, string name, TypeAttributes attr, Type pa

// skip .<Module> ?
table_idx = mb.get_next_table_index(this, 0x02, 1);
fullname = GetFullName();
this.fullname = GetFullName();
}

public override Assembly Assembly
Expand Down Expand Up @@ -396,7 +396,7 @@ private TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type pare
/* This breaks mcs
if (((attrs & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||
((attrs & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
throw new ArgumentException ("attr", "Bad type flags for nested type.");
throw new ArgumentException (nameof(attr), "Bad type flags for nested type.");
*/
if (interfaces != null)
{
Expand Down Expand Up @@ -555,7 +555,7 @@ public MethodBuilder DefineMethod(string name, MethodAttributes attributes, Call

public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
check_name("name", name);
check_name(nameof(name), name);
check_not_created();
if (IsInterface && (
!((attributes & MethodAttributes.Abstract) != 0) ||
Expand Down Expand Up @@ -596,9 +596,9 @@ public MethodBuilder DefinePInvokeMethod(
CallingConvention nativeCallConv,
CharSet nativeCharSet)
{
check_name("name", name);
check_name("dllName", dllName);
check_name("entryName", entryName);
check_name(nameof(name), name);
check_name(nameof(dllName), dllName);
check_name(nameof(entryName), entryName);
if ((attributes & MethodAttributes.Abstract) != 0)
throw new ArgumentException("PInvoke methods must be static and native and cannot be abstract.");
if (IsInterface)
Expand Down Expand Up @@ -665,7 +665,7 @@ public FieldBuilder DefineField(string fieldName, Type type, FieldAttributes att

public FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
{
check_name("fieldName", fieldName);
check_name(nameof(fieldName), fieldName);
if (type == typeof(void))
throw new ArgumentException("Bad field type in defining field.");
check_not_created();
Expand Down Expand Up @@ -715,7 +715,7 @@ public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes

public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
check_name("name", name);
check_name(nameof(name), name);
if (parameterTypes != null)
foreach (Type param in parameterTypes)
if (param == null)
Expand Down Expand Up @@ -1544,12 +1544,12 @@ public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)

public EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype)
{
check_name("name", name);
check_name(nameof(name), name);
if (eventtype == null)
throw new ArgumentNullException("type");
check_not_created();
if (eventtype.IsByRef)
throw new ArgumentException(nameof(eventtype));
throw new ArgumentException(SR.Argument_CannotGetTypeTokenForByRef);
EventBuilder res = new EventBuilder(this, name, attributes, eventtype);
if (events != null)
{
Expand Down Expand Up @@ -1689,10 +1689,8 @@ private void check_name(string argName, string name)
{
if (name == null)
throw new ArgumentNullException(argName);
if (name.Length == 0)
throw new ArgumentException("Empty name is not legal", argName);
if (name[0] == ((char)0))
throw new ArgumentException("Illegal name", argName);
if (name.Length == 0 || name[0] == ((char)0))
throw new ArgumentException(SR.Argument_EmptyName, argName);
}

public override string ToString()
Expand Down Expand Up @@ -1812,7 +1810,7 @@ public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] nam
if (names == null)
throw new ArgumentNullException(nameof(names));
if (names.Length == 0)
throw new ArgumentException("names");
throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));

generic_params = new GenericTypeParameterBuilder[names.Length];
for (int i = 0; i < names.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ abstract class TypeBuilderInstantiation : TypeInfo
{
internal static Type MakeGenericType (Type type, Type[] typeArguments)
{
throw new NotSupportedException ("User types are not supported under full aot");
throw new NotSupportedException("User types are not supported under full aot");
}
}
}
Expand Down