From: Roman Marusyk Date: Wed, 13 Nov 2019 22:10:55 +0000 (+0100) Subject: Use Strings.resx file for the exception messages (dotnet/corefx#40402) X-Git-Tag: submit/tizen/20210909.063632~11031^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad3d37528d0f9557cb906ce113592a33420739eb;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Use Strings.resx file for the exception messages (dotnet/corefx#40402) * Use Strings.resx file for the exception messages within System.Windows.Extensions * Use Strings resx file for the exception messages within System.Threading * Use Strings resx file for the exception messages within System.Security.Cryptography.Xml * Use Strings resx file for the exception messages within System.Runtime.WindowsRuntime * Use Strings resx file for the exception messages within System.Reflection.Metadata * Use Strings resx file for the exception messages within System.Private.Xml * Use Strings resx file for the exception messages within System.Private.DataContractSerialization * Use Strings resx file for the exception messages within System.Numerics.Tensors * Use Strings resx file for the exception messages within System.IO.Packaging * Use Strings resx file for the exception messages within System.IO.FileSystem * Use Strings resx file for the exception messages within System.Drawing.Common * Use Strings resx file for the exception messages within System.DirectoryServices * Use Strings resx file for the exception messages within System.Diagnostics.DiagnosticSource * Use Strings resx file for the exception messages within System.Composition.Hosting * Update ExportDescriptorPromise.cs * Fix build Commit migrated from https://github.com/dotnet/corefx/commit/1518fdc5cc94571bf3ce1bb95e1a60f789a67f18 --- diff --git a/src/libraries/System.Composition.Hosting/src/Resources/Strings.resx b/src/libraries/System.Composition.Hosting/src/Resources/Strings.resx index 22472e6..3188760 100644 --- a/src/libraries/System.Composition.Hosting/src/Resources/Strings.resx +++ b/src/libraries/System.Composition.Hosting/src/Resources/Strings.resx @@ -130,4 +130,7 @@ Internal error occurred. Additional information: '{0}'. - + + The update has already executed. + + \ No newline at end of file diff --git a/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistryUpdate.cs b/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistryUpdate.cs index 143d48a..60d894c 100644 --- a/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistryUpdate.cs +++ b/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistryUpdate.cs @@ -32,7 +32,7 @@ namespace System.Composition.Hosting.Core { // Opportunism - we'll miss recursive calls to Execute(), but this will catch some problems // and the _updateFinished flag is required for other purposes anyway. - if (_updateFinished) throw new InvalidOperationException("The update has already executed."); + if (_updateFinished) throw new InvalidOperationException(SR.Update_already_executed); CompositionDependency initial; if (TryResolveOptionalDependency("initial request", contract, true, out initial)) diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/Resources/Strings.resx b/src/libraries/System.Diagnostics.DiagnosticSource/src/Resources/Strings.resx index d571e67..724068b 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/Resources/Strings.resx +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/Resources/Strings.resx @@ -120,6 +120,9 @@ "Value must be a valid ActivityIdFormat value" + + Trying to set an Activity that is not running + "Can not stop an Activity that was not started" diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs index 0bf74fc..8205556 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs @@ -854,7 +854,7 @@ namespace System.Diagnostics bool canSet = activity == null || (activity.Id != null && !activity.IsFinished); if (!canSet) { - NotifyError(new InvalidOperationException("Trying to set an Activity that is not running")); + NotifyError(new InvalidOperationException(SR.ActivityNotRunning)); } return canSet; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs index df3baeb..24d230c 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs @@ -122,7 +122,7 @@ namespace System.DirectoryServices.ActiveDirectory public void Insert(int index, ActiveDirectorySiteLink link) { if (link == null) - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(link)); if (!link.existing) throw new InvalidOperationException(SR.Format(SR.SiteLinkNotCommitted, link.Name)); diff --git a/src/libraries/System.Drawing.Common/src/Resources/Strings.resx b/src/libraries/System.Drawing.Common/src/Resources/Strings.resx index a8db37b..e5b4b7e 100644 --- a/src/libraries/System.Drawing.Common/src/Resources/Strings.resx +++ b/src/libraries/System.Drawing.Common/src/Resources/Strings.resx @@ -410,4 +410,49 @@ Unable to find an entry point named '{0}' in DLL '{1}'. - + + {0} only available on WMF files. + + + Cannot create Graphics from an indexed bitmap. + + + Could not open display (X-Server required. Check your DISPLAY environment variable) + + + Couldn't find specified file. + + + Icon instance was disposed. + + + Invalid GraphicsUnit + + + Invalid thumbnail size + + + No codec available for format:{0} + + + Operation not implemented under X11 + + + No valid icon image found + + + Null or empty path. + + + Invalid parameter passed. Number of points and types must be same. + + + Object has been disposed. + + + The value of the {0} property is less than zero. + + + The value of the {0} property is not one of the {1} values + + \ No newline at end of file diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs index 5413d28..5ece42d 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs @@ -78,7 +78,7 @@ namespace System.Drawing.Drawing2D if (pts == null) throw new ArgumentNullException(nameof(pts)); if (pts.Length != types.Length) - throw new ArgumentException("Invalid parameter passed. Number of points and types must be same."); + throw new ArgumentException(SR.NumberOfPointsAndTypesMustBeSame); int status = Gdip.GdipCreatePath2I(pts, types, pts.Length, fillMode, out _nativePath); Gdip.CheckStatus(status); @@ -89,7 +89,7 @@ namespace System.Drawing.Drawing2D if (pts == null) throw new ArgumentNullException(nameof(pts)); if (pts.Length != types.Length) - throw new ArgumentException("Invalid parameter passed. Number of points and types must be same."); + throw new ArgumentException(SR.NumberOfPointsAndTypesMustBeSame); int status = Gdip.GdipCreatePath2(pts, types, pts.Length, fillMode, out _nativePath); Gdip.CheckStatus(status); @@ -141,7 +141,7 @@ namespace System.Drawing.Drawing2D set { if ((value < FillMode.Alternate) || (value > FillMode.Winding)) - throw new InvalidEnumArgumentException("FillMode", (int)value, typeof(FillMode)); + throw new InvalidEnumArgumentException(nameof(FillMode), (int)value, typeof(FillMode)); int status = Gdip.GdipSetPathFillMode(_nativePath, value); Gdip.CheckStatus(status); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs index 399733b..94a5b00 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs @@ -96,7 +96,7 @@ namespace System.Drawing inchs = nSrc / 72f; break; default: - throw new ArgumentException("Invalid GraphicsUnit"); + throw new ArgumentException(SR.InvalidGraphicsUnit); } switch (toUnit) @@ -121,7 +121,7 @@ namespace System.Drawing nTrg = inchs * 72; break; default: - throw new ArgumentException("Invalid GraphicsUnit"); + throw new ArgumentException(SR.InvalidGraphicsUnit); } } @@ -211,7 +211,7 @@ namespace System.Drawing public IntPtr ToHfont() { if (_nativeFont == IntPtr.Zero) - throw new ArgumentException("Object has been disposed."); + throw new ArgumentException(SR.ObjectDisposed); return _nativeFont; } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs index 0fbaa90..45b7ffb 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs @@ -142,7 +142,7 @@ namespace System.Drawing int AllPlanes = ~0, nitems = 0, pixel; if (copyPixelOperation != CopyPixelOperation.SourceCopy) - throw new NotImplementedException("Operation not implemented under X11"); + throw new NotImplementedException(SR.NotImplementedUnderX11); if (Gdip.Display == IntPtr.Zero) { @@ -458,7 +458,7 @@ namespace System.Drawing { Gdip.Display = LibX11Functions.XOpenDisplay(IntPtr.Zero); if (Gdip.Display == IntPtr.Zero) - throw new NotSupportedException("Could not open display (X-Server required. Check your DISPLAY environment variable)"); + throw new NotSupportedException(SR.CouldNotOpenDisplay); } if (hwnd == IntPtr.Zero) { @@ -483,7 +483,7 @@ namespace System.Drawing throw new ArgumentNullException(nameof(image)); if ((image.PixelFormat & PixelFormat.Indexed) != 0) - throw new ArgumentException("Cannot create Graphics from an indexed bitmap.", nameof(image)); + throw new ArgumentException(SR.CannotCreateGraphics, nameof(image)); int status = Gdip.GdipGetImageGraphicsContext(image.nativeImage, out graphics); Gdip.CheckStatus(status); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Unix.cs index fee5856..2bf5642 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Unix.cs @@ -205,7 +205,7 @@ namespace System.Drawing } if (id == ushort.MaxValue) - throw new ArgumentException("Icon", "No valid icon image found"); + throw new ArgumentException(SR.NoValidIconImageFound, "Icon"); iconSize.Height = iconDir.idEntries[id].height; iconSize.Width = iconDir.idEntries[id].width; @@ -313,9 +313,9 @@ namespace System.Drawing if (filePath == null) throw new ArgumentNullException(nameof(filePath)); if (string.IsNullOrEmpty(filePath)) - throw new ArgumentException("Null or empty path.", "path"); + throw new ArgumentException(SR.NullOrEmptyPath, "path"); if (!File.Exists(filePath)) - throw new FileNotFoundException("Couldn't find specified file.", filePath); + throw new FileNotFoundException(SR.CouldntFindSpecifiedFile, filePath); return SystemIcons.WinLogo; } @@ -635,7 +635,7 @@ namespace System.Drawing public Bitmap ToBitmap() { if (disposed) - throw new ObjectDisposedException("Icon instance was disposed."); + throw new ObjectDisposedException(SR.IconInstanceWasDisposed); // note: we can't return the original image because // (a) we have no control over the bitmap instance we return (i.e. it could be disposed) diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs index 2d0b83e..21b6146 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs @@ -129,7 +129,7 @@ namespace System.Drawing public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData) { if ((thumbWidth <= 0) || (thumbHeight <= 0)) - throw new OutOfMemoryException("Invalid thumbnail size"); + throw new OutOfMemoryException(SR.InvalidThumbnailSize); Image ThumbNail = new Bitmap(thumbWidth, thumbHeight); @@ -224,7 +224,7 @@ namespace System.Drawing ImageCodecInfo encoder = FindEncoderForFormat(format); if (encoder == null) - throw new ArgumentException("No codec available for format:" + format.Guid); + throw new ArgumentException(SR.Format(SR.NoCodecAvailableForFormat, format.Guid)); Save(stream, encoder, null); } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.Unix.cs index d524a44..992dce5 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.Unix.cs @@ -211,7 +211,7 @@ namespace System.Drawing.Imaging { if (IsWmf()) return new MetaHeader(header.wmf_header); - throw new ArgumentException("WmfHeader only available on WMF files."); + throw new ArgumentException(SR.Format(SR.AvailableOnlyOnWMF, nameof(WmfHeader))); } } } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Unix.cs index 7b9ad29..134261c 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Unix.cs @@ -102,7 +102,7 @@ namespace System.Drawing.Printing set { if (value < 0) - throw new ArgumentException("The value of the Copies property is less than zero."); + throw new ArgumentException(SR.Format(SR.ValueLessThenZero, nameof(Copies))); copies = value; } @@ -139,7 +139,7 @@ namespace System.Drawing.Printing set { if (value < 0) - throw new ArgumentException("The value of the FromPage property is less than zero"); + throw new ArgumentException(SR.Format(SR.ValueLessThenZero, nameof(FromPage))); from_page = value; } @@ -182,7 +182,7 @@ namespace System.Drawing.Printing { // This not documented but behaves like MinimumPage if (value < 0) - throw new ArgumentException("The value of the MaximumPage property is less than zero"); + throw new ArgumentException(SR.Format(SR.ValueLessThenZero, nameof(MaximumPage))); maximum_page = value; } @@ -194,7 +194,7 @@ namespace System.Drawing.Printing set { if (value < 0) - throw new ArgumentException("The value of the MaximumPage property is less than zero"); + throw new ArgumentException(SR.Format(SR.ValueLessThenZero, nameof(MinimumPage))); minimum_page = value; } @@ -264,7 +264,7 @@ namespace System.Drawing.Printing { if (value != PrintRange.AllPages && value != PrintRange.Selection && value != PrintRange.SomePages) - throw new InvalidEnumArgumentException("The value of the PrintRange property is not one of the PrintRange values"); + throw new InvalidEnumArgumentException(SR.Format(SR.ValueNotOneOfValues, nameof(PrintRange), nameof(PrintRange))); print_range = value; } @@ -287,7 +287,7 @@ namespace System.Drawing.Printing set { if (value < 0) - throw new ArgumentException("The value of the ToPage property is less than zero"); + throw new ArgumentException(SR.Format(SR.ValueLessThenZero, nameof(ToPage))); to_page = value; } diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs b/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs index d9de6daa..8149ee8 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs @@ -36,8 +36,7 @@ namespace System.IO private void Init(string originalPath, string fullPath = null, string fileName = null, bool isNormalized = false) { - // Want to throw the original argument name - OriginalPath = originalPath ?? throw new ArgumentNullException("path"); + OriginalPath = originalPath ?? throw new ArgumentNullException(nameof(originalPath)); fullPath = fullPath ?? originalPath; fullPath = isNormalized ? fullPath : Path.GetFullPath(fullPath); diff --git a/src/libraries/System.IO.Packaging/src/Resources/Strings.resx b/src/libraries/System.IO.Packaging/src/Resources/Strings.resx index bb4887d..6680945 100644 --- a/src/libraries/System.IO.Packaging/src/Resources/Strings.resx +++ b/src/libraries/System.IO.Packaging/src/Resources/Strings.resx @@ -372,4 +372,7 @@ Must have absolute URI. - + + File contains corrupted data. + + \ No newline at end of file diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs index 9acbdd3..f044bf7 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs @@ -353,7 +353,7 @@ namespace System.IO.Packaging } catch (InvalidDataException) { - throw new FileFormatException("File contains corrupted data."); + throw new FileFormatException(SR.FileContainsCorruptedData); } catch { diff --git a/src/libraries/System.Numerics.Tensors/src/Resources/Strings.resx b/src/libraries/System.Numerics.Tensors/src/Resources/Strings.resx new file mode 100644 index 0000000..57f792d --- /dev/null +++ b/src/libraries/System.Numerics.Tensors/src/Resources/Strings.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Array must contain elements. + + + Cannot compare {0} to {1}. + + + Cannot compare {0} to {1} with different dimension {2}, {3} != {4}. + + + Cannot compare {0} with different dimension {1}, {2} != {3}. + + + Cannot compare {0} with Rank {1} to {2} with Rank {3}. + + + Cannot compute diagonal of {0} with Rank less than 2. + + + Cannot compute diagonal with offset {0}. + + + Tensor {0} must have at least one dimension. + + + Cannot compute triangle of {0} with Rank less than 2. + + + Cannot reshape array due to mismatch in lengths, currently {0} would become {1}. + + + Dimensions must be positive and non-zero. + + + Dimensions must contain elements. + + + Length of {0} ({1}) must match product of {2} ({3}). + + + The number of elements in the Tensor is greater than the available space from index to the end of the destination array. + + + Only single dimensional arrays are supported for the requested action. + + + The value "{0}" is not of type "{1}" and cannot be used in this generic collection. + + \ No newline at end of file diff --git a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj index 6a9856a..af8a3d2 100644 --- a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj +++ b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj @@ -21,6 +21,7 @@ + diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/DenseTensor.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/DenseTensor.cs index 2213e46..9af5707 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/DenseTensor.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/DenseTensor.cs @@ -72,7 +72,7 @@ namespace System.Numerics.Tensors if (Length != memory.Length) { - throw new ArgumentException($"Length of {nameof(memory)} ({memory.Length}) must match product of {nameof(dimensions)} ({Length})."); + throw new ArgumentException(SR.Format(SR.LengthMustMatch, nameof(memory), memory.Length, nameof(dimensions), Length)); } } @@ -109,7 +109,7 @@ namespace System.Numerics.Tensors } if (array.Length < arrayIndex + Length) { - throw new ArgumentException("The number of elements in the Tensor is greater than the available space from index to the end of the destination array.", nameof(array)); + throw new ArgumentException(SR.NumberGreaterThenAvailableSpace, nameof(array)); } Buffer.Span.CopyTo(array.AsSpan(arrayIndex)); @@ -162,14 +162,14 @@ namespace System.Numerics.Tensors { if (dimensions.Length == 0) { - throw new ArgumentException("Dimensions must contain elements.", nameof(dimensions)); + throw new ArgumentException(SR.DimensionsMustContainElements, nameof(dimensions)); } var newSize = ArrayUtilities.GetProduct(dimensions); if (newSize != Length) { - throw new ArgumentException($"Cannot reshape array due to mismatch in lengths, currently {Length} would become {newSize}.", nameof(dimensions)); + throw new ArgumentException(SR.Format(SR.CannotReshapeArrayDueToMismatchInLengths, Length, newSize), nameof(dimensions)); } return new DenseTensor(Buffer, dimensions, IsReversedStride); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/Tensor.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/Tensor.cs index d29475d..50296fa 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/Tensor.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/Tensor.cs @@ -82,7 +82,7 @@ namespace System.Numerics.Tensors { if (diagonal.Rank < 1) { - throw new ArgumentException($"Tensor {nameof(diagonal)} must have at least one dimension.", nameof(diagonal)); + throw new ArgumentException(SR.Format(SR.MustHaveAtLeastOneDimension, nameof(diagonal)), nameof(diagonal)); } int diagonalLength = diagonal.dimensions[0]; @@ -283,7 +283,7 @@ namespace System.Numerics.Tensors { if (dimensions.Length == 0) { - throw new ArgumentException("Dimensions must contain elements.", nameof(dimensions)); + throw new ArgumentException(SR.DimensionsMustContainElements, nameof(dimensions)); } this.dimensions = new int[dimensions.Length]; @@ -292,7 +292,7 @@ namespace System.Numerics.Tensors { if (dimensions[i] < 1) { - throw new ArgumentOutOfRangeException(nameof(dimensions), "Dimensions must be positive and non-zero"); + throw new ArgumentOutOfRangeException(nameof(dimensions), SR.DimensionsMustBePositiveAndNonZero); } this.dimensions[i] = dimensions[i]; size *= dimensions[i]; @@ -318,7 +318,7 @@ namespace System.Numerics.Tensors if (fromArray.Rank == 0) { - throw new ArgumentException("Array must contain elements.", nameof(fromArray)); + throw new ArgumentException(SR.ArrayMustContainElements, nameof(fromArray)); } dimensions = new int[fromArray.Rank]; @@ -443,7 +443,7 @@ namespace System.Numerics.Tensors if (Rank < 2) { - throw new InvalidOperationException($"Cannot compute diagonal of {nameof(Tensor)} with Rank less than 2."); + throw new InvalidOperationException(SR.Format(SR.CannotComputeDiagonal, nameof(Tensor))); } // TODO: allow specification of axis1 and axis2? @@ -470,7 +470,7 @@ namespace System.Numerics.Tensors if (diagonalLength <= 0) { - throw new ArgumentException($"Cannot compute diagonal with offset {offset}", nameof(offset)); + throw new ArgumentException(SR.Format(SR.CannotComputeDiagonalWithOffset, offset), nameof(offset)); } var newTensorRank = Rank - 1; @@ -548,7 +548,7 @@ namespace System.Numerics.Tensors { if (Rank < 2) { - throw new InvalidOperationException($"Cannot compute triangle of {nameof(Tensor)} with Rank less than 2."); + throw new InvalidOperationException(SR.Format(SR.CannotComputeTriangle, nameof(Tensor))); } // Similar to get diagonal except it gets every element below and including the diagonal. @@ -745,11 +745,11 @@ namespace System.Numerics.Tensors } if (array.Rank != 1) { - throw new ArgumentException("Only single dimensional arrays are supported for the requested action.", nameof(array)); + throw new ArgumentException(SR.OnlySingleDimensionalArraysSupported, nameof(array)); } if (array.Length < index + Length) { - throw new ArgumentException("The number of elements in the Tensor is greater than the available space from index to the end of the destination array.", nameof(array)); + throw new ArgumentException(SR.NumberGreaterThenAvailableSpace, nameof(array)); } for (int i = 0; i < length; i++) @@ -775,7 +775,7 @@ namespace System.Numerics.Tensors } catch (InvalidCastException) { - throw new ArgumentException($"The value \"{value}\" is not of type \"{typeof(T)}\" and cannot be used in this generic collection."); + throw new ArgumentException(SR.Format(SR.ValueIsNotOfType, value, typeof(T))); } } } @@ -892,7 +892,7 @@ namespace System.Numerics.Tensors } if (array.Length < arrayIndex + Length) { - throw new ArgumentException("The number of elements in the Tensor is greater than the available space from index to the end of the destination array.", nameof(array)); + throw new ArgumentException(SR.NumberGreaterThenAvailableSpace, nameof(array)); } for (int i = 0; i < length; i++) @@ -980,21 +980,21 @@ namespace System.Numerics.Tensors return CompareTo(otherArray, comparer); } - throw new ArgumentException($"Cannot compare {nameof(Tensor)} to {other.GetType()}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompare, nameof(Tensor), other.GetType()), nameof(other)); } private int CompareTo(Tensor other, IComparer comparer) { if (Rank != other.Rank) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} with Rank {Rank} to {nameof(other)} with Rank {other.Rank}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithRank, nameof(Tensor), Rank, nameof(other), other.Rank), nameof(other)); } for (int i = 0; i < dimensions.Length; i++) { if (dimensions[i] != other.dimensions[i]) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)}s with differning dimension {i}, {dimensions[i]} != {other.dimensions[i]}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithDifferentDimension, nameof(Tensor), i, dimensions[i], other.dimensions[i]), nameof(other)); } } @@ -1032,7 +1032,7 @@ namespace System.Numerics.Tensors { if (Rank != other.Rank) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} with Rank {Rank} to {nameof(Array)} with rank {other.Rank}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithRank, nameof(Tensor), Rank, nameof(Array), other.Rank), nameof(other)); } for (int i = 0; i < dimensions.Length; i++) @@ -1040,7 +1040,7 @@ namespace System.Numerics.Tensors var otherDimension = other.GetLength(i); if (dimensions[i] != otherDimension) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} to {nameof(Array)} with differning dimension {i}, {dimensions[i]} != {otherDimension}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareToWithDifferentDimension, nameof(Tensor), nameof(Array), i, dimensions[i], otherDimension), nameof(other)); } } @@ -1082,21 +1082,21 @@ namespace System.Numerics.Tensors return Equals(otherArray, comparer); } - throw new ArgumentException($"Cannot compare {nameof(Tensor)} to {other.GetType()}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompare, nameof(Tensor), other.GetType()), nameof(other)); } private bool Equals(Tensor other, IEqualityComparer comparer) { if (Rank != other.Rank) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} with Rank {Rank} to {nameof(other)} with Rank {other.Rank}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithRank, nameof(Tensor), Rank, nameof(other), other.Rank), nameof(other)); } for (int i = 0; i < dimensions.Length; i++) { if (dimensions[i] != other.dimensions[i]) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)}s with differning dimension {i}, {dimensions[i]} != {other.dimensions[i]}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithDifferentDimension, nameof(Tensor), i, dimensions[i], other.dimensions[i]), nameof(other)); } } @@ -1131,7 +1131,7 @@ namespace System.Numerics.Tensors { if (Rank != other.Rank) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} with Rank {Rank} to {nameof(Array)} with rank {other.Rank}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareWithRank, nameof(Tensor), Rank, nameof(Array), other.Rank), nameof(other)); } for (int i = 0; i < dimensions.Length; i++) @@ -1139,7 +1139,7 @@ namespace System.Numerics.Tensors var otherDimension = other.GetLength(i); if (dimensions[i] != otherDimension) { - throw new ArgumentException($"Cannot compare {nameof(Tensor)} to {nameof(Array)} with differning dimension {i}, {dimensions[i]} != {otherDimension}.", nameof(other)); + throw new ArgumentException(SR.Format(SR.CannotCompareToWithDifferentDimension, nameof(Tensor), nameof(Array), i, dimensions[i], otherDimension), nameof(other)); } } diff --git a/src/libraries/System.Private.DataContractSerialization/src/Resources/Strings.resx b/src/libraries/System.Private.DataContractSerialization/src/Resources/Strings.resx index bbd28b3..d8f0cd3 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/Resources/Strings.resx +++ b/src/libraries/System.Private.DataContractSerialization/src/Resources/Strings.resx @@ -1110,7 +1110,7 @@ IExtensibleDataObject property setter '{1}' in type '{0}' must have a single parameter of type '{2}'. - Type '{0}' does not have DataContractAttribute attribute and therefore cannot support IExtensibleDataObject. + Type '{0}' does not have DataContractAttribute attribute and therefore cannot support IExtensibleDataObject. JsonObjectDataContract.ParseJsonNumber shouldn't return a TypeCode that we're not expecting. @@ -1157,4 +1157,10 @@ Failed to create Delegate for method '{0}' of type '{1}'. - + + Cannot set option twice. + + + '{0}' must be greater than 0. + + \ No newline at end of file diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs index b197175..4e70572 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs @@ -43,7 +43,7 @@ namespace System.Runtime.Serialization { if (_optionAlreadySet) { - throw new InvalidOperationException("Can only set once"); + throw new InvalidOperationException(SR.CannotSetTwice); } _optionAlreadySet = true; _option = value; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs index cb22af6..d960d45 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs @@ -218,7 +218,7 @@ namespace System.Runtime.Serialization.Json if (keyTypeNullableDepth > 0) { - throw new NotImplementedException("keyTypeNullableDepth > 0"); + throw new NotImplementedException(SR.Format(SR.MustBeGreaterThanZero, keyTypeNullableDepth)); } object pairValue = ReflectionReadValue(xmlReader, context, valueType, string.Empty, string.Empty); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs index 434188c..09f9f82 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs @@ -1656,11 +1656,11 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Boolean", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Boolean), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Boolean", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Boolean), exception)); } } @@ -1677,15 +1677,15 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Decimal), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Decimal), exception)); } catch (OverflowException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Decimal", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Decimal), exception)); } } @@ -1697,15 +1697,15 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Double), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Double), exception)); } catch (OverflowException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Double", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Double), exception)); } } @@ -1717,15 +1717,15 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int32), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int32), exception)); } catch (OverflowException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int32", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int32), exception)); } } @@ -1737,15 +1737,15 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int64), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int64), exception)); } catch (OverflowException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Int64", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Int64), exception)); } } @@ -1757,15 +1757,15 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Single), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Single), exception)); } catch (OverflowException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("Single", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(Single), exception)); } } @@ -1777,11 +1777,11 @@ namespace System.Xml } catch (ArgumentException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("String", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(String), exception)); } catch (FormatException exception) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException("String", exception)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(nameof(String), exception)); } } diff --git a/src/libraries/System.Private.Xml/src/Resources/Strings.resx b/src/libraries/System.Private.Xml/src/Resources/Strings.resx index 944e6f8..ca4b85c 100644 --- a/src/libraries/System.Private.Xml/src/Resources/Strings.resx +++ b/src/libraries/System.Private.Xml/src/Resources/Strings.resx @@ -3449,4 +3449,7 @@ Usage: dotnet {0} [--assembly <assembly file path>] [--type <type name& Pre-generated serializer '{0}' has expired. You need to re-generate serializer for '{1}' - + + Compiling JScript/CSharp scripts is not supported + + \ No newline at end of file diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs index 4668df6..696e43e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs @@ -80,7 +80,7 @@ namespace System.Xml.Serialization if (fallbackToCSharpAssemblyGeneration) { - throw new PlatformNotSupportedException("Compiling JScript/CSharp scripts is not supported"); + throw new PlatformNotSupportedException(SR.CompilingScriptsNotSupported); } #if DEBUG diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs index 1dccb7a..41ea497 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs @@ -1315,7 +1315,7 @@ namespace System.Xml.Xsl.Xslt return; } - throw new PlatformNotSupportedException("Compiling JScript/CSharp scripts is not supported"); // Not adding any scripts as script compilation is not available + throw new PlatformNotSupportedException(SR.CompilingScriptsNotSupported); // Not adding any scripts as script compilation is not available } private readonly XsltAttribute[] _assemblyAttributes = { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs index ac29a39..224e48f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs @@ -773,7 +773,7 @@ namespace System.Xml.Xsl.XsltOld Hashtable typeDecls = _typeDeclsByLang[(int)langTmp]; if (lang == langTmp) { - throw new PlatformNotSupportedException("Compiling JScript/CSharp scripts is not supported"); + throw new PlatformNotSupportedException(SR.CompilingScriptsNotSupported); } else if (typeDecls.Contains(ns)) { diff --git a/src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx b/src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx index 2ae9612..437a702 100644 --- a/src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx +++ b/src/libraries/System.Reflection.Metadata/src/Resources/Strings.resx @@ -399,4 +399,13 @@ Invalid exception region bounds: start offset ({0}) is greater than end offset ({1}). - + + Unexpected value '{0}' of type '{1}' + + + Unexpected value '{0}' of unknown type. + + + This program location is thought to be unreachable. + + \ No newline at end of file diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ExceptionUtilities.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ExceptionUtilities.cs index 9e08f4f..e07dce1 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ExceptionUtilities.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ExceptionUtilities.cs @@ -6,10 +6,17 @@ namespace System.Reflection.Internal { internal static class ExceptionUtilities { - internal static Exception UnexpectedValue(object value) => - new InvalidOperationException($"Unexpected value '{value}' of type '{value?.GetType().FullName ?? ""}'"); + internal static Exception UnexpectedValue(object value) + { + if (value?.GetType().FullName != null) + { + return new InvalidOperationException(SR.Format(SR.UnexpectedValue, value, value.GetType().FullName)); + } + + return new InvalidOperationException(SR.Format(SR.UnexpectedValueUnknownType, value)); + } internal static Exception Unreachable => - new InvalidOperationException("This program location is thought to be unreachable."); + new InvalidOperationException(SR.UnreachableLocation); } } diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/Resources/Strings.resx b/src/libraries/System.Runtime.WindowsRuntime/src/Resources/Strings.resx index 719c7b7..806231d 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/Resources/Strings.resx +++ b/src/libraries/System.Runtime.WindowsRuntime/src/Resources/Strings.resx @@ -338,4 +338,7 @@ Windows Runtime (WinRT) is not supported on this platform. - + + Invalid action value: '{0}'. + + \ No newline at end of file diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/StreamOperationAsyncResult.cs b/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/StreamOperationAsyncResult.cs index 2eda976..8a58356 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/StreamOperationAsyncResult.cs +++ b/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/StreamOperationAsyncResult.cs @@ -40,7 +40,7 @@ namespace System.IO bool processCompletedOperationInCallback) { if (asyncStreamOperation == null) - throw new ArgumentNullException("asyncReadOperation"); + throw new ArgumentNullException(nameof(asyncStreamOperation)); _userCompletionCallback = userCompletionCallback; _userAsyncStateInfo = userAsyncStateInfo; diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/WinRtToNetFxStreamAdapter.cs b/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/WinRtToNetFxStreamAdapter.cs index 796e65d..d7d5fe8 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/WinRtToNetFxStreamAdapter.cs +++ b/src/libraries/System.Runtime.WindowsRuntime/src/System/IO/WinRtToNetFxStreamAdapter.cs @@ -283,7 +283,7 @@ namespace System.IO set { if (value < 0) - throw new ArgumentOutOfRangeException("Position", SR.ArgumentOutOfRange_IO_CannotSeekToNegativePosition); + throw new ArgumentOutOfRangeException(nameof(Position), SR.ArgumentOutOfRange_IO_CannotSeekToNegativePosition); IRandomAccessStream wrtStr = EnsureNotDisposed(); diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs b/src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs index e83682e..484bd84 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs +++ b/src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs @@ -160,7 +160,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime NotifyCollectionChangedAction.Replace => new NotifyCollectionChangedEventArgs(action, newItems, oldItems, newStartingIndex), NotifyCollectionChangedAction.Move => new NotifyCollectionChangedEventArgs(action, newItems, newStartingIndex, oldStartingIndex), NotifyCollectionChangedAction.Reset => new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset), - _ => throw new ArgumentException("Invalid action value: " + action), + _ => throw new ArgumentException(SR.Format(SR.InvalidAction, action)), }; } diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index 82a2a15..baa955a 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -938,7 +938,7 @@ namespace System.Threading { if (_disposed) { - throw new ObjectDisposedException("Barrier", SR.Barrier_Dispose); + throw new ObjectDisposedException(nameof(Barrier), SR.Barrier_Dispose); } } } diff --git a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs index 813306c..f0cd912 100644 --- a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs +++ b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs @@ -570,7 +570,7 @@ namespace System.Threading { if (_disposed) { - throw new ObjectDisposedException("CountdownEvent"); + throw new ObjectDisposedException(nameof(CountdownEvent)); } } } diff --git a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs index 4123850..69d474b 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs @@ -72,7 +72,7 @@ namespace System.Media { if (value < 0) { - throw new ArgumentOutOfRangeException("LoadTimeout", value, SR.SoundAPILoadTimeout); + throw new ArgumentOutOfRangeException(nameof(LoadTimeout), value, SR.SoundAPILoadTimeout); } _loadTimeout = value;