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

Pass the temp path to DesktopStrongNameProvider ctor #72587

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Pass the temp path to DesktopStrongNameProvider ctor
This addresses feedback ticket: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1950505

The underlying issue here is that the DesktopStrongNameProvider assumes it's caller will pass it a temp directory as EmitStream.CreateStream fails if the path isn't set. Jared indicated the compiler has a ban on calling Path.GetTempPath within their codebase, so it's on the caller to specify a value.
  • Loading branch information
ToddGrun committed Mar 18, 2024
commit 52331e58045afeed283fa3847526dd7732ed8563
1 change: 1 addition & 0 deletions eng/config/BannedSymbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ M:Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(System
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(System.Threading.CancellationToken); Use overload that takes progress
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(CSystem.Threading.CancellationToken); Use overload that takes progress
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedDocumentAsync(CancellationToken); Use overload that takes progress
M:Microsoft.CodeAnalysis.DesktopStrongNameProvider.#ctor(System.Collections.Immutable.ImmutableArray{System.String}); Use overload that takes in temp directory
M:System.Diagnostics.Tracing.EventSource.WriteEvent(System.Int32,System.Object[]); Use WriteEventCore instead
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private Task<ProjectInfo> CreateProjectInfoAsync(ProjectFileInfo projectFileInfo
.WithSourceReferenceResolver(new SourceFileResolver([], projectDirectory))
// TODO: https://github.com/dotnet/roslyn/issues/4967
.WithMetadataReferenceResolver(new WorkspaceMetadataFileReferenceResolver(metadataService, new RelativePathResolver([], projectDirectory)))
.WithStrongNameProvider(new DesktopStrongNameProvider(commandLineArgs.KeyFileSearchPaths))
.WithStrongNameProvider(new DesktopStrongNameProvider(commandLineArgs.KeyFileSearchPaths, Path.GetTempPath()))
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default);

var documents = CreateDocumentInfos(projectFileInfo.Documents, projectId, commandLineArgs.Encoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading;
using Roslyn.Utilities;
Expand Down Expand Up @@ -158,7 +159,7 @@ protected static (
var xmlReferenceResolver = XmlFileResolver.Default;
var sourceReferenceResolver = SourceFileResolver.Default;
var assemblyIdentityComparer = DesktopAssemblyIdentityComparer.Default;
var strongNameProvider = new DesktopStrongNameProvider();
var strongNameProvider = new DesktopStrongNameProvider(ImmutableArray<string>.Empty, Path.GetTempPath());

return (
outputKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Immutable;
using System.IO;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
Expand Down Expand Up @@ -37,7 +38,7 @@ public static WellKnownSynchronizationKind GetWellKnownSynchronizationKind(this
public static CompilationOptions FixUpCompilationOptions(this ProjectInfo.ProjectAttributes info, CompilationOptions compilationOptions)
{
return compilationOptions.WithXmlReferenceResolver(GetXmlResolver(info.FilePath))
.WithStrongNameProvider(new DesktopStrongNameProvider(GetStrongNameKeyPaths(info)));
.WithStrongNameProvider(new DesktopStrongNameProvider(GetStrongNameKeyPaths(info), Path.GetTempPath()));
}

private static XmlFileResolver GetXmlResolver(string? filePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static ProjectInfo CreateProjectInfo(string projectName, string language,

var analyzerLoader = languageServices.SolutionServices.GetRequiredService<IAnalyzerService>().GetLoader();
var xmlFileResolver = new XmlFileResolver(commandLineArguments.BaseDirectory);
var strongNameProvider = new DesktopStrongNameProvider(commandLineArguments.KeyFileSearchPaths);
var strongNameProvider = new DesktopStrongNameProvider(commandLineArguments.KeyFileSearchPaths, Path.GetTempPath());

// Resolve all metadata references.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void UpdateProjectOptions_NoLock()
.WithConcurrentBuild(concurrent: false)
.WithXmlReferenceResolver(new XmlFileResolver(_commandLineArgumentsForCommandLine.BaseDirectory))
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
.WithStrongNameProvider(new DesktopStrongNameProvider(_commandLineArgumentsForCommandLine.KeyFileSearchPaths.WhereNotNull().ToImmutableArray()));
.WithStrongNameProvider(new DesktopStrongNameProvider(_commandLineArgumentsForCommandLine.KeyFileSearchPaths.WhereNotNull().ToImmutableArray(), Path.GetTempPath()));

// Override the default documentation mode.
var documentationMode = _commandLineArgumentsForCommandLine.DocumentationPath != null ? DocumentationMode.Diagnose : DocumentationMode.Parse;
Expand Down
Loading