Skip to content

Append dot to warning messages conditionally #701

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

Merged
merged 2 commits into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1707,8 +1707,13 @@ methodParams[argsParam] is ArrayValue arrayValue &&
if (shouldEnableReflectionWarnings &&
calledMethod.HasCustomAttribute("System.Diagnostics.CodeAnalysis", "RequiresUnreferencedCodeAttribute"))
{
string attributeMessage = DiagnosticUtilities.GetRequiresUnreferencedCodeAttributeMessage(calledMethod);

if (attributeMessage.Length > 0 && !attributeMessage.EndsWith('.'))
attributeMessage += '.';

string message =
$"Calling '{calledMethod.GetDisplayName()}' which has `RequiresUnreferencedCodeAttribute` can break functionality when trimming application code. {DiagnosticUtilities.GetRequiresUnreferencedCodeAttributeMessage(calledMethod)}.";
$"Calling '{calledMethod.GetDisplayName()}' which has `RequiresUnreferencedCodeAttribute` can break functionality when trimming application code. {attributeMessage}";

//if (requiresUnreferencedCode.Url != null)
//{
Expand All @@ -1728,7 +1733,12 @@ methodParams[argsParam] is ArrayValue arrayValue &&

static void LogDynamicCodeWarning(Logger logger, MethodIL callingMethodBody, int offset, MethodDesc calledMethod)
{
string message = $"{String.Format(Resources.Strings.IL9700, calledMethod.GetDisplayName())} {DiagnosticUtilities.GetRequiresDynamicCodeAttributeMessage(calledMethod)}.";
string attributeMessage = DiagnosticUtilities.GetRequiresDynamicCodeAttributeMessage(calledMethod);

if (attributeMessage.Length > 0 && !attributeMessage.EndsWith('.'))
attributeMessage += '.';

string message = $"{String.Format(Resources.Strings.IL9700, calledMethod.GetDisplayName())} {attributeMessage}";

//if (requiresUnreferencedCode.Url != null)
//{
Expand Down