Skip to content

Commit fcab981

Browse files
Fixing CA1507 (#10186)
1 parent 36e6e74 commit fcab981

File tree

355 files changed

+1086
-1089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

355 files changed

+1086
-1089
lines changed

src/Microsoft.DotNet.Wpf/src/.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ dotnet_diagnostic.CA1310.severity = suggestion
4444
# CA1419: Provide a parameterless constructor that is as visible as the containing type for concrete types derived from 'System.Runtime.InteropServices.SafeHandle'
4545
dotnet_diagnostic.CA1419.severity = suggestion
4646

47-
# CA1507: Use nameof in place of string
48-
dotnet_diagnostic.CA1507.severity = suggestion
49-
5047
# CA1510: Use ArgumentNullException throw helper
5148
dotnet_diagnostic.CA1510.severity = suggestion
5249

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/EventMap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -108,7 +108,7 @@ private static AutomationEvent GetRegisteredEventObjectHelper(AutomationEvents e
108108
case AutomationEvents.ActiveTextPositionChanged: eventObject = AutomationElementIdentifiers.ActiveTextPositionChangedEvent; break;
109109

110110
default:
111-
throw new ArgumentException(SR.Automation_InvalidEventId, "eventId");
111+
throw new ArgumentException(SR.Automation_InvalidEventId, nameof(eventId));
112112
}
113113

114114
if ((eventObject != null) && (!_eventsTable.ContainsKey(eventObject.Id)))

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ internal static void SplitFontFaceIndex(Uri fontUri, out Uri fontSourceUri, out
493493
out faceIndex
494494
))
495495
{
496-
throw new ArgumentException(SR.FaceIndexMustBePositiveOrZero, "fontUri");
496+
throw new ArgumentException(SR.FaceIndexMustBePositiveOrZero, nameof(fontUri));
497497
}
498498

499499
// face index was specified in a fragment, we need to strip off fragment from the source Uri

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -305,7 +305,7 @@ internal double Baseline
305305
get { return _baseline; }
306306
set
307307
{
308-
CompositeFontParser.VerifyNonNegativeMultiplierOfEm("Baseline", ref value);
308+
CompositeFontParser.VerifyNonNegativeMultiplierOfEm(nameof(Baseline), ref value);
309309
_baseline = value;
310310
}
311311
}
@@ -319,7 +319,7 @@ internal double LineSpacing
319319
get { return _lineSpacing; }
320320
set
321321
{
322-
CompositeFontParser.VerifyPositiveMultiplierOfEm("LineSpacing", ref value);
322+
CompositeFontParser.VerifyPositiveMultiplierOfEm(nameof(LineSpacing), ref value);
323323
_lineSpacing = value;
324324
}
325325
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/FontDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ internal void SetFace(int faceIndex)
156156
else
157157
{
158158
if (faceIndex != 0)
159-
throw new ArgumentOutOfRangeException("faceIndex", SR.FaceIndexValidOnlyForTTC);
159+
throw new ArgumentOutOfRangeException(nameof(faceIndex), SR.FaceIndexValidOnlyForTTC);
160160
}
161161

162162
try

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IListConverters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -53,7 +53,7 @@ public override object ConvertFrom(ITypeDescriptorContext td, CultureInfo ci, ob
5353

5454
if (null == s)
5555
{
56-
throw new ArgumentException(SR.Format(SR.General_BadType, "ConvertFrom"), "value");
56+
throw new ArgumentException(SR.Format(SR.General_BadType, "ConvertFrom"), nameof(value));
5757
}
5858

5959
return ConvertFromCore(td, ci, s);

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal ByteRangeDownloader(Uri requestedUri, string tempFileName, SafeWaitHand
5555

5656
if (tempFileName.Length <= 0)
5757
{
58-
throw new ArgumentException(SR.InvalidTempFileName, "tempFileName");
58+
throw new ArgumentException(SR.InvalidTempFileName, nameof(tempFileName));
5959
}
6060

6161
_tempFileStream = File.Open(tempFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
@@ -402,14 +402,14 @@ private ByteRangeDownloader(Uri requestedUri, SafeWaitHandle eventHandle)
402402
// Ensure uri is correct scheme (http or https) Do case-sensitive comparison since Uri.Scheme contract is to return in lower case only.
403403
if (!string.Equals(requestedUri.Scheme, Uri.UriSchemeHttp, StringComparison.Ordinal) && !string.Equals(requestedUri.Scheme, Uri.UriSchemeHttps, StringComparison.Ordinal))
404404
{
405-
throw new ArgumentException(SR.InvalidScheme, "requestedUri");
405+
throw new ArgumentException(SR.InvalidScheme, nameof(requestedUri));
406406
}
407407

408408
ArgumentNullException.ThrowIfNull(eventHandle);
409409

410410
if (eventHandle.IsInvalid || eventHandle.IsClosed)
411411
{
412-
throw new ArgumentException(SR.InvalidEventHandle, "eventHandle");
412+
throw new ArgumentException(SR.InvalidEventHandle, nameof(eventHandle));
413413
}
414414

415415
_requestedUri = requestedUri;

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/NetStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public override int Read(byte[] buffer, int offset, int count)
139139
checked
140140
{
141141
if (offset + count > buffer.Length)
142-
throw new ArgumentException(SR.IOBufferOverflow, "buffer");
142+
throw new ArgumentException(SR.IOBufferOverflow, nameof(buffer));
143143

144144
// make sure some data is in the stream - block until it is
145145
int bytesAvailable = GetData(new Block(_position, count));
@@ -248,7 +248,7 @@ public override long Seek(long offset, SeekOrigin origin)
248248

249249
default:
250250
{
251-
throw new ArgumentOutOfRangeException("origin", SR.SeekOriginInvalid);
251+
throw new ArgumentOutOfRangeException(nameof(origin), SR.SeekOriginInvalid);
252252
}
253253
}
254254
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/PreloadedPackages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private static void ValidateUriKey(Uri uri)
152152

153153
if (!uri.IsAbsoluteUri)
154154
{
155-
throw new ArgumentException(SR.UriMustBeAbsolute, "uri");
155+
throw new ArgumentException(SR.UriMustBeAbsolute, nameof(uri));
156156
}
157157
}
158158

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedPropertyCollection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -148,7 +148,7 @@ internal void Add(Guid id, object value)
148148
{
149149
if (this.Contains(id))
150150
{
151-
throw new ArgumentException(SR.EPExists, "id");
151+
throw new ArgumentException(SR.EPExists, nameof(id));
152152
}
153153

154154
ExtendedProperty extendedProperty = new ExtendedProperty(id, value);
@@ -166,7 +166,7 @@ internal void Remove(Guid id)
166166
{
167167
if (!Contains(id))
168168
{
169-
throw new ArgumentException(SR.EPGuidNotFound, "id");
169+
throw new ArgumentException(SR.EPGuidNotFound, nameof(id));
170170
}
171171

172172
ExtendedProperty propertyToRemove = GetExtendedPropertyById(id);
@@ -226,7 +226,7 @@ internal object this[Guid attributeId]
226226
ExtendedProperty ep = GetExtendedPropertyById(attributeId);
227227
if (ep == null)
228228
{
229-
throw new ArgumentException(SR.EPNotFound, "attributeId");
229+
throw new ArgumentException(SR.EPNotFound, nameof(attributeId));
230230
}
231231
return ep.Value;
232232
}

0 commit comments

Comments
 (0)