-
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
Simplify and unify assembly loader provider #74895
Changes from all commits
65aaa15
cab006f
9bef508
655c0f8
9b75362
561c5cd
e6b292d
574bde8
bbf4ff9
f0fab02
d72580b
65e1db9
9da0b5e
a610785
b8a923f
bf31f0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,50 @@ | |
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Composition; | ||
using System.IO; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
|
||
namespace Microsoft.CodeAnalysis.Host; | ||
|
||
internal interface IAnalyzerAssemblyLoaderProvider : IWorkspaceService | ||
{ | ||
IAnalyzerAssemblyLoaderInternal GetShadowCopyLoader(); | ||
IAnalyzerAssemblyLoaderInternal SharedShadowCopyLoader { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Abstract implementation of an analyzer assembly loader that can be used by VS/VSCode to provide a <see | ||
/// cref="IAnalyzerAssemblyLoader"/> with an appropriate path. | ||
/// </summary> | ||
internal abstract class AbstractAnalyzerAssemblyLoaderProvider : IAnalyzerAssemblyLoaderProvider | ||
{ | ||
private readonly ImmutableArray<IAnalyzerAssemblyResolver> _externalResolvers; | ||
private readonly Lazy<IAnalyzerAssemblyLoaderInternal> _shadowCopyLoader; | ||
|
||
public AbstractAnalyzerAssemblyLoaderProvider(IEnumerable<IAnalyzerAssemblyResolver> externalResolvers) | ||
{ | ||
_externalResolvers = externalResolvers.ToImmutableArray(); | ||
_shadowCopyLoader = new(CreateShadowCopyLoader); | ||
} | ||
|
||
public IAnalyzerAssemblyLoaderInternal SharedShadowCopyLoader | ||
=> _shadowCopyLoader.Value; | ||
|
||
private IAnalyzerAssemblyLoaderInternal CreateShadowCopyLoader() | ||
=> this.WrapLoader(DefaultAnalyzerAssemblyLoader.CreateNonLockingLoader( | ||
Path.Combine(Path.GetTempPath(), nameof(Roslyn), "AnalyzerAssemblyLoader"), | ||
_externalResolvers)); | ||
|
||
protected virtual IAnalyzerAssemblyLoaderInternal WrapLoader(IAnalyzerAssemblyLoaderInternal loader) | ||
=> loader; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by this comment. _workspaceKind is still factoring into the path passed into WrapLoader, no? |
||
|
||
[ExportWorkspaceService(typeof(IAnalyzerAssemblyLoaderProvider)), Shared] | ||
[method: ImportingConstructor] | ||
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
internal sealed class DefaultAnalyzerAssemblyLoaderProvider( | ||
[ImportMany] IEnumerable<IAnalyzerAssemblyResolver> externalResolvers) | ||
: AbstractAnalyzerAssemblyLoaderProvider(externalResolvers); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we're now always using the same path now for VS/OOP - which I think is fine? I assume in VS we only make shadow copies in the remote workspace now? So devenv won't shadow copy analyzers and conflict with the remote workspace any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. every shadow copy loader already puts their work in a unique guid-named subdirectory of the base directory passed in. So there's no conflicts ever across instances (within the same process, or other process, etc.). THey are always independent.