Skip to content

Commit 4747b00

Browse files
Merge remote-tracking branch 'upstream/main' into testClassification
2 parents 342e06e + 058591b commit 4747b00

File tree

100 files changed

+4610
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+4610
-616
lines changed

azure-pipelines-official.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ variables:
101101

102102
- ${{ if and(notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}:
103103
- name: enableSourceIndex
104-
value: true
104+
value: false
105105
- name: VSCodeOptimizationDataRoot
106106
value: $(Pipeline.Workspace)/profilingInputs/merged mibc
107107

docs/compilers/CSharp/Compiler Breaking Changes - DotNet 10.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,41 @@ class extension { } // type may not be named "extension"
364364
class C<extension> { } // type parameter may not be named "extension"
365365
```
366366

367+
## Partial properties and events are now implicitly virtual and public
368+
369+
***Introduced in Visual Studio 2022 version 17.15***
370+
371+
We have fixed [an inconsistency](https://github.com/dotnet/roslyn/issues/77346)
372+
where partial interface properties and events would not be implicitly `virtual` and `public` unlike their non-partial equivalents.
373+
This inconsistency is however [preserved](./Deviations%20from%20Standard.md#interface-partial-methods) for partial interface methods to avoid a larger breaking change.
374+
Note that Visual Basic and other languages not supporting default interface members will start requiring to implement implicitly virtual `partial` interface members.
375+
376+
To keep the previous behavior, explicitly mark `partial` interface members as `private` (if they don't have any accessibility modifiers)
377+
and `sealed` (if they don't have the `private` modifier which implies `sealed`, and they don't already have modifier `virtual` or `sealed`).
378+
379+
```cs
380+
System.Console.Write(((I)new C()).P); // wrote 1 previously, writes 2 now
381+
382+
partial interface I
383+
{
384+
public partial int P { get; }
385+
public partial int P => 1; // implicitly virtual now
386+
}
387+
388+
class C : I
389+
{
390+
public int P => 2; // implements I.P
391+
}
392+
```
393+
394+
```cs
395+
System.Console.Write(((I)new C()).P); // inaccessible previously, writes 1 now
396+
397+
partial interface I
398+
{
399+
partial int P { get; } // implicitly public now
400+
partial int P => 1;
401+
}
402+
403+
class C : I;
404+
```

docs/compilers/CSharp/Deviations from Standard.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@ The compiler is free to make assumptions about the shape and behavior of well-kn
7777
It may not check for unexpected constraints, `Obsolete` attribute, or `UnmanagedCallersOnly` attribute.
7878
It may perform some optimizations based on expectations that the types/members are well-behaved.
7979
Note: the compiler should remain resilient to missing well-known types/members.
80+
81+
# Interface partial methods
82+
83+
Interface partial methods are implicitly non-virtual,
84+
unlike non-partial interface methods and other interface partial member kinds,
85+
see [a related breaking change](./Compiler%20Breaking%20Changes%20-%20DotNet%2010.md#partial-properties-and-events-are-now-implicitly-virtual-and-public)
86+
and [LDM 2025-04-07](https://github.com/dotnet/csharplang/blob/main/meetings/2025/LDM-2025-04-07.md#breaking-change-discussion-making-partial-members-in-interfaces-virtual-andor-public).

eng/Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
<PackageVersion Include="NuGet.ProjectModel" Version="6.8.0-rc.112" />
146146
<PackageVersion Include="Microsoft.TestPlatform.TranslationLayer" Version="$(MicrosoftNETTestSdkVersion)" />
147147
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="$(MicrosoftNETTestSdkVersion)" />
148-
<PackageVersion Include="Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace" Version="9.0.0-preview.25064.4" />
149148

150149
<!--
151150
Analyzers

eng/Publishing.props

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<Project>
3-
<PropertyGroup>
4-
<PublishingVersion>3</PublishingVersion>
5-
</PropertyGroup>
62

73
<PropertyGroup>
84
<PublishDependsOnTargets>_ResolvePublishRoslynNuGetPackages;$(PublishDependsOnTargets)</PublishDependsOnTargets>
95
</PropertyGroup>
106

7+
<!-- Update Artifacts with Kind=Package to have additional metadata item Category="ToolingPackage".
8+
Depending on channel configuration, this means that these assets could be pushed to a different feed. -->
9+
<ItemGroup>
10+
<Artifact Update="@(Artifact->WithMetadataValue('Kind', 'Package'))" Category="ToolingPackage" />
11+
</ItemGroup>
12+
1113
<!--
1214
During PR Validation we only need to publish symbols with Arcade,
1315
since our packages are published separately to the CoreXT feed.
@@ -32,4 +34,5 @@
3234
<ItemsToPushToBlobFeed Include="@(_SymbolPackagesToPush)" />
3335
</ItemGroup>
3436
</Target>
35-
</Project>
37+
38+
</Project>

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
1414
</Dependency>
1515
<!-- Intermediate is necessary for source build. -->
16-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.621601">
16+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25223.3">
1717
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
18-
<Sha>4b566314cf9602b77f25538a88b9c8175231c106</Sha>
18+
<Sha>19eb5ea4e5f9c4e5256843a92805c8c9e942207d</Sha>
1919
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
2020
</Dependency>
2121
<Dependency Name="System.CommandLine" Version="2.0.0-beta5.25210.1">

src/Analyzers/Core/CodeFixes/Formatting/FormattingCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
6262
private async Task<Document> FixOneAsync(CodeFixContext context, Diagnostic diagnostic, CancellationToken cancellationToken)
6363
{
6464
var root = await context.Document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
65-
var text = root.GetText();
65+
var text = await context.Document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
6666

6767
// The span to format is the full line(s) containing the diagnostic
6868
var diagnosticSpan = diagnostic.Location.SourceSpan;

src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,21 @@ private BoundCall CreateBadCall(
19821982
var constructedMethods = ArrayBuilder<MethodSymbol>.GetInstance();
19831983
foreach (var m in methods)
19841984
{
1985-
constructedMethods.Add(m.ConstructedFrom == m && m.Arity == typeArgumentsWithAnnotations.Length ? m.Construct(typeArgumentsWithAnnotations) : m);
1985+
MethodSymbol constructedMethod;
1986+
if (m.GetIsNewExtensionMember())
1987+
{
1988+
constructedMethod = m.IsDefinition && m.GetMemberArityIncludingExtension() == typeArgumentsWithAnnotations.Length
1989+
? m.ConstructIncludingExtension(typeArgumentsWithAnnotations)
1990+
: m;
1991+
}
1992+
else
1993+
{
1994+
constructedMethod = m.ConstructedFrom == m && m.Arity == typeArgumentsWithAnnotations.Length
1995+
? m.Construct(typeArgumentsWithAnnotations)
1996+
: m;
1997+
}
1998+
1999+
constructedMethods.Add(constructedMethod);
19862000
}
19872001

19882002
methods = constructedMethods.ToImmutableAndFree();
@@ -2010,7 +2024,17 @@ private BoundCall CreateBadCall(
20102024

20112025
private static bool IsUnboundGeneric(MethodSymbol method)
20122026
{
2013-
return method.IsGenericMethod && method.ConstructedFrom == method;
2027+
if (method.GetMemberArityIncludingExtension() == 0)
2028+
{
2029+
return false;
2030+
}
2031+
2032+
if (!method.GetIsNewExtensionMember())
2033+
{
2034+
return method.ConstructedFrom == method;
2035+
}
2036+
2037+
return method.IsDefinition;
20142038
}
20152039

20162040
// Arbitrary limit on the number of parameter lists from overload
@@ -2023,9 +2047,9 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
20232047
var parameterListList = ArrayBuilder<ImmutableArray<ParameterSymbol>>.GetInstance();
20242048
foreach (var m in methods)
20252049
{
2026-
if (!IsUnboundGeneric(m) && m.ParameterCount > 0)
2050+
if (!IsUnboundGeneric(m) && m.GetParameterCountIncludingExtensionParameter() > 0)
20272051
{
2028-
parameterListList.Add(m.Parameters);
2052+
parameterListList.Add(m.GetParametersIncludingExtensionParameter(skipExtensionIfStatic: false));
20292053
if (parameterListList.Count == MaxParameterListsForErrorRecovery)
20302054
{
20312055
break;
@@ -2043,6 +2067,7 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
20432067
var parameterListList = ArrayBuilder<ImmutableArray<ParameterSymbol>>.GetInstance();
20442068
foreach (var p in properties)
20452069
{
2070+
// Tracked by https://github.com/dotnet/roslyn/issues/76130: Revisit this with new extensions
20462071
if (p.ParameterCount > 0)
20472072
{
20482073
parameterListList.Add(p.Parameters);

src/Compilers/CSharp/Portable/Binder/ExecutableCodeBinder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public static void ValidateIteratorMethod(CSharpCompilation compilation, MethodS
107107
return;
108108
}
109109

110-
var parameters = !iterator.IsStatic
111-
? iterator.GetParametersIncludingExtensionParameter()
112-
: iterator.Parameters;
110+
var parameters = iterator.GetParametersIncludingExtensionParameter(skipExtensionIfStatic: true);
113111

114112
foreach (var parameter in parameters)
115113
{

src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public static MethodTypeInferenceResult Infer(
277277
// no arguments per se we cons up some fake arguments.
278278
ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo,
279279
Extensions extensions = null,
280+
// Map of TypeParameterSymbol to ordinal for new extension methods
280281
Dictionary<TypeParameterSymbol, int> ordinals = null)
281282
{
282283
Debug.Assert(!methodTypeParameters.IsDefault);

0 commit comments

Comments
 (0)