Skip to content
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

Allow globally suppressing compiler warnings #762

Open
heaths opened this issue Sep 9, 2020 · 6 comments
Open

Allow globally suppressing compiler warnings #762

heaths opened this issue Sep 9, 2020 · 6 comments
Labels
Area-Packages and Extensions Related to acquiring and using packages and extensions enhancement New feature or request good first issue Good for newcomers

Comments

@heaths
Copy link

heaths commented Sep 9, 2020

When adding NuGet packages with common dependency but with different versions in a Jupyter notebook, compiler warning CS1701 occurs. To suppress this, each code cell needs #pragma warning disable CS1701. This becomes distracting when using a notebook as an interactive tutorial, so it would be great if suppression could be done globally - perhaps even a Directory.Build.props file in a parent or ancestor directory (like MSBuild project files). Or, at the very least, if a single #pragma would disable a warning for all cells.

An example of the error without the #pragma would be using the following in a code cell:

#r "nuget:Azure.Identity"
#r "nuget:Azure.Security.KeyVault.Secrets"

(8,27): warning CS1701: Assuming assembly reference 'Azure.Core, Version=1.0.2.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' used by 'Azure.Security.KeyVault.Secrets' matches identity 'Azure.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' of 'Azure.Core', you may need to supply runtime policy
@heaths
Copy link
Author

heaths commented Sep 15, 2020

Here's an example of where I have to add #pragmas to suppress these, and on one of the executable blocks it doesn't even work (see toward the bottom where the warning is still emitted): https://github.com/heaths/azure-sdk-notebooks/blob/886ca19ead4c3de9a921e47ee03c0c84bcfa3d68/dotnet/Secrets%20in%20Key%20Vault.ipynb

@jonsequitur jonsequitur added enhancement New feature or request Area-Packages and Extensions Related to acquiring and using packages and extensions labels Oct 29, 2020
@ArrowRaider
Copy link

I have a block that is emitting 3 of these warnings, and the pragma statement only removes 1 of them, leaving the other 2 present.

@jonsequitur
Copy link
Contributor

We would probably implement a fix for this related to #890. The general goal there is to make sure that we use existing, familiar implementations as much as possible.

One theory as to why the #pragma doesn't seem to stick is that each submission (e.g. cell) is actually compiled into a different assembly. Any thoughts on this, @tmat?

@tmat
Copy link
Member

tmat commented Apr 27, 2021

RE CS1701: This warning is obsolete and shouldn't be reported at all. The script engine can suppress these warnings globally.
RE #pragma - yes, these are scoped per compilation unit, i.e. submission. The host can define host-level command to suppress warnings globally.

@MSDNAndi
Copy link

Any news on this? This is super actionable as especially in the AI craze, there are a lot of prerelease packages from Microsoft, OpenAI and others, and every cell that uses anything from those packages currently needs to have the pragma warning disable.

@jonsequitur
Copy link
Contributor

One approach that could work would be a magic command (e.g. something like #!suppress-warnings CS1701) that suppresses a warning for current and future submissions. This would probably be fairly simple to add even for a first-time contributor to the project.

@jonsequitur jonsequitur added the good first issue Good for newcomers label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Packages and Extensions Related to acquiring and using packages and extensions enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants