Skip to content

Commit

Permalink
Merge branch 'main' into lspApis2
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Jul 11, 2023
2 parents 8a5375e + 3de7706 commit 4770338
Show file tree
Hide file tree
Showing 132 changed files with 1,480 additions and 812 deletions.
10 changes: 5 additions & 5 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23360.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23360.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>226c103b56a979243f08032e6cddb4deb66ea54b</Sha>
<Sha>dd0aec2c9a3ee25da70212063fddf6cc47cd8780</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23326.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
<Sha>10a822a79bde97ca45faa76dc4ec33b85533728a</Sha>
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceLink.GitHub" Version="8.0.0-beta.23358.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Dependency Name="Microsoft.SourceLink.GitHub" Version="8.0.0-beta.23359.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>d65917a564ce5d2b75fc387a7f4d0bcc6bdd269d</Sha>
<SourceBuild RepoName="sourcelink" ManagedOnly="true" />
Expand All @@ -36,9 +36,9 @@
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5d10d428050c0d6afef30a072c4ae68776621877</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.23360.1">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.23360.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>226c103b56a979243f08032e6cddb4deb66ea54b</Sha>
<Sha>dd0aec2c9a3ee25da70212063fddf6cc47cd8780</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23251.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
Expand Down
5 changes: 3 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Versions used by several individual references below -->
<RoslynDiagnosticsNugetPackageVersion>3.11.0-beta1.23356.2</RoslynDiagnosticsNugetPackageVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>8.0.0-preview.23356.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisTestingVersion>1.1.2-beta1.23323.1</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftCodeAnalysisTestingVersion>1.1.2-beta1.23357.1</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.149-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.6.0</CodeStyleAnalyzerVersion>
Expand Down Expand Up @@ -326,6 +326,7 @@
</PropertyGroup>
<PropertyGroup>
<!-- We should try to keep this version in sync with the version of app-local runtime in VS. -->
<MicrosoftNetCoreAppPackagesVersion>6.0.6</MicrosoftNetCoreAppPackagesVersion>
<MicrosoftNetCoreAppRuntimePackagesVersion>8.0.0-preview.5.23280.8</MicrosoftNetCoreAppRuntimePackagesVersion>
<MicrosoftWindowsDesktopAppRuntimePackagesVersion>8.0.0-preview.5.23302.2</MicrosoftWindowsDesktopAppRuntimePackagesVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"xcopy-msbuild": "17.6.0-2"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23360.1",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23360.1"
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23360.4",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23360.4"
}
}
5 changes: 1 addition & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,13 +1523,10 @@ private void CheckWhatCandidatesWeHave(

if (lookupResult.IsMultiViable)
{
var conversions = Conversions;

foreach (var symbol in lookupResult.Symbols)
{
var method = (MethodSymbol)symbol;
var conversion = conversions.ConvertExtensionMethodThisArg(method.Parameters[0].Type, receiverType, ref useSiteInfo);
if (conversion.Exists)
if (method.ReduceExtensionMethod(receiverType, Compilation) is not null)
{
haveInstanceCandidates = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15862,6 +15862,44 @@ class C1(int p1)
comp.VerifyEmitDiagnostics();
}

[Fact]
[WorkItem("https://github.com/dotnet/roslyn/issues/68796")]
public void ParameterCapturing_165_ColorColor_MemberAccess_InstanceAndStatic_MethodAndExtensionMethod_Generic()
{
var source = """
struct S1(Color Color)
{
public void Test()
{
Color.M1(this);
}
}

static class E
{
public static void M1<T>(this T c, S1 x, int y = 0)
{
}
}

class Color
{
public static void M1<T>(T x) where T : unmanaged
{
}
}
""";
var comp = CreateCompilation(source, options: TestOptions.ReleaseDll);

comp.VerifyDiagnostics(
// (5,9): error CS9106: Identifier 'Color' is ambiguous between type 'Color' and parameter 'Color Color' in this context.
// Color.M1(this);
Diagnostic(ErrorCode.ERR_AmbiguousPrimaryConstructorParameterAsColorColorReceiver, "Color").WithArguments("Color", "Color", "Color Color").WithLocation(5, 9)
);

Assert.NotEmpty(comp.GetTypeByMetadataName("S1").InstanceConstructors.OfType<SynthesizedPrimaryConstructor>().Single().GetCapturedParameters());
}

[Fact]
public void CycleDueToIndexerNameAttribute_01()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/MSBuildTask/Csc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected override string ToolNameWithoutExtension
/// <summary>
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
/// </summary>
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitchIfNotNull("/lib:", AdditionalLibPaths, ",");
commandLine.AppendPlusOrMinusSwitch("/unsafe", _store, nameof(AllowUnsafeBlocks));
Expand Down
6 changes: 6 additions & 0 deletions src/Compilers/Core/MSBuildTask/Csi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class Csi : InteractiveCompiler
#endregion

#region Interactive Compiler Members

protected override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
// Nothing to add
}

protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitchIfNotNull("/lib:", AdditionalLibPaths, ",");
Expand Down
52 changes: 2 additions & 50 deletions src/Compilers/Core/MSBuildTask/InteractiveCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,60 +184,22 @@ public ITaskItem? Source

#region Tool Members

// See ManagedCompiler.cs on the logic of this property
private bool HasToolBeenOverridden => !(string.IsNullOrEmpty(ToolPath) && ToolExe == ToolName);

protected sealed override bool IsManagedTool => !HasToolBeenOverridden;

protected sealed override string PathToManagedTool => Utilities.GenerateFullPathToTool(ToolName);

protected sealed override string PathToNativeTool => Path.Combine(ToolPath ?? "", ToolExe);

protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
if (ProvideCommandLineArgs)
{
CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands).Select(arg => new TaskItem(arg)).ToArray();
CommandLineArgs = GenerateCommandLineArgsTaskItems(responseFileCommands);
}

return (SkipInteractiveExecution) ? 0 : base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
}

public string GenerateCommandLineContents() => GenerateCommandLineCommands();

protected sealed override string ToolArguments
{
get
{
var builder = new CommandLineBuilderExtension();
AddCommandLineCommands(builder);
return builder.ToString();
}
}

public string GenerateResponseFileContents() => GenerateResponseFileCommands();

protected sealed override string GenerateResponseFileCommands()
{
var commandLineBuilder = new CommandLineBuilderExtension();
AddResponseFileCommands(commandLineBuilder);
return commandLineBuilder.ToString();
}

#endregion

/// <summary>
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can't go into a response file and
/// must go directly onto the command line.
/// </summary>
protected virtual void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
}

/// <summary>
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
/// </summary>
protected virtual void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitch("/i-");

Expand Down Expand Up @@ -269,15 +231,5 @@ protected virtual void AddResponseFileCommands(CommandLineBuilderExtension comma
}
}
}

/// <summary>
/// Get the command line arguments to pass to the compiler.
/// </summary>
private string[] GetArguments(string commandLineCommands, string responseFileCommands)
{
var commandLineArguments = CommandLineUtilities.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
var responseFileArguments = CommandLineUtilities.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
return commandLineArguments.Concat(responseFileArguments).ToArray();
}
}
}
71 changes: 5 additions & 66 deletions src/Compilers/Core/MSBuildTask/ManagedCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,6 @@ public bool ReportIVTs

#endregion

// ToolExe delegates back to ToolName if the override is not
// set. So, if ToolExe == ToolName, we know ToolExe is not
// explicitly overridden. So, if both ToolPath is unset and
// ToolExe == ToolName, we know nothing is overridden, and
// we can use our own csc.
private bool HasToolBeenOverridden => !(string.IsNullOrEmpty(ToolPath) && ToolExe == ToolName);

protected sealed override bool IsManagedTool => !HasToolBeenOverridden;

/// <summary>
/// Method for testing only
/// </summary>
Expand All @@ -494,10 +485,6 @@ public string GeneratePathToTool()
return GenerateFullPathToTool();
}

protected sealed override string PathToManagedTool => Utilities.GenerateFullPathToTool(ToolName);

protected sealed override string PathToNativeTool => Path.Combine(ToolPath ?? "", ToolExe);

protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
using var logger = new CompilerServerLogger($"MSBuild {Process.GetCurrentProcess().Id}");
Expand All @@ -508,8 +495,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string
{
if (ProvideCommandLineArgs)
{
CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands)
.Select(arg => new TaskItem(arg)).ToArray();
CommandLineArgs = GenerateCommandLineArgsTaskItems(responseFileCommands);
}

if (SkipCompilerExecution)
Expand All @@ -526,7 +512,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string
string? tempDirectory = BuildServerConnection.GetTempPath(workingDirectory);

if (!UseSharedCompilation ||
HasToolBeenOverridden ||
!IsManagedTool ||
!BuildServerConnection.IsCompilerServerSupported)
{
LogCompilationMessage(logger, requestId, CompilationKind.Tool, $"using command line tool by design '{pathToTool}'");
Expand All @@ -550,7 +536,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string
var buildRequest = BuildServerConnection.CreateBuildRequest(
requestId,
Language,
GetArguments(ToolArguments, responseFileCommands).ToList(),
GenerateCommandLineArgsList(responseFileCommands),
workingDirectory: workingDirectory,
tempDirectory: tempDirectory,
keepAlive: null,
Expand Down Expand Up @@ -804,66 +790,19 @@ private void LogCompilationMessage(ICompilerServerLogger logger, Guid requestId,
}
}

public string GenerateResponseFileContents()
{
return GenerateResponseFileCommands();
}

/// <summary>
/// Get the command line arguments to pass to the compiler.
/// </summary>
private string[] GetArguments(string commandLineCommands, string responseFileCommands)
{
var commandLineArguments =
CommandLineUtilities.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true);
var responseFileArguments =
CommandLineUtilities.SplitCommandLineIntoArguments(responseFileCommands, removeHashComments: true);
return commandLineArguments.Concat(responseFileArguments).ToArray();
}

/// <summary>
/// Returns the command line switch used by the tool executable to specify the response file
/// Will only be called if the task returned a non empty string from GetResponseFileCommands
/// Called after ValidateParameters, SkipTaskExecution and GetResponseFileCommands
/// </summary>
protected override string GenerateResponseFileCommands()
{
CommandLineBuilderExtension commandLineBuilder = new CommandLineBuilderExtension();
AddResponseFileCommands(commandLineBuilder);
return commandLineBuilder.ToString();
}

/// <summary>
/// Method for testing only
/// </summary>
public string GenerateCommandLine()
{
return GenerateCommandLineCommands();
}

protected sealed override string ToolArguments
{
get
{
var builder = new CommandLineBuilderExtension();
AddCommandLineCommands(builder);
return builder.ToString();
}
}

/// <summary>
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can't go into a response file and
/// must go directly onto the command line.
/// </summary>
protected internal virtual void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
protected override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendWhenTrue("/noconfig", _store, nameof(NoConfig));
}

/// <summary>
/// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
/// </summary>
protected internal virtual void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
// If outputAssembly is not specified, then an "/out: <name>" option won't be added to
// overwrite the one resulting from the OutputAssembly member of the CompilerParameters class.
Expand Down
Loading

0 comments on commit 4770338

Please sign in to comment.