-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Turn on argument exception analyzer on runtime, fix warnings found #38578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
900e3ab
ec7228b
d2bd508
61c8827
21c3cf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,7 +205,7 @@ public Icon(Icon original, Size size) | |
| } | ||
|
|
||
| if (id == ushort.MaxValue) | ||
| throw new ArgumentException(SR.NoValidIconImageFound, "Icon"); | ||
| throw new ArgumentException(SR.NoValidIconImageFound, nameof(original)); | ||
|
|
||
| iconSize.Height = iconDir.idEntries[id].height; | ||
| iconSize.Width = iconDir.idEntries[id].width; | ||
|
|
@@ -240,7 +240,7 @@ public Icon(string fileName) | |
| public Icon(Type type, string resource) | ||
| { | ||
| if (resource == null) | ||
| throw new ArgumentException(nameof(resource)); | ||
| throw new ArgumentNullException(nameof(resource)); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This kind of pattern happening for most of the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absent other data, it sounds like we should change the Windows implementation to throw the appropriate ArgumentNullException. |
||
|
|
||
| // For compatibility with the .NET Framework | ||
| if (type == null) | ||
|
|
@@ -313,7 +313,7 @@ public static Icon ExtractAssociatedIcon(string filePath) | |
| if (filePath == null) | ||
| throw new ArgumentNullException(nameof(filePath)); | ||
| if (string.IsNullOrEmpty(filePath)) | ||
| throw new ArgumentException(SR.NullOrEmptyPath, "path"); | ||
| throw new ArgumentException(SR.NullOrEmptyPath, nameof(filePath)); | ||
| if (!File.Exists(filePath)) | ||
| throw new FileNotFoundException(SR.CouldntFindSpecifiedFile, filePath); | ||
|
|
||
|
|
@@ -346,7 +346,7 @@ public object Clone() | |
| public static Icon FromHandle(IntPtr handle) | ||
| { | ||
| if (handle == IntPtr.Zero) | ||
| throw new ArgumentException(nameof(handle)); | ||
| throw new ArgumentException(null, nameof(handle)); | ||
|
|
||
| return new Icon(handle); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, we're happy with these argument exception names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combination of arguments found 2-3 times in previous PR, and we have suppressed it. I would say we are OK with it instead of happy 😄. We could change the analyzer to not warn in this case but not sure the amount of work for calculating that worth for this
rarecase scenario