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

IDE changes for analyzer loading #69470

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@ namespace Microsoft.CodeAnalysis
{
internal sealed class DefaultAnalyzerAssemblyLoader : AnalyzerAssemblyLoader
{
#if NETCOREAPP

internal DefaultAnalyzerAssemblyLoader()
{
}

#if NETCOREAPP

internal DefaultAnalyzerAssemblyLoader(System.Runtime.Loader.AssemblyLoadContext? compilerLoadContext = null, AnalyzerLoadOption loadOption = AnalyzerLoadOption.LoadFromDisk)
: base(compilerLoadContext, loadOption)
{
}

#else

internal DefaultAnalyzerAssemblyLoader()
{
}

#endif

/// <summary>
Expand All @@ -51,32 +45,21 @@ internal DefaultAnalyzerAssemblyLoader()
internal static IAnalyzerAssemblyLoader CreateNonLockingLoader(string windowsShadowPath)
{
#if NETCOREAPP
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// The cost of doing stream based loading on Windows is too expensive and we must continue to
// use the shadow copy loader.
return createShadowLoaderWindows();
}
else
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new DefaultAnalyzerAssemblyLoader(loadOption: AnalyzerLoadOption.LoadFromStream);
}
#else
return createShadowLoaderWindows();
#endif

ShadowCopyAnalyzerAssemblyLoader createShadowLoaderWindows()
// The shadow copy analyzer should only be created on Windows. To create on Linux we cannot use
// GetTempPath as it's not per-user. Generally there is no need as LoadFromStream achieves the same
// effect
if (!Path.IsPathRooted(windowsShadowPath))
{
// The shadow copy analyzer should only be created on Windows. To create on Linux we cannot use
// GetTempPath as it's not per-user. Generally there is no need as LoadFromStream achieves the same
// effect
if (!Path.IsPathRooted(windowsShadowPath))
{
throw new ArgumentException("Must be a full path.", nameof(windowsShadowPath));
}

return new ShadowCopyAnalyzerAssemblyLoader(windowsShadowPath);
throw new ArgumentException("Must be a full path.", nameof(windowsShadowPath));
}

return new ShadowCopyAnalyzerAssemblyLoader(windowsShadowPath);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal sealed class RemoteAnalyzerAssemblyLoader : AnalyzerAssemblyLoader

public RemoteAnalyzerAssemblyLoader(string baseDirectory)
{
// jason should we load from stream here on Linux or is this VS only?
_baseDirectory = baseDirectory;
}

Expand Down