-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Multi-target compiler to netstandard2.0 and netcoreapp3.1 #40766
Comments
@jaredpar Shouldn't we start with switching the VBCSCompiler to run on .NET Core and keeping netstandard2.0 until that's done? Otherwise, who is gonna be actually using the netcoreapp3.1 assemblies? The build task does not load them. |
@tmat VBCSCompiler is already mult-targeted to |
But we are actually not running it on Windows using .NET Core, right? |
The compiler executables will use the same .NET runtime that the MSBuild process is using. It doesn't consider the underlying operating system. That means if you use |
I see. But when building from VS that never uses |
Correct. That always goes through desktop MSBuild. Hence every tool, including the compiler, is the desktop version. |
It's a bit worrisome that we would effectively have two different compilers once we start using .NET Core specific features and these compilers might potentially produce different results between There would still be difference between IDE analysis and build, but at least build would be consistent. |
Correct that is 2 above. To be clear though there will be no language feature difference between .NET Desktop and .NET Core (same as today). The difference will be limited to implementation details, mostly around taking advantage of .NET Core APIs that provide better performance. Any language feature difference between .NET Desktop and .NET Core is a bug. It's possible there will be observable compiler behavior differences between .NET Desktop and .NET Core but that is already true today. Concrete example is there are subtle differences in how analyzers load into the compiler between desktop and core. But that is true today so no change here.
That is something we have looked into a few times but it's more involved than just flipping a switch. There are a couple of items that have to come along with that:
|
Yes, I am aware that it won't be a simple switch. I'm just suggesting we should at least start working on it asap since it will need work from other teams as well. At some point we would also want to run IDE services on .NET Core, which will have the same problems. #39988 tracks [1]. I think we should enable this requirement by default in the IDE with a possible off switch that we'll remove later on. |
Had to clean up a few nullable annotations now that we are compiling agaist `netcoreapp3.1` and hence get the full value of the framework annotations. This is also problematic though because there are now two places where the compiler can see nullable attributes that are directly used by the developer. For example `NotNullWhenAttribute`. This is both defined in our assemblies for non-netcoreapp target frameworks and provided by the SDK when targeting `netcoreapp3.1`. This causes a problem for assemblies which have the following characteristics: 1. Target `netcoreapp3.1` 1. Reference an assembly targeting `netstandard2.0` which uses our nullable attributes definition 1. Has IVT into (2) above These properties essentially define all of our unit test assemblies. In that environment it's not possible to use nullable attributes in code because the compiler can't disambiguate which definition of `NotNullWhenAttribute` to use. This meant I had to temporarily remove a few attributes until we can complete dotnet#40766.
This work is complete now. |
The compiler libraries should move to mult-target
netstandard2.0
andnetcoreapp3.1
where today they only targetnetstandard2.0
. Adding a target fornetcoreapp3.1
will provide some benefits to our code base:Debug.Assert
andstring.IsNullOrEmpty
as the flow attributes aren't present innetstandard2.0
. This is a significant burden for us as we annotate our source tree.This does have a few downsides:
This specifically includes the following libraries:
Check list:
netcoreapp3.1
. Today it is a mix of versions do to timing around when we adopted runtime features like Default Interface Methods.netstandard2.0
andnetcoreapp3.1
targets.netcoreapp3.1
binariesThe text was updated successfully, but these errors were encountered: