Skip to content

Merge latest main into relaxed modifier ordering - #85251

Merged
akhera99 merged 56 commits into
dotnet:features/relaxed-modifier-orderingfrom
CyrusNajmabadi:merge-main-into-relaxed-modifier-ordering-20260910
Sep 10, 2026
Merged

Merge latest main into relaxed modifier ordering#85251
akhera99 merged 56 commits into
dotnet:features/relaxed-modifier-orderingfrom
CyrusNajmabadi:merge-main-into-relaxed-modifier-ordering-20260910

Conversation

@CyrusNajmabadi

@CyrusNajmabadi CyrusNajmabadi commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Merge the latest main into features/relaxed-modifier-ordering.

This brings in #85183 before the partial and ref ordering PRs are updated.

Microsoft Reviewers: Open in CodeFlow

jasonmalinowski and others added 30 commits September 4, 2026 13:48
Nobody on the team has used this in awhile, so we can just delete it.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 415c03c3-4e89-40bd-89c8-c28b3cab5da8
[main] Source code updates from dotnet/dotnet
[main] Source code updates from dotnet/dotnet
[main] Source code updates from dotnet/dotnet
Nobody on the team has used this in awhile, so we can just delete it.
## Summary

Introduce a synchronized Language Server service as the authoritative
source of current local workspace folders.

- Add initial folders directly from the LSP initialize handler.
- Remove and add folders for `workspace/didChangeWorkspaceFolders`
notifications.
- Normalize paths and compare them with platform path semantics, and
ignore non-file workspace-folder URIs.
- Migrate existing file-based-program consumers away from
`IInitializeManager` folder state.

## Validation

- `WorkspaceFolderTrackerTests` (2 passed)
- Analyzer-enabled Language Server unit-test project build succeeded
with 0 errors
- Final stacked analyzer-enabled Language Server build succeeded with 0
errors
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85105)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1d6a35c4-0f49-4671-b352-8cac98e9eaa4
The instructions to update FILE_MAP on any file add/remove was making
that quite noisy -- we don't need to record the addition of a single
utilities class, for example. Also remove instructions to update
area instructions on routine edits that are already tracked in other
files.
Fixes a hermeticity gap in Roslyn Helix test work items.

`PrepareTests` preserves the repository `NuGet.config`, but
`HelixTestRunner` only included `eng` and `global.json` in each
generated work-item payload. As a result, runtime NuGet clients such as
`Microsoft.CodeAnalysis.Testing.ReferenceAssemblies` loaded the Helix
machine defaults and attempted to resolve packages from nuget.org.

This change includes `NuGet.config` at every work-item root. The config
clears inherited package sources and uses the approved feeds, including
`dotnet-public`.

This addresses the `Microsoft.NETCore.App.Ref.10.0.1` failures observed
in [build
1587731](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1587731)
for dotnet#85107.

Validation:
- Built `src/Tools/RunTests/RunTests.csproj`
- Generated 27 local Helix work-item payloads and verified each
contained `NuGet.config`
- Ran the exact failing `SkippedNamespace_MoreDerivedNamespace` test
with fresh NuGet and temporary package caches; it resolved
`Microsoft.NETCore.App.Ref.10.0.1` successfully
- Ran all `Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests`: 317
passed
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85210)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: Mark Wiemer <mwiemer@microsoft.com>
…otnet#85214)

The instructions to update FILE_MAP on any file add/remove was making
that quite noisy -- we don't need to record the addition of a single
utilities class, for example. Also remove instructions to update area
instructions on routine edits that are already tracked in other files.
This migrates this code from the internal repository.
Since this repo isn't what's deploying this, let's not worry about it.
Previous attempt at this triggered on rolling dev/* builds not on PR.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85216)
The AI guidance contained a misleading compiler build target and an
unclear Razor services file location.

- **Compiler guidance:** Point the build example to the actual project
file:
  ```bash
  dotnet build src/Compilers/CSharp/csc/AnyCpu/csc.csproj
  ```
- **Razor guidance:** Explicitly identify
`eng\targets\RazorServices.props` as a repo-root file, not part of
`src\Razor`.

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes dotnet#85197

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: akhera99 <40616383+akhera99@users.noreply.github.com>
[main] Source code updates from dotnet/dotnet
… Build ID 3070492 (dotnet#85218)

This is the pull request automatically created by the OneLocBuild task
in the build process to check-in localized files generated based upon
translation source files (.lcl files) handed-back from the downstream
localization pipeline. If there are issues in translations, visit
https://aka.ms/icxLocBug and log bugs for fixes. The OneLocBuild wiki is
https://aka.ms/onelocbuild and the localization process in general is
documented at https://aka.ms/AllAboutLoc.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85218)

---------

Co-authored-by: dotnet-oneloc-localization[bot] <310689744+dotnet-oneloc-localization[bot]@users.noreply.github.com>
…net#85154)

This migrates this code from the internal repository.
…cally, resolving classification conflict (dotnet#85225)

Fixes dotnet#51553.

Roslyn classifies discards as keywords for syntax highlighting which
shows whether or not `_` is referring to a symbol.

<img width="329" height="230" alt="image"
src="https://github.com/user-attachments/assets/3364de33-039c-451a-94e5-25cc2f091731"
/>

However, it's not working for lambda parameter discards:
<img width="394" height="49" alt="image"
src="https://github.com/user-attachments/assets/60c81709-2e7d-45ce-9821-f3830cea834a"
/>

There was an attempt to implement it in
dotnet#40396 for lambda parameter
discards:

https://github.com/dotnet/roslyn/blob/6de0973c513f7d3940cc0b52ff7cd7d55b869982/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/DiscardSyntaxClassifier.cs#L36-L44

But this was insufficient because it was implemented in the semantic
classifier. The syntactic classifier already classified it as
ParameterName, and the two are merged with ordering rules which cause
ParameterName to win over Keyword.

https://github.com/dotnet/roslyn/blob/6de0973c513f7d3940cc0b52ff7cd7d55b869982/src/EditorFeatures/Core/Classification/ClassificationTypeFormatDefinitions.cs#L520-L523

This PR fixes the issue by implementing the proper classification in the
syntactic classifier instead of the semantic classifier. This is
preferable because the semantic classifier may run after more of a
delay, so this is less visual flicker in the IDE.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85225)
## Summary

Expose focused query APIs on `ProjectFileExtensionRegistry` for
consumers that need to enumerate registered project extensions or
resolve a language directly from an extension.

Existing project-path lookup retains file-based application
compatibility; this PR only separates reusable registry queries from
that behavior.

## Stack

Depends on **Centralize Language Server workspace folder tracking**.

## Validation

- Analyzer-enabled `Microsoft.CodeAnalysis.Workspaces.MSBuild` build
succeeded with 0 errors.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85106)

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: 1d6a35c4-0f49-4671-b352-8cac98e9eaa4
jasonmalinowski and others added 11 commits September 9, 2026 17:13
…ile (dotnet#85232)

This is to enable consumption in the SDK repo.
[main] Source code updates from dotnet/dotnet
## Summary
- replace packaged `Microsoft.CodeAnalysis.*.Testing` dependencies in
internal repository projects with local project references
- remove unused testing-library references from Language Server tests
and the Razor cohosting utility
- keep package references in Roslyn SDK samples and Visual Studio SDK
templates because they model standalone consumers
- align Razor's `System.Formats.Asn1` pin with the locally built testing
library dependency

This removes the package publication/update cycle for testing-library
fixes used by internal tests, including the NuGet source-resolution
issue observed in [build
1587758](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1587758).

## Validation
- built all directly changed internal projects across Workspaces,
CodeStyle, Language Server, Visual Studio integration tests,
RoslynAnalyzers, and Razor
- built C# Features tests to validate their transitive Workspaces
dependency
- confirmed every internal consumer resolves
`Microsoft.CodeAnalysis.*.Testing` dependencies as project assets
- confirmed only SDK samples and project templates retain
testing-library package references
- CodeStyle `RemoveUnusedParametersTests`: 133 passed on `net10.0`
- Features `AddImportCodeRefactoringTests`: 52 passed on `net10.0`
- Resx source-generator tests: 2 passed on `net10.0`
- Razor source-generator test: 1 passed on `net10.0`

The Visual Basic CodeStyle and Visual Studio source-generator projects
target .NET Framework; they were built but cannot be executed on macOS.

---------

Copilot-Session: 1d6a35c4-0f49-4671-b352-8cac98e9eaa4
Fixes dotnet#78721

## Summary

Metadata-only output cannot have an associated PDB. However, `/refonly
/debug:embedded` synthesized a PDB path and emitted a `CodeView`
debug-directory entry even though no PDB was produced.

This change:

- allows `EmitMetadataOnly` with `DebugInformationFormat.Embedded`
instead of throwing, bringing the public API into alignment with
command-line behavior;
- suppresses the effective PDB path for metadata-only output, preventing
PDB-related debug-directory entries;
- preserves the `Reproducible` entry for deterministic builds; and
- adds coverage for both the public emit API and the `/refonly
/debug:embedded` command-line path.

## Testing

- `CompilationEmitTests.EmitMetadataOnly_IgnoreEmbeddedPdb`
- `CommandLineTests.RefOnly_EmbeddedDebugInformation`
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85028)

---------

Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 86e95881-607e-4eb5-a88c-8dcf3dea2ca4
Copilot-Session: 55832284-ffad-4c9a-81d5-0e63a7b79265
Adds telemetry for empty definition, type-definition, reference, and
implementation responses to help diagnose invalid or off-by-one source
positions.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85082)
## Summary

- rename the partial modifier lookahead helper to describe its result
- inline the redundant partial member-or-type wrapper
- clarify whether member declarations are included in lookahead

## Test plan

- `Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests`
@CyrusNajmabadi
CyrusNajmabadi requested review from a team as code owners September 10, 2026 20:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode Area-Razor Needs UX Triage labels Sep 10, 2026
@CyrusNajmabadi

Copy link
Copy Markdown
Contributor Author

@333fred @dotnet/roslyn-compiler. just bringing feature branch up to date with main. Please auto-merge. kthxbye! :)

@akhera99

Copy link
Copy Markdown
Member

Will need to bring in latest main once #85253 has been merged

JoeRobich and others added 4 commits September 10, 2026 13:56
…net#85107)

## Summary

Tracks initial Language Server project loads on each LoadedProject,
allowing callers to await only the projects they requested and report
progress independently. Project paths are normalized and compared using
platform semantics to prevent duplicate loads, while failures, unloads,
and shutdown reliably release waiting callers.

Adds deterministic tests covering concurrent loads, reloads, failures,
path normalization, progress reporting, and disposal behavior.

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85107)

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1d6a35c4-0f49-4671-b352-8cac98e9eaa4
Copilot-Session: 5d746ea1-5c75-4b18-80d6-b51b10d46b9f
Copilot-Session: ec398bd6-078c-414a-b745-fa624f52e376
Copilot-Session: b6bbeadc-d0a7-4f79-9f55-a54f05246e32
…otnet#85230)

## Motivation

`AbstractTypeMap.SubstituteNamedType` eagerly rents and fills an
`ArrayBuilder<TypeWithAnnotations>` before determining whether
substitution changes any arguments.

The existing implementation avoids materializing an immutable array when
nothing changes, but uses one `changed` flag for two independent
conditions: the containing type changes, or one or more type arguments
change. This means unchanged arguments still get a new array when only
the containing type changes.

For example, consider a nested generic return type:

```csharp
class Cache<TKey>
{
    public sealed class Entry<TValue>(TKey key, TValue value)
    {
        public TKey Key { get; } = key;
        public TValue Value { get; } = value;
    }

    public Entry<string> GetText(TKey key) => new(key, "cached text");
}
```

When binding `new Cache<int>().GetText(42)`, the compiler substitutes
`TKey → int` into the declared return type:

```text
Cache<TKey>.Entry<string> → Cache<int>.Entry<string>
```

The containing type changes, but `Entry`'s own argument array remains
`[string]`. Outer type arguments are represented through
`ContainingType`, not included in the inner type's own argument array.

Previously, the containing-type change set `changed = true`, bypassing
the `Free(); return previous;` path and calling `ToImmutableAndFree()`.
The new symbol therefore received a newly materialized argument array
even though the original immutable array could be reused.

This is **not a failure of pooling**. The fully unchanged path already
returned the builder to the pool and was allocation-free in steady
state.

## Change

Defer renting the builder until the first changed argument. At that
point, copy the unchanged prefix and append the substituted arguments.

| Substitution outcome | Previous behavior | New behavior |
|---|---|---|
| Nothing changes | Rent, populate, and free a builder; return the
original symbol | Return the original symbol without builder work |
| Only the containing type changes | Materialize an argument array for
the new symbol | Reuse the original immutable argument array |
| Arguments change | Materialize a changed argument array | Materialize
a changed argument array |

This separates two benefits: avoiding pool traffic and array writes for
no-op substitutions, and avoiding an argument-array allocation for
containing-type-only substitutions.

The change preserves the existing `TypeWithAnnotations.IsSameAs`
comparison, including nullable annotations and custom modifiers. Tuple
handling is unchanged. It does not change alpha renaming or how
substituted containing types are constructed.

## Performance

BenchmarkDotNet measurements on .NET 10.0.11, Windows, Ryzen 9 5950X.
Baseline and candidate used saved Release builds and the in-process
toolchain to avoid rebuilding the baseline against modified sources.
Stronger runs used candidate then baseline order, six warmup iterations
and 15 measurement iterations with a 250 ms iteration time.

| Scenario | Before | After |
|---|---:|---:|
| No change, arity 0 | 10.16 ns | 6.99 ns |
| No change, arity 1 | 49.38 ns | 34.45 ns |
| No change, arity 2 | 82.34 ns | 57.04 ns |
| No change, arity 8 | 286.59 ns | 203.09 ns |
| Containing type only, arity 1 | 1,192 B/op | 1,144 B/op |
| Containing type only, arity 2 | 1,440 B/op | 1,368 B/op |
| Containing type only, arity 8 | 3,056 B/op | 2,840 B/op |

No-op execution time decreases approximately **29–31%**, with zero
steady-state allocation before and after. Containing-type-only cases
save **48, 72, and 216 bytes per operation**, respectively.
Changed-argument cases are not uniformly faster; two cases have
approximately 2% slower point estimates with overlapping error
intervals.

For a Replay workload containing 1,648 compiler requests, sampled
allocation attribution for C# `TypeWithAnnotations[]` decreased from
**1.78 GiB to 1.67 GiB**, approximately **6.3%**. These are type-wide
sampled estimates, not allocations attributed exclusively to this
method. The trace reader reported invalid negative lost-event counters,
so event loss is unknown.

Full-workload timings remain inconclusive: baseline runs took 184/163
seconds and candidate runs took 156/176 seconds in
baseline/candidate/candidate/baseline order. **No end-to-end compilation
speedup is claimed.**

## Coverage

Adds 14 benchmark cases covering no-op, first/last changed arguments,
containing-type-only changes, and nested substitutions. Grants the
existing `Benchmarks` assembly access to compiler internals for these
measurements.

Adds 18 regression cases covering symbol identity, nested types, tuple
names, nullable annotations, and custom modifiers. The original
algorithm passed all 22 TypeMap cases; the candidate passed 34
focused/related cases across TypeMapTests and
NoPiaLocalHideAndTypeSubstitutionTests. Release Replay and Benchmarks
builds passed with analyzers enabled.

All four Replay runs completed 1,648 compilations successfully, and all
2,164 emitted DLL/EXE/PDB files matched byte-for-byte across the four
runs.

Performance-tracing documentation is intentionally deferred to a
separate change.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85230)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fixes the test compilation failures introduced by dotnet#82294.

`TypeHierarchySupertypesParams` and `TypeHierarchySubtypesParams` no
longer inherit `TextDocumentPositionParams` under the LSP 3.18 model.
Remove the stale `TextDocument` and `Position` assignments from the
Language Server and Razor test requests; the handlers resolve the
document from `Item.Data`.

Validation:
- `dotnet test
src/LanguageServer/ProtocolUnitTests/Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests.csproj
-f net10.0 --filter 'FullyQualifiedName~TypeHierarchyTests'
-p:RunAnalyzersDuringBuild=true --no-restore`
- `dotnet test
src/Razor/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.UnitTests/Microsoft.VisualStudioCode.RazorExtension.UnitTests.csproj
--filter 'FullyQualifiedName~CohostTypeHierarchyEndpointTest'
-p:RunAnalyzersDuringBuild=true --no-restore`

The `net472` build could not be run locally on macOS because the .NET
Framework 4.7.2 targeting pack is unavailable; CI covers that target.

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/85253)

Copilot-Session: 5eafba01-dc3d-4db4-8343-3cc70b399bba
@CyrusNajmabadi

Copy link
Copy Markdown
Contributor Author

@akhera99 done. can you please set to auto-merge (NOT SQUASH). Tnx :)

@akhera99
akhera99 enabled auto-merge September 10, 2026 21:53
@akhera99
akhera99 merged commit 391a386 into dotnet:features/relaxed-modifier-ordering Sep 10, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Razor Community The pull request was submitted by a contributor who is not a Microsoft employee. Needs UX Triage VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.