Skip to content

Conversation

@sebastienros
Copy link
Contributor

No description provided.

@dadhi
Copy link
Owner

dadhi commented Oct 25, 2025

Thank you! Will look later.

@sebastienros
Copy link
Contributor Author

I am quite ashamed to say that I can't explain how these warnings show up in my project and not in yours. I do use Polysharp which comes with some polyfills and analyzers but even when removing u still see some. SDK is the same too.

But when I find out I think I would try to add a change here to reveal them. I think it's important for the src packages because in the end of the target project can't build these it's useless. At the same time ignoring all these like I did in this PR is fine because this is the same code as the non-src ones so it's as good.

Ideally the BuildInternal script would inject code to ignore all warnings, this way you do what you want and these why will work anywhere.

@sebastienros
Copy link
Contributor Author

I asked chatgpt and I think I found the solution. Update incoming. Much simpler, and hassle-free for you.

{
$content = Get-Content -path $file
$content = $content -creplace "public(?=\s+(((abstract|sealed|static|record)\s+)?(partial\s+)?class|delegate|enum|interface|struct|record))", "internal"
$content = ,"#pragma warning disable" + $content # $content is a list of lines, insert at the top
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generates the #pragma warning disable for each internal files.
This way the warnings are not ignored in your standard code, in case you want to see and handle them individually

protected internal virtual Expression VisitDebugInfo(DebugInfoExpression node) => node;
}

#nullable restore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary at the end of files, these directives are per-file.

@@ -1,4 +1,6 @@
using System;
#nullable disable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #nullable disable for every file, since this will be necessary for internal files, and you really don't use nullable types.


[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
class CallerArgumentExpression : Attribute
class CallerArgumentExpressionAttribute : Attribute
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would be a conflict otherwise in internal files in some fwks, it would be conflicted between this and the real ones when it's used later in the code.

public static StringBuilder Argument(StringBuilder sb, int ordinal) => sb.AppendFormat(CultureInfo.InvariantCulture, "V_{0}", ordinal);
public static StringBuilder Label(StringBuilder sb, int offset) => sb.AppendFormat(CultureInfo.InvariantCulture, "IL_{0:D4}", offset);

public static StringBuilder MultipleLabels(StringBuilder sb, int[] offsets)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings could be ignored, but I think it's good to set the culture in case there is a side effect when rendered "technical" values like these.

public static bool AllowPrintCS = false;
public static bool AllowPrintExpression = false;
public static bool DisableAssertOpCodes = false;
public static bool AllowPrintIL;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were valid warnings appearing in my build. Though doesn't matter much in this case.

@sebastienros
Copy link
Contributor Author

I am happy with these changes now. The main idea is to inject #pragma warning disable on all internal files, and also remove any existing pragma restore since the global disable should not be altered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants