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

Continued analyzer assembly loading work #66612

Merged
merged 7 commits into from
Feb 2, 2023
Merged

Conversation

jaredpar
Copy link
Member

@jaredpar jaredpar commented Jan 31, 2023

This change responds to several concerns raised in #66492:

  • Collapse the AnalyzerAssembyLoader hierarchy by one level and move more logic into the base type.
  • Fix AssemblyLoadContext in tests to not replicate types. That means we can safely pass ITestOutputHelper into the custom AssemblyLoadContext
  • Further strengthen the test separation

I have deliberately not changed the file names to reflect the new type names because I wanted the review process to be smooth. Once I have two sign offs for the change I will send another commit which does the following:

  • Rename
    • DefaultAnalyzerAssemblyLoaderTests.cs to AnalyzerAssemblyLoaderTests.cs
    • DefaultAnalyzerAssemblyLoader.Core.cs to AnalyzerAssemblyLoader.Core.cs
    • DefaultAnalyzerAssemblyLoader.Desktop.cs to AnalyzerAssemblyLoader.Desktop.cs
    • DefaultAnalyzerAssemblyLoader.cs to AnalyzerAssemblyLoader.cs
  • Move
    • DefaultAnalyzerAssemblyLoader into DefaultAnalyzerAssemblyLoader.cs
    • InvokeUtil to InvokeUtil.cs. As constructed every edit to this type causes Test Explorer to lose context on the theory branches. Doesn't come back until rebuild. Will be smoother editting in its own file.

That should get is into the style we expect here. After that I will merge once tests are green.

@jaredpar jaredpar requested review from a team as code owners January 31, 2023 00:04
@jaredpar
Copy link
Member Author

@RikkiGibson, @jcouv, @cston PTAL

@cston
Copy link
Member

cston commented Jan 31, 2023

                Assert.Throws<UnauthorizedAccessException>(() => File.Delete(testFixture.Delta1.Path));

deltaCopy.Path?


Refers to: src/Compilers/Core/CodeAnalysisTest/DefaultAnalyzerAssemblyLoaderTests.cs:1264 in 42010f0. [](commit_id = 42010f0, deletion_comment = False)

src/Compilers/Test/Core/AssemblyLoadTestFixture.cs Outdated Show resolved Hide resolved

#else

// The AsesmblyLoadTestFixture collection can't be taken advantage of on .NET Framework because
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The AsesmblyLoadTestFixture collection can't be taken advantage of on .NET Framework because
// The AssemblyLoadTestFixture collection can't be taken advantage of on .NET Framework because

@jcouv jcouv self-assigned this Jan 31, 2023
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 4) modulo typos Rikki pointed out

jaredpar and others added 6 commits February 2, 2023 10:06
This change responds to several concerns raised in dotnet#66492:

- Collapse the `AnalyzerAssembyLoader` hierarchy by one level and move
  more logic into the base type.
- Fix `AssemblyLoadContext` in tests to not replicate types. That means
  we can safely pass `ITestOutputHelper` into the custom
  `AssemblyLoadContext`
- Further strengthen the test separation

I have deliberately not changed the file names to reflect the new type
names because I wanted the review process to be smooth. Once I have two
sign offs for the change I will send another commit which does the
following:

- Rename
    - DefaultAnalyzerAssemblyLoaderTests.cs -> AnalyzerAssemblyLoaderTests.cs
    - DefaultAnalyzerAssemblyLoader.Core.cs -> AnalyzerAssemblyLoader.Core.cs
    - DefaultAnalyzerAssemblyLoader.Desktop.cs -> AnalyzerAssemblyLoader.Desktop.cs
    - DefaultAnalyzerAssemblyLoader.cs -> AnalyzerAssemblyLoader.cs
- Move
    - `DefaultAnalyzerAssemblyLoader` into DefaultAnalyzerAssemblyLoader.cs
    - `InvokeUtil` to InvokeUtil.cs. As constructed every edit to this
      type causes Test Explorer to lose context on the theory branches.
      Doesn't come back until rebuild. Will be smoother editting in its own
      file.

That should get is into the style we expect here. After that I will
merge once tests are green.
This also has the added benefit that the entire .NET Core set of tests
run in less than one second. Previously it close to half a second per
test.

This will hopefully alleviate the pain for the runtime issue we're
hittnig running `AssemblyLoadContext` tests in CI. This reduces the
amount of compilations on this code path which seem to be the trigger
for the failure.

- dotnet#66621
- dotnet/runtime#81108
@jaredpar jaredpar merged commit 79e33c5 into dotnet:main Feb 2, 2023
@jaredpar jaredpar deleted the load3 branch February 2, 2023 21:52
@ghost ghost added this to the Next milestone Feb 2, 2023
@RikkiGibson RikkiGibson modified the milestones: Next, 17.6 P2 Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants