Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 numberDiff line numberDiff line change
Expand Up@@ -1189,12 +1189,12 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess

if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
{
throw new ArgumentException(SR.Argument_NotExceptionType);
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
}
ConstructorInfo? con = excType.GetConstructor(Type.EmptyTypes);
if (con == null)
{
throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
}
Emit(OpCodes.Newobj, con);
Emit(OpCodes.Throw);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1708,7 +1708,7 @@ void ResolveFuncEvalGenericArgInfo(DebuggerEval *pDE)
// If this is a new object operation, then we should have a .ctor.
if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsCtor())
{
COMPlusThrow(kArgumentException, W("Argument_MissingDefaultConstructor"));
COMPlusThrow(kArgumentException, W("Arg_NoDefCTorWithoutTypeName"));
}

pDE->m_md->EnsureActive();
Expand Down
185 changes: 181 additions & 4 deletions src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mono/System.Private.CoreLib/src/Mono/HotReload.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ public static FieldStore Create (RuntimeTypeHandle type)
else if (t.IsClass || t.IsInterface)
loc = null;
else
throw new ArgumentException("EnC: Expected a primitive, valuetype, class or interface field");
throw new ArgumentException(SR.Arg_EnC_ExpectedPrimitive);
/* FIXME: do we want FieldStore to be pinned? */
return new FieldStore(loc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,10 +122,10 @@ private static void Copy(Array sourceArray, int sourceIndex, Array destinationAr
throw new RankException(SR.Rank_MultiDimNotSupported);

if (sourceIndex < 0)
throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

if (destinationIndex < 0)
throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0.");
throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_NeedNonNegNum);

var src = sourceArray;
var dst = destinationArray;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/System.Private.CoreLib/src/System/ModuleHandle.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ public int MDStreamVersion
get
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
return RuntimeModule.GetMDStreamVersion(value);
}
}
Expand DownExpand Up@@ -68,10 +68,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveTypeToken(value, typeToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64()));
throw new TypeLoadException(SR.Format(SR.ClassLoad_General_Hex, typeToken, value.ToInt64()));
else
return new RuntimeTypeHandle(res);
}
Expand All@@ -80,10 +80,10 @@ public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[]? t
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);
IntPtr res = RuntimeModule.ResolveMethodToken(value, methodToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, methodToken, value.ToInt64()));
else
return new RuntimeMethodHandle(res);
}
Expand All@@ -92,11 +92,11 @@ public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandl
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[]? typeInstantiationContext, RuntimeTypeHandle[]? methodInstantiationContext)
{
if (value == IntPtr.Zero)
throw new ArgumentNullException(string.Empty, "Invalid handle");
throw new ArgumentNullException(string.Empty, SR.Arg_InvalidHandle);

IntPtr res = RuntimeModule.ResolveFieldToken(value, fieldToken, ptrs_from_handles(typeInstantiationContext), ptrs_from_handles(methodInstantiationContext), out _);
if (res == IntPtr.Zero)
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64()));
throw new Exception(SR.Format(SR.ClassLoad_General_Hex, fieldToken, value.ToInt64()));
else
return new RuntimeFieldHandle(res);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,11 +200,11 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type t = fi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Field '" + fi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotBelongToConstructorClass, fi.Name));
if (!IsValidType(fi.FieldType))
throw new ArgumentException("Field '" + fi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidType, fi.Name));
if (!IsValidValue(fi.FieldType, fieldValues[i]))
throw new ArgumentException("Field " + fi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_FieldDoesNotHaveAValidValue, fi.Name));
// FIXME: Check enums and TypeBuilders as well
if (fieldValues[i] != null)
// IsEnum does not seem to work on TypeBuilders
Expand All@@ -215,7 +215,7 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
// MS.NET allows this
//
if (!fi.FieldType.IsArray)
throw new ArgumentException("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
throw new ArgumentException(SR.Format(SR.Argument_UnmatchedFieldValueAndType, fi.Name, fi.FieldType));
}
i++;
}
Expand All@@ -224,19 +224,19 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
foreach (PropertyInfo pi in namedProperties)
{
if (!pi.CanWrite)
throw new ArgumentException("Property '" + pi.Name + "' does not have a setter.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyMissingSetter, pi.Name));
Type t = pi.DeclaringType!;
if ((atype != t) && (!t.IsSubclassOf(atype)) && (!atype.IsSubclassOf(t)))
throw new ArgumentException("Property '" + pi.Name + "' does not belong to the same class as the constructor");
throw new ArgumentException(SR.Format(SR.Argument_PropertyClassUnmatchedWithConstructor, pi.Name));
if (!IsValidType(pi.PropertyType))
throw new ArgumentException("Property '" + pi.Name + "' does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidType, pi.Name));
if (!IsValidValue(pi.PropertyType, propertyValues[i]))
throw new ArgumentException("Property " + pi.Name + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_PropertyInvalidValue, pi.Name));
if (propertyValues[i] != null)
{
if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsInstanceOfType(propertyValues[i]))
if (!pi.PropertyType.IsArray)
throw new ArgumentException("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues[i]);
throw new ArgumentException(SR.Format(SR.Argument_PropertyUnmatchingPropertyType, pi.Name, pi.PropertyType, propertyValues[i]));
}
i++;
}
Expand All@@ -248,17 +248,17 @@ private void Initialize(ConstructorInfo con, object?[] constructorArgs,
{
Type paramType = pi.ParameterType;
if (!IsValidType(paramType))
throw new ArgumentException("Parameter " + i + " does not have a valid type.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidType, i));
if (!IsValidValue(paramType, constructorArgs[i]))
throw new ArgumentException("Parameter " + i + " is not a valid value.");
throw new ArgumentException(SR.Format(SR.Argument_ParameterInvalidValue, i));

if (constructorArgs[i] != null)
{
if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsInstanceOfType(constructorArgs[i]))
if (!paramType.IsArray)
throw new ArgumentException("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs[i]);
throw new ArgumentException(SR.Format(SR.Argument_ParameterHasUnmatchedArgumentValue, i, paramType, constructorArgs[i]));
if (!IsValidParam(constructorArgs[i]!, paramType))
throw new ArgumentException("Cannot emit a CustomAttribute with argument of type " + constructorArgs[i]!.GetType() + ".");
throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, constructorArgs[i]!.GetType()));
}
}
i++;
Expand DownExpand Up@@ -403,7 +403,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
marshalCookie = decode_string(data, pos, out pos)!;
break;
default:
throw new Exception("Unknown MarshalAsAttribute field: " + named_name);
throw new Exception(SR.Format(SR.Exception_UnknownMarshalAsAttributeField, named_name));
}
}

Expand All@@ -420,7 +420,7 @@ internal static UnmanagedMarshal get_umarshal(CustomAttributeBuilder customBuild
#endif
case UnmanagedType.ByValArray:
if (!is_field)
throw new ArgumentException("Specified unmanaged type is only valid on fields");
throw new ArgumentException(SR.Argument_UnmanagedTypeOnlyValidOnFields);

return UnmanagedMarshal.DefineByValArray(sizeConst);
case UnmanagedType.ByValTStr:
Expand DownExpand Up@@ -451,7 +451,7 @@ private static Type elementTypeToType(int elementType) =>
0x0c => typeof(float),
0x0d => typeof(double),
0x0e => typeof(string),
_ => throw new Exception("Unknown element type '" + elementType + "'"),
_ => throw new Exception(SR.Format(SR.ArgumentException_InvalidTypeArgument, elementType)),
};

private static object? decode_cattr_value(Type t, byte[] data, int pos, out int rpos)
Expand DownExpand Up@@ -480,7 +480,7 @@ private static Type elementTypeToType(int elementType) =>
if (subtype >= 0x02 && subtype <= 0x0e)
return decode_cattr_value(elementTypeToType(subtype), data, pos, out rpos);
else
throw new Exception("Subtype '" + subtype + "' of type object not yet handled in decode_cattr_value");
throw new Exception(SR.Exception_UnhandledSubType);
default:
throw new Exception("FIXME: Type " + t + " not yet handled in decode_cattr_value.");
}
Expand DownExpand Up@@ -508,9 +508,9 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu

// Prolog
if (data.Length < 2)
throw new Exception("Custom attr length is only '" + data.Length + "'");
throw new Exception(SR.Format(SR.Exception_InvalidCustomAttributeLength, data.Length));
if ((data[0] != 0x1) || (data[1] != 0x00))
throw new Exception("Prolog invalid");
throw new Exception(SR.Exception_InvalidProlog);
pos = 2;

ParameterInfo[] pi = GetParameters(ctor);
Expand DownExpand Up@@ -547,7 +547,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
/* Field */
FieldInfo? fi = ctor.DeclaringType!.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (fi == null)
throw new Exception("Custom attribute type '" + ctor.DeclaringType + "' doesn't contain a field named '" + name + "'");
throw new Exception(SR.Format(SR.Exception_EmptyFieldForCustomAttributeType, ctor.DeclaringType, name));

object? val = decode_cattr_value(fi.FieldType, data, pos, out pos);
if (enum_type_name != null)
Expand All@@ -560,7 +560,7 @@ internal static CustomAttributeInfo decode_cattr(CustomAttributeBuilder customBu
}
else
// FIXME:
throw new Exception("Unknown named type: " + named_type);
throw new Exception(SR.Format(SR.Exception_UnknownNamedType, named_type));
}

return info;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ public ILGenerator GetILGenerator(int streamSize) =>
}
catch (MethodAccessException mae)
{
throw new TargetInvocationException("Method cannot be invoked.", mae);
throw new TargetInvocationException(SR.TargetInvocation_MethodCannotBeInvoked, mae);
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ public virtual void BeginCatchBlock(Type? exceptionType)
if (!InExceptionBlock)
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
if (exceptionType != null && exceptionType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
if (ex_handlers![cur_block].LastClauseType() == ILExceptionBlock.FILTER_START)
{
if (exceptionType != null)
Expand DownExpand Up@@ -446,7 +446,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
{
ArgumentNullException.ThrowIfNull(localType);
if (localType.IsUserType)
throw new NotSupportedException("User defined subclasses of System.Type are not yet supported.");
throw new NotSupportedException(SR.PlatformNotSupported_UserDefinedSubclassesOfType);
LocalBuilder res = new LocalBuilder(localType, this);
res.is_pinned = pinned;

Expand DownExpand Up@@ -797,7 +797,7 @@ public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[]? optio
{
if ((methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
{
throw new InvalidOperationException("Method is not VarArgs method and optional types were passed");
throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}

int token = token_gen.GetToken(methodInfo, optionalParameterTypes);
Expand DownExpand Up@@ -901,7 +901,7 @@ public virtual void ThrowException([DynamicallyAccessedMembers(DynamicallyAccess
throw new ArgumentException(SR.Argument_NotExceptionType, nameof(excType));
ConstructorInfo? ctor = excType.GetConstructor(Type.EmptyTypes);
if (ctor == null)
throw new ArgumentException(SR.Argument_MissingDefaultConstructor, nameof(excType));
throw new ArgumentException(SR.Arg_NoDefCTorWithoutTypeName, nameof(excType));
Emit(OpCodes.Newobj, ctor);
Emit(OpCodes.Throw);
}
Expand All@@ -917,7 +917,7 @@ internal void label_fixup(MethodBase mb)
for (int i = 0; i < num_fixups; ++i)
{
if (labels![fixups![i].label_idx].addr < 0)
throw new ArgumentException(string.Format("Label #{0} is not marked in method `{1}'", fixups[i].label_idx + 1, mb.Name));
throw new ArgumentException(SR.Format(SR.Argument_LabelUnmarked, fixups[i].label_idx + 1, mb.Name));
// Diff is the offset from the end of the jump instruction to the address of the label
int diff = labels[fixups[i].label_idx].addr - (fixups[i].pos + fixups[i].offset);
if (fixups[i].offset == 1)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,12 +93,12 @@ public override bool ContainsGenericParameters
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!_method.IsGenericMethodDefinition || (_typeArguments != null))
throw new InvalidOperationException("Method is not a generic method definition");
throw new InvalidOperationException(SR.Argument_NeedGenericMethodDefinition);

ArgumentNullException.ThrowIfNull(typeArgs);

if (_method.GetGenericArguments().Length != typeArgs.Length)
throw new ArgumentException("Incorrect length", nameof(typeArgs));
throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, _method.GetGenericArguments().Length, typeArgs.Length));

foreach (Type type in typeArgs)
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -234,8 +234,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
aname = (AssemblyName)n.Clone();

if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"Argument value {0} is not valid.", (int)access),
throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
SR.Arg_EnumIllegalVal, (int)access),
nameof(access));

name = n.Name;
Expand Down
Loading