-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Warn on message formatting failure instead of crash, and fix Native AOT MakeGenericType failure #110330
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
Warn on message formatting failure instead of crash, and fix Native AOT MakeGenericType failure #110330
Changes from 3 commits
ae67ab6
4aeb116
c883da8
825344e
18c20b8
999fc82
eae0efd
1aaac68
826c7ee
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 |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| // This is needed due to NativeAOT which doesn't enable nullable globally yet | ||
| #nullable enable | ||
|
|
||
| using System; | ||
|
|
||
| namespace ILLink.Shared | ||
| { | ||
| internal static class MessageFormat | ||
|
|
@@ -33,7 +35,24 @@ public static string FormatRequiresAttributeMismatch (bool memberHasAttribute, b | |
| (true, false) => SharedStrings.DerivedRequiresMismatchMessage | ||
| }; | ||
|
|
||
| return string.Format (format, args); | ||
| return TryFormat (format, args); | ||
| } | ||
|
|
||
| public static string TryFormat (string format, params object[] args) | ||
| { | ||
| string formattedString; | ||
| try | ||
| { | ||
| formattedString = string.Format(format, args); | ||
| } | ||
| catch (FormatException) | ||
| { | ||
| #pragma warning disable RS1035 // Do not use APIs banned for analyzers - We just need a newline | ||
| formattedString = "Internal error formatting diagnostic. Please report the issue at https://aka.ms/report-illink" + Environment.NewLine | ||
| + $"'{format}', " + $"[{string.Join(", ", args)}]"; | ||
| #pragma warning restore RS1035 // Do not use APIs banned for analyzers | ||
| } | ||
| return formattedString; | ||
|
||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.