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

Add and use TargetFramework.Net70 #64490

Merged
merged 8 commits into from
Oct 6, 2022
Merged

Add and use TargetFramework.Net70 #64490

merged 8 commits into from
Oct 6, 2022

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Oct 4, 2022

Closes #61463 (adds Net70)
Closes #61235 (removes RuntimeSupportsNumericIntPtr )

Relates to test plan #60578 (Numeric IntPtr)
Relates to test plan #59194 (ref fields)

Documentation of process:

  1. create a package with ref assemblies (see doc and PR for .NET 7 ref assemblies)
  2. ask First Responders to ingest resulting package from nuget into dotnet-public Azure feed
  3. add new TargetFramework, consuming that package (see first commit in this PR)

Note to future self: when adding a new TFM, it is good to update NetCoreApp to point to it. This requires a bit of a process:

  1. Move TargetFrameworkUtil.NetCoreApp forward and start a draft PR
  2. Fix up all of the tests that just have simple errors
  3. Hard code the rest to Net50
  4. Merge

Ideally, we can remove the packages for old reference assemblies, to reduce the amount of copy to test folders in CI.

@jcouv jcouv self-assigned this Oct 4, 2022
@jcouv jcouv force-pushed the net-70 branch 4 times, most recently from d2a47f8 to 06e4f21 Compare October 5, 2022 05:28
{
get
{
// CorLibrary should never be null, but that invariant is broken in some cases for MissingAssemblySymbol.
// Tracked by https://github.com/dotnet/roslyn/issues/61262
return CorLibrary?.RuntimeSupportsNumericIntPtr == true;
return CorLibrary is not null &&
RuntimeSupportsFeature(SpecialMember.System_Runtime_CompilerServices_RuntimeFeature__NumericIntPtr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider separating product changes and infrastructure changes into separate PRs

@@ -260,11 +260,6 @@ internal new AssemblyMetadata Copy()
return new AssemblyMetadata(this, shareCachedSymbols: true);
}

internal AssemblyMetadata CopyWithoutSharingCachedSymbols()
Copy link
Contributor

Choose a reason for hiding this comment

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

internal AssemblyMetadata CopyWithoutSharingCachedSymbols()

Given the volume of changes in this PR, consider splitting it into several more targeted PRs. We can discuss offline in more details.

@AlekseyTs
Copy link
Contributor

The title of the PR feels somewhat misleading. For example, in my mind adding TargetFramework.Net70 for tests is not equivalent to changing target framework for project files, etc. In general, it feels like this PR bundles to many unrelated work items together. I understand that there is likely an order dependency between them (one must be done before the other), but there are probably work items that that do not depend on others.

@jcouv jcouv force-pushed the net-70 branch 2 times, most recently from 9d3d153 to 86432cd Compare October 5, 2022 19:13
@jcouv
Copy link
Member Author

jcouv commented Oct 5, 2022

#if NET7_0_OR_GREATER

@AlekseyTs I've shrunk this PR to exclude the upgrade to new SDK.

I just want to point out this means that tests in NumerIntPtrTests no longer execute (see this line, but we never build the test projects with .NET 7). I'm okay with this temporary regression in coverage given that I have the follow-up change working already.

Note that RefFieldTests has the same problem, but there is no regression there since they didn't execute prior to this PR.


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:32 in 86432cd. [](commit_id = 86432cd, deletion_comment = False)

@jcouv jcouv changed the title Add TargetFramework.Net70 Add and use TargetFramework.Net70 Oct 5, 2022
@jcouv jcouv marked this pull request as ready for review October 6, 2022 05:50
@jcouv jcouv requested review from a team as code owners October 6, 2022 05:50
{
get
{
// CorLibrary should never be null, but that invariant is broken in some cases for MissingAssemblySymbol.
// Tracked by https://github.com/dotnet/roslyn/issues/61262
return CorLibrary?.RuntimeSupportsNumericIntPtr == true;
return CorLibrary is not null &&
Copy link
Member

@cston cston Oct 6, 2022

Choose a reason for hiding this comment

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

CorLibrary is not null &&

Is the CorLibrary check needed here? It's not included in similar properties below. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

It is. One test reaches this with a null CorLibrary (CompilationReferences_More, crash in EmitDifference). This is tracked by above issue.
I'm not sure why numeric IntPtr is uniquely susceptible, but it might be because it's involved in metadata decoding for a type that already exists in the BCL ref assemblies.

@cston
Copy link
Member

cston commented Oct 6, 2022

        CompileAndVerify(comp, verify: Verification.FailsPEVerify, expectedOutput: IncludeExpectedOutput(

Just curious: Why do these tests fail PEVerify?


In reply to: 1270347021


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:1406 in ab4209b. [](commit_id = ab4209b, deletion_comment = False)

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Oct 6, 2022

IL_0014: call ""readonly bool nint?.HasValue.get""

What is the source of baseline changes like this?


In reply to: 1270370025


In reply to: 1270370025 #Closed


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:1635 in ab4209b. [](commit_id = ab4209b, deletion_comment = False)

comp.VerifyDiagnostics(
// (4,18): error CS9064: Target runtime doesn't support ref fields.
// public ref T F;
Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, "F").WithLocation(4, 18),
Copy link
Contributor

@AlekseyTs AlekseyTs Oct 6, 2022

Choose a reason for hiding this comment

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

Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, "F").WithLocation(4, 18),

If the goal is to verify presence of this diagnostics, then we probably shouldn't be targeting default framework. Consider targeting Net50, for example. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

On second look, the original test didn't seem to be about the attribute definition being provided in source. I've removed the extra validation I'd added.

@jcouv
Copy link
Member Author

jcouv commented Oct 6, 2022

IL_0014: call ""readonly bool nint?.HasValue.get""

This was a change in the BCL: dotnet/runtime#1727


In reply to: 1270370025


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:1635 in ab4209b. [](commit_id = ab4209b, deletion_comment = False)

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 4)

@jcouv
Copy link
Member Author

jcouv commented Oct 6, 2022

        CompileAndVerify(comp, verify: Verification.FailsPEVerify, expectedOutput: IncludeExpectedOutput(

I've not investigated in great details.
PEVerify gives rather cryptic errors. All the skipped tests give 3x "Type load failed." regardless of content of test. Even if this test is removed (empty Main() method) those errors occur.
I would not expect PE Verify to work in Net70.


In reply to: 1270347021


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:1406 in ab4209b. [](commit_id = ab4209b, deletion_comment = False)

@AlekseyTs
Copy link
Contributor

        CompileAndVerify(comp, verify: Verification.FailsPEVerify, expectedOutput: IncludeExpectedOutput(

I've not investigated in great details.
PEVerify gives rather cryptic errors. All the skipped tests give 3x "Type load failed." regardless of content of test.

Could this be a temporary problem caused by the fact that we are trying to run tests in .NET 6 runtime, but using ref assemblies of the next version?

I would not expect PE Verify to work in Net70.

It is not obvious to me why that is. Could you elaborate please? At least I think we need to open a follow-up issue, or perhaps make verification conditional on whether we are building against NET7


In reply to: 1270401588


Refers to: src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs:1406 in ab4209b. [](commit_id = ab4209b, deletion_comment = False)

@jcouv
Copy link
Member Author

jcouv commented Oct 6, 2022

CodeFlow froze for the second time when I tried to post this response. Using GitHub for third attempt...

Could this be a temporary problem caused by the fact that we are trying to run tests in .NET 6 runtime, but using ref assemblies of the next version?

PEVerify only runs in Desktop runtime. Which version of the Core runtime we use doesn't seem relevant.
Either way, the same problem occurs in my next PR which adopts .NET 7 runtime to execute tests.

I would not expect PE Verify to work in Net70.

PEVerify is a tool/API for validation of PE on Desktop runtime. As far as I can tell, it is only given the bits for the module that we've emitted (see CLRHelpers.PeVerify), not references, so I don't know how it could resolve references to .NET Core BCL.

This is not a new problem, by the way. All tests that use TargetFramework.Net60 or Net50 skip PEVerify (PEVerify only runs when IsWindowsDesktop is true).

At least I think we need to open a follow-up issue, or perhaps make verification conditional on whether we are building against NET7

Let's discuss with Jared. I don't think we're investing in validation using PEVerify anymore.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 5)

@jcouv
Copy link
Member Author

jcouv commented Oct 6, 2022

I've resolved conflict with #64404 and that caused me to identify a bug in Verification.PassesOrFailFast logic. Conflict resolution and fix are in separate/last commit (e0f2dd2).

@jcouv jcouv merged commit 09fd334 into dotnet:main Oct 6, 2022
@jcouv jcouv deleted the net-70 branch October 6, 2022 23:27
@ghost ghost added this to the Next milestone Oct 6, 2022
333fred added a commit to 333fred/roslyn that referenced this pull request Oct 10, 2022
* upstream/main: (252 commits)
  Use the source-built version of ref packs and don't use app host when building in source-build (dotnet#64055)
  Enable rich LSIF hover information. (dotnet#64580)
  Add ChecksumAlgorithm to project snapshot (dotnet#62840)
  Utility for uploading artifact on test failure (dotnet#64578)
  Enable diagnostics
  Revert "Remove unused TS brace completion code"
  Publish additional packages to vssdk feed (dotnet#64571)
  spelling
  Move check
  Simplify SymbolKey implementation
  lint
  Update publish data to test PR validation fix (dotnet#64559)
  Simplify
  Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.cs
  Lint
  Proper equality checks
  Update src/Workspaces/Remote/Core/RemoteCallback.cs
  Revert "Not wait for solution crawler because it can be very busy"
  Add and use TargetFramework.Net70 (dotnet#64490)
  Not wait for solution crawler because it can be very busy
  ...
@RikkiGibson RikkiGibson modified the milestones: Next, 17.5 P1 Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants