Skip to content
Open
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
5 changes: 5 additions & 0 deletions .github/memory/testing/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class MyTests : CSharpTestBase

- **Unit tests** target individual compiler phases (lexing, parsing); **compilation
tests** create `Compilation` objects and verify symbols/diagnostics.
- **Version-specific C# features** use the matching
`src/Compilers/CSharp/Test/CSharpN/` project. Use `TestOptions.RegularNext`
for the upcoming language version and the latest stable `RegularN` option for
the disabled-feature boundary; retain an explicit `RegularPreview` case when
testing the feature's language-version gate.
Comment on lines +33 to +34

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retain an explicit RegularPreview case when testing the feature's language-version gate.

This guidance seems incorrect? To test the gate, you want to test across N and RegularNext.

- **Cross-language patterns**: many test patterns work for both C# and VB with
minor syntax changes.
- **Verification baselines**: when helpers like `VerifyDiagnostics`,
Expand Down
1 change: 1 addition & 0 deletions Compilers.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"src\\Compilers\\CSharp\\Portable\\Microsoft.CodeAnalysis.CSharp.csproj",
"src\\Compilers\\CSharp\\Test\\CommandLine\\Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\CSharp15\\Microsoft.CodeAnalysis.CSharp.CSharp15.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\CSharp16\\Microsoft.CodeAnalysis.CSharp.CSharp16.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit3\\Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit2\\Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit\\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj",
Expand Down
1 change: 1 addition & 0 deletions Ide.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"src\\Compilers\\CSharp\\Test\\Emit2\\Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit3\\Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\CSharp15\\Microsoft.CodeAnalysis.CSharp.CSharp15.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\CSharp16\\Microsoft.CodeAnalysis.CSharp.CSharp16.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit\\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\EndToEnd\\Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\IOperation\\Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests.csproj",
Expand Down
1 change: 1 addition & 0 deletions Roslyn.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Project Path="src/Compilers/CSharp/Test/Symbol/Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests.csproj" />
<Project Path="src/Compilers/CSharp/Test/Syntax/Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests.csproj" />
<Project Path="src/Compilers/CSharp/Test/CSharp15/Microsoft.CodeAnalysis.CSharp.CSharp15.UnitTests.csproj" />
<Project Path="src/Compilers/CSharp/Test/CSharp16/Microsoft.CodeAnalysis.CSharp.CSharp16.UnitTests.csproj" />
<Project Path="src/Compilers/CSharp/Test/WinRT/Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests.csproj" />
<Project Path="src/Compilers/Test/Utilities/CSharp/Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj" />
</Folder>
Expand Down
29 changes: 29 additions & 0 deletions docs/compilers/CSharp/compiler-breaking-changes-dotnet-12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Breaking changes in Roslyn after .NET 11.0.100 through .NET 12.0.100

This document lists known breaking changes in Roslyn after .NET 11 general release (.NET SDK version 11.0.100) through .NET 12 general release (.NET SDK version 12.0.100).

## Type parameter inference considers generic constraints

***Introduced in .NET 12***

In C# 16, method type inference can infer type parameters that occur only in the constraints of other inferred type parameters. As a result, a generic method that was previously excluded from overload resolution may become applicable. This can change the selected overload, introduce an ambiguity, or produce a more specific diagnostic from the newly applicable candidate.

For example, the following call previously selected the non-generic overload because `U` could not be inferred. It now selects the generic overload because `T` is fixed to `string` and `U` is then inferred as `char` from the `IEnumerable<U>` constraint.

```cs
using System;
using System.Collections.Generic;

static void M(object value) => Console.WriteLine("non-generic");
static void M<T, U>(T value) where T : IEnumerable<U> => Console.WriteLine("generic");

M("test"); // C# 15: "non-generic"; C# 16: "generic"
```

To preserve the previous overload selection, explicitly convert the argument to the intended parameter type:

```cs
M((object)"test"); // "non-generic"
```

See [the type parameter inference from constraints proposal](https://github.com/dotnet/csharplang/issues/9453) and [the Roslyn implementation](https://github.com/dotnet/roslyn/pull/84655).
1 change: 1 addition & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ function GetCompilerTestAssembliesIncludePaths() {
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.Emit2\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.Emit3\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.CSharp15\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.CSharp16\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.IOperation\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.CSharp\.CommandLine\.UnitTests$'"
$assemblies += " --include '^Microsoft\.CodeAnalysis\.VisualBasic\.Syntax\.UnitTests$'"
Expand Down
1 change: 1 addition & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ function GetCompilerTestAssembliesIncludePaths {
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.Emit2\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.Emit3\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.CSharp15\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.CSharp16\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.IOperation\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.CSharp\.CommandLine\.UnitTests$'"
assemblies+=" --include '^Microsoft\.CodeAnalysis\.VisualBasic\.Syntax\.UnitTests$'"
Expand Down
Loading