Skip to content

Commit 3132deb

Browse files
authored
Use ArgumentNullException.ThrowIfNull in PresentationCore (#8126)
* CA1510 * manual changes
1 parent e3a120c commit 3132deb

File tree

279 files changed

+1602
-4250
lines changed

Some content is hidden

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

279 files changed

+1602
-4250
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ internal class InteropAutomationProvider: IRawElementProviderFragmentRoot
2020

2121
internal InteropAutomationProvider(HostedWindowWrapper wrapper, AutomationPeer parent)
2222
{
23-
if (wrapper == null)
24-
{
25-
throw new ArgumentNullException("wrapper");
26-
}
27-
if (parent == null)
28-
{
29-
throw new ArgumentNullException("parent");
30-
}
23+
ArgumentNullException.ThrowIfNull(wrapper);
24+
ArgumentNullException.ThrowIfNull(parent);
3125

3226
_wrapper = wrapper;
3327
_parent = parent;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,7 @@ public bool Contains(KeyValuePair<int, ushort> item)
727727

728728
public void CopyTo(KeyValuePair<int, ushort>[] array, int arrayIndex)
729729
{
730-
if (array == null)
731-
{
732-
throw new ArgumentNullException("array");
733-
}
730+
ArgumentNullException.ThrowIfNull(array);
734731

735732
if (array.Rank != 1)
736733
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ internal CompositeFontInfo()
5757
internal void PrepareToAddFamilyMap(FontFamilyMap familyMap)
5858
{
5959
// Validate parameters.
60-
if (familyMap == null)
61-
throw new ArgumentNullException("familyMap");
60+
ArgumentNullException.ThrowIfNull(familyMap);
6261

6362
if (string.IsNullOrEmpty(familyMap.Target))
6463
throw new ArgumentException(SR.FamilyMap_TargetNotSet);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public bool Contains(Typeface item)
6969

7070
public void CopyTo(Typeface[] array, int arrayIndex)
7171
{
72-
if (array == null)
73-
{
74-
throw new ArgumentNullException("array");
75-
}
72+
ArgumentNullException.ThrowIfNull(array);
7673

7774
if (array.Rank != 1)
7875
{

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ internal class ByteRangeDownloader : IDisposable
5656
internal ByteRangeDownloader(Uri requestedUri, string tempFileName, SafeWaitHandle eventHandle)
5757
: this(requestedUri, eventHandle)
5858
{
59-
if (tempFileName == null)
60-
{
61-
throw new ArgumentNullException("tempFileName");
62-
}
59+
ArgumentNullException.ThrowIfNull(tempFileName);
6360

6461
if (tempFileName.Length <= 0)
6562
{
@@ -186,10 +183,7 @@ internal void RequestByteRanges(int[,] byteRanges)
186183
// The worker thread will never call dispose nor this method; no need to lock
187184
CheckDisposed();
188185

189-
if (byteRanges == null)
190-
{
191-
throw new ArgumentNullException("byteRanges");
192-
}
186+
ArgumentNullException.ThrowIfNull(byteRanges);
193187

194188
CheckTwoDimensionalByteRanges(byteRanges);
195189

@@ -303,10 +297,7 @@ internal IWebProxy Proxy
303297
set
304298
{
305299
CheckDisposed();
306-
if (value == null)
307-
{
308-
throw new ArgumentNullException("value");
309-
}
300+
ArgumentNullException.ThrowIfNull(value);
310301

311302
if (!_firstRequestMade)
312303
{
@@ -411,21 +402,15 @@ private void CheckDisposed()
411402
/// </summary>
412403
private ByteRangeDownloader(Uri requestedUri, SafeWaitHandle eventHandle)
413404
{
414-
if (requestedUri == null)
415-
{
416-
throw new ArgumentNullException("requestedUri");
417-
}
405+
ArgumentNullException.ThrowIfNull(requestedUri);
418406

419407
// Ensure uri is correct scheme (http or https) Do case-sensitive comparison since Uri.Scheme contract is to return in lower case only.
420408
if (!string.Equals(requestedUri.Scheme, Uri.UriSchemeHttp, StringComparison.Ordinal) && !string.Equals(requestedUri.Scheme, Uri.UriSchemeHttps, StringComparison.Ordinal))
421409
{
422410
throw new ArgumentException(SR.InvalidScheme, "requestedUri");
423411
}
424412

425-
if (eventHandle == null)
426-
{
427-
throw new ArgumentNullException("eventHandle");
428-
}
413+
ArgumentNullException.ThrowIfNull(eventHandle);
429414

430415
if (eventHandle.IsInvalid || eventHandle.IsClosed)
431416
{

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ public override bool CanWrite
196196
/// <remarks>streamUri has to be a pack Uri</remarks>
197197
internal DeobfuscatingStream(Stream obfuscatedStream, Uri streamUri, bool leaveOpen)
198198
{
199-
if (obfuscatedStream == null)
200-
{
201-
throw new ArgumentNullException("obfuscatedStream");
202-
}
199+
ArgumentNullException.ThrowIfNull(obfuscatedStream);
203200

204201
// Make sure streamUri is in the correct form; getting partUri from it will do all necessary checks for error
205202
// conditions; We also have to make sure that it has a part name

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ internal static void Clear()
160160

161161
private static void ValidateUriKey(Uri uri)
162162
{
163-
if (uri == null)
164-
{
165-
throw new ArgumentNullException("uri");
166-
}
163+
ArgumentNullException.ThrowIfNull(uri);
167164

168165
if (!uri.IsAbsoluteUri)
169166
{

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ public override WebHeaderCollection Headers
201201
}
202202
set
203203
{
204-
if (value == null)
205-
throw new ArgumentNullException("value");
204+
ArgumentNullException.ThrowIfNull(value);
206205

207206
_headers = value;
208207
}
@@ -222,8 +221,7 @@ public override string Method
222221
}
223222
set
224223
{
225-
if (value == null)
226-
throw new ArgumentNullException("value");
224+
ArgumentNullException.ThrowIfNull(value);
227225

228226
_method = value;
229227
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ internal object Value
163163
}
164164
set
165165
{
166-
if (value == null)
167-
{
168-
throw new ArgumentNullException("value");
169-
}
166+
ArgumentNullException.ThrowIfNull(value);
170167

171168
// validate the type information for the id against the id
172169
ExtendedPropertySerializer.Validate(_id, value);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ internal object this[Guid attributeId]
247247
}
248248
set
249249
{
250-
if (value == null)
251-
{
252-
throw new ArgumentNullException("value");
253-
}
250+
ArgumentNullException.ThrowIfNull(value);
254251
for (int i = 0; i < _extendedProperties.Count; i++)
255252
{
256253
ExtendedProperty currentProperty = _extendedProperties[i];

0 commit comments

Comments
 (0)