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

Pull reading of last storage subsystem out of lock (part2) #73295

Merged
merged 19 commits into from
May 2, 2024
Merged
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
"problemMatcher": "$msCompile",
"group": "build"
},
{
"label": "build Roslyn.sln",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"-p:RunAnalyzersDuringBuild=false",
"-p:GenerateFullPaths=true",
"Roslyn.sln"
],
"problemMatcher": "$msCompile",
"group": "build"
},
{
"label": "build current project",
"type": "shell",
Expand Down
28 changes: 28 additions & 0 deletions docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ public class C
}
```

## Collection expression for type implementing `IEnumerable` must have elements implicitly convertible to `object`

***Introduced in Visual Studio 2022 version 17.10***

*Conversion* of a collection expression to a `struct` or `class` that implements `System.Collections.IEnumerable` and *does not* have a strongly-typed `GetEnumerator()`
requires the elements in the collection expression are implicitly convertible to the `object`.
Previously, the elements of a collection expression targeting an `IEnumerable` implementation were assumed to be convertible to `object`, and converted only when binding to the applicable `Add` method.

This additional requirement means that collection expression conversions to `IEnumerable` implementations are treated consistently with other target types where the elements in the collection expression must be implicitly convertible to the *iteration type* of the target type.

This change affects collection expressions targeting `IEnumerable` implementations where the elements rely on target-typing to a strongly-typed `Add` method parameter type.
In the example below, an error is reported that `_ => { }` cannot be implicitly converted to `object`.
```csharp
class Actions : IEnumerable
{
public void Add(Action<int> action);
// ...
}

Actions a = [_ => { }]; // error CS8917: The delegate type could not be inferred.
```

To resolve the error, the element expression could be explicitly typed.
```csharp
a = [(int _) => { }]; // ok
a = [(Action<int>)(_ => { })]; // ok
```

## Collection expression target type must have constructor and `Add` method

***Introduced in Visual Studio 2022 version 17.10***
Expand Down
12 changes: 6 additions & 6 deletions eng/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@
<PackageVersion Include="runtime.linux-x64.Microsoft.NETCore.ILAsm" Version="$(ILAsmPackageVersion)" />
<PackageVersion Include="runtime.osx-x64.Microsoft.NETCore.ILAsm" Version="$(ILAsmPackageVersion)" />
<PackageVersion Include="Basic.CompilerLog.Util" Version="0.6.1" />
<PackageVersion Include="Basic.Reference.Assemblies.NetStandard20" Version="1.2.4" />
<PackageVersion Include="Basic.Reference.Assemblies.Net50" Version="1.2.4" />
<PackageVersion Include="Basic.Reference.Assemblies.Net60" Version="1.2.4" />
<PackageVersion Include="Basic.Reference.Assemblies.Net70" Version="1.3.0" />
<PackageVersion Include="Basic.Reference.Assemblies.NetStandard20" Version="1.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net50" Version="1.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net60" Version="1.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net70" Version="1.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.4.5" />
<PackageVersion Include="Basic.Reference.Assemblies.Net461" Version="1.3.0" />
<PackageVersion Include="Basic.Reference.Assemblies.NetStandard13" Version="1.2.4" />
<PackageVersion Include="Basic.Reference.Assemblies.Net461" Version="1.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.NetStandard13" Version="1.6.0" />
<PackageVersion Include="Microsoft.TeamFoundationServer.Client" Version="19.232.0-preview" />
<!--
Microsoft.TeamFoundationServer.Client is referencing System.Data.SqlClient causing CG alert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ string getSdkDirectory(TempRoot temp)
if (ExecutionConditionUtil.IsCoreClr)
{
var dir = temp.CreateDirectory();
File.WriteAllBytes(Path.Combine(dir.Path, "mscorlib.dll"), Net461.References.mscorlib.ImageBytes);
File.WriteAllBytes(Path.Combine(dir.Path, "mscorlib.dll"), Net461.ReferenceInfos.mscorlib.ImageBytes);
return dir.Path;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11986,7 +11986,7 @@ public sealed class DiagnosticDescriptor
var minSystemCollectionsImmutableImage = CSharpCompilation.Create(
"System.Collections.Immutable",
new[] { SyntaxFactory.ParseSyntaxTree(minSystemCollectionsImmutableSource) },
new MetadataReference[] { NetStandard13.SystemRuntime },
new MetadataReference[] { NetStandard13.References.SystemRuntime },
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_b03f5f7f11d50a3a)).EmitToArray();

var minSystemCollectionsImmutableRef = MetadataReference.CreateFromImage(minSystemCollectionsImmutableImage);
Expand All @@ -11996,7 +11996,7 @@ public sealed class DiagnosticDescriptor
new[] { SyntaxFactory.ParseSyntaxTree(minCodeAnalysisSource) },
new MetadataReference[]
{
NetStandard13.SystemRuntime,
NetStandard13.References.SystemRuntime,
minSystemCollectionsImmutableRef
},
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, cryptoPublicKey: TestResources.TestKeys.PublicKey_31bf3856ad364e35)).EmitToArray();
Expand Down Expand Up @@ -12087,7 +12087,7 @@ public override void Initialize(AnalysisContext context)
minCodeAnalysisRef,
minSystemCollectionsImmutableRef
};
references = references.Concat(NetStandard13.All).ToArray();
references = references.Concat(NetStandard13.References.All).ToArray();

var analyzerImage = CSharpCompilation.Create(
analyzerAssemblyName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49419,7 +49419,7 @@ static explicit operator byte(I1 x)
public void RuntimeFeature_01()
{
var compilation1 = CreateCompilation("", options: TestOptions.DebugDll,
references: new[] { Net461.mscorlib },
references: new[] { Net461.References.mscorlib },
targetFramework: TargetFramework.Empty);

Assert.False(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
Expand All @@ -49430,7 +49430,7 @@ public void RuntimeFeature_01()
public void RuntimeFeature_02()
{
var compilation1 = CreateCompilation("", options: TestOptions.DebugDll,
references: new[] { Net70.SystemRuntime },
references: new[] { Net70.References.SystemRuntime },
targetFramework: TargetFramework.Empty);

Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
Expand Down Expand Up @@ -49730,7 +49730,7 @@ public static class RuntimeFeature
";

var compilation1 = CreateCompilation(source, options: TestOptions.DebugDll,
references: new[] { Net461.mscorlib },
references: new[] { Net461.References.mscorlib },
targetFramework: TargetFramework.Empty);

Assert.False(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public class TestAnalyzer : DiagnosticAnalyzer
new SyntaxTree[] { CSharp.SyntaxFactory.ParseSyntaxTree(analyzerSource) },
new MetadataReference[]
{
NetStandard20.mscorlib,
NetStandard20.netstandard,
NetStandard20.SystemRuntime,
NetStandard20.References.mscorlib,
NetStandard20.References.netstandard,
NetStandard20.References.SystemRuntime,
MetadataReference.CreateFromFile(immutable.Path),
MetadataReference.CreateFromFile(analyzer.Path)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private TempFile CreateNetStandardDll(TempDirectory directory, string assemblyNa
var comp = CSharpCompilation.Create(
assemblyName,
sources,
references: NetStandard20.All,
references: NetStandard20.References.All,
options: options);

var file = directory.CreateFile($"{assemblyName}.dll");
Expand Down Expand Up @@ -112,7 +112,7 @@ public void DifferingMvidsDifferentDirectory()
var directory = Temp.CreateDirectory();
var assemblyLoader = DefaultAnalyzerAssemblyLoader.CreateNonLockingLoader(directory.CreateDirectory("shadow").Path);

var key = NetStandard20.netstandard.GetAssemblyIdentity().PublicKey;
var key = NetStandard20.References.netstandard.GetAssemblyIdentity().PublicKey;
var mvidAlpha1 = CreateNetStandardDll(directory.CreateDirectory("mvid1"), "MvidAlpha", "1.0.0.0", key, "class C { }");
var mvidAlpha2 = CreateNetStandardDll(directory.CreateDirectory("mvid2"), "MvidAlpha", "1.0.0.0", key, "class D { }");

Expand All @@ -137,7 +137,7 @@ public void DifferingMvidsSameDirectory()
var directory = Temp.CreateDirectory();
var assemblyLoader = DefaultAnalyzerAssemblyLoader.CreateNonLockingLoader(directory.CreateDirectory("shadow").Path);

var key = NetStandard20.netstandard.GetAssemblyIdentity().PublicKey;
var key = NetStandard20.References.netstandard.GetAssemblyIdentity().PublicKey;
var mvidAlpha1 = CreateNetStandardDll(directory, "MvidAlpha", "1.0.0.0", key, "class C { }");

var result = AnalyzerConsistencyChecker.Check(
Expand Down Expand Up @@ -168,7 +168,7 @@ public void DifferingMvidsSameDirectory()
public void LoadingLibraryFromCompiler()
{
var directory = Temp.CreateDirectory();
_ = CreateNetStandardDll(directory, "System.Memory", "2.0.0.0", NetStandard20.netstandard.GetAssemblyIdentity().PublicKey);
_ = CreateNetStandardDll(directory, "System.Memory", "2.0.0.0", NetStandard20.References.netstandard.GetAssemblyIdentity().PublicKey);

// This test must use the DefaultAnalyzerAssemblyLoader as we want assembly binding redirects
// to take affect here.
Expand Down Expand Up @@ -226,7 +226,7 @@ public void AssemblyLoadException()
public void LoadingSimpleLibrary()
{
var directory = Temp.CreateDirectory();
var key = NetStandard20.netstandard.GetAssemblyIdentity().PublicKey;
var key = NetStandard20.References.netstandard.GetAssemblyIdentity().PublicKey;
var compFile = CreateNetStandardDll(directory, "netstandardRef", "1.0.0.0", key);

var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference(compFile.Path));
Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/Test/Core/AssemblyLoadTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ private static string GenerateDll(string assemblyName, TempDirectory directory,
syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(csSource, encoding: null, SourceHashAlgorithms.Default)) },
references: (new MetadataReference[]
{
NetStandard20.mscorlib,
NetStandard20.netstandard,
NetStandard20.SystemRuntime
NetStandard20.References.mscorlib,
NetStandard20.References.netstandard,
NetStandard20.References.SystemRuntime
}).Concat(additionalReferences),
options: options);

Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/Test/Core/Platform/Desktop/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public class TestAnalyzer : DiagnosticAnalyzer
new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(analyzerSource, encoding: null, SourceHashAlgorithms.Default)) },
new MetadataReference[]
{
NetStandard20.mscorlib,
NetStandard20.netstandard,
NetStandard20.SystemRuntime,
NetStandard20.References.mscorlib,
NetStandard20.References.netstandard,
NetStandard20.References.SystemRuntime,
MetadataReference.CreateFromFile(immutable.Path),
MetadataReference.CreateFromFile(analyzer.Path)
},
Expand Down
Loading