Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
233 commits
Select commit Hold shift + click to select a range
6a3d295
Add WorkItem attribute to track GitHub issue #80628
Copilot Oct 10, 2025
d23a3b1
Revert "Docs"
CyrusNajmabadi Oct 10, 2025
0466900
Switch to lock instead
CyrusNajmabadi Oct 10, 2025
da3607c
Switch to lock instead
CyrusNajmabadi Oct 10, 2025
aaf32e7
Add XML doc comments to Incremental Generator public API (#80609)
Copilot Oct 10, 2025
ef5182a
PEDeltaAssemblyBuilder: Don't freeze `_needsGeneratedAttributes` comp…
AlekseyTs Oct 10, 2025
db13c17
Update dotnet-format instructions (#80642)
JoeRobich Oct 10, 2025
b127cfe
Fix where keyword completion for extension declarations
Copilot Oct 10, 2025
fdf76d9
Update WorkItem attributes with proper placeholder format
Copilot Oct 10, 2025
72ea8d1
Add test cases for incomplete parameter lists in extensions
Copilot Oct 10, 2025
39d38f9
Update tests
CyrusNajmabadi Oct 10, 2025
4b4e7d3
Update code
CyrusNajmabadi Oct 10, 2025
fbd9982
Simplify
CyrusNajmabadi Oct 10, 2025
d17489e
Initial spike for file-based programs editor features (#80410)
RikkiGibson Oct 10, 2025
5fdb64c
Build BuildHost against net8.0 (#80641)
JoeRobich Oct 10, 2025
08658df
Add xcopy-msbuild version to global.json (#80647)
JoeRobich Oct 11, 2025
47d179f
Do not run the 'fully qualify' fixer on sourcce-generated docs
CyrusNajmabadi Oct 10, 2025
d2b50b6
Improve diagnostic quality for less accessible base type argument (#8…
stbau04 Oct 13, 2025
043f72b
Restore fully qualify for Razor (#80674)
davidwengier Oct 13, 2025
c678ad9
Fix stack overflow when looking for json embedded strings in a file
CyrusNajmabadi Oct 13, 2025
8982003
remove
CyrusNajmabadi Oct 13, 2025
e21823f
Use proper "unsafe" context while binding type in explicit interface …
AlekseyTs Oct 13, 2025
b2ae410
Add ExtensionOrder to ensure RemoveUnnecessaryImports runs before Fil…
Copilot Oct 12, 2025
7c50e3e
Fix FindReferences with a type arg in a conversion operator
CyrusNajmabadi Oct 12, 2025
720a6b8
Fix
CyrusNajmabadi Oct 12, 2025
9aef686
Update src/EditorFeatures/Test2/FindReferences/FindReferencesTests.Ty…
CyrusNajmabadi Oct 12, 2025
458dbed
cleanup
CyrusNajmabadi Oct 12, 2025
25d0104
Fix exception when adding delegate declaration to interface in Syntax…
Copilot Oct 12, 2025
a66c4e7
Remove accessibility modifiers from delegate declarations in interfaces
Copilot Oct 12, 2025
efefe21
Add WorkItem attribute to test and update copilot instructions
Copilot Oct 12, 2025
b1bb80d
Refactor delegate handling to use pattern matching
Copilot Oct 12, 2025
a995ab8
Update src/Workspaces/CoreTest/Editing/SyntaxEditorTests.cs
CyrusNajmabadi Oct 12, 2025
1fd226a
Update WorkItem attribute format to URL-only
Copilot Oct 12, 2025
4a4c3a3
Implement Go To Definition preference for non-generated code
Copilot Oct 12, 2025
1317f68
Add test for Go To Definition with partial user and generated code
Copilot Oct 12, 2025
abe9a83
Use IsGeneratedCodeAsync extension method to simplify code
Copilot Oct 12, 2025
a150e3c
Remove redundant inline comments from GetPreferredNonGeneratedLocatio…
Copilot Oct 12, 2025
071da44
Address code review feedback: inline variable, remove unused using, a…
Copilot Oct 12, 2025
62b83be
Add using
CyrusNajmabadi Oct 12, 2025
c25cc57
remove
CyrusNajmabadi Oct 12, 2025
3a0fb03
Update tests
CyrusNajmabadi Oct 13, 2025
3cd2dfa
Fix HasInitializer to recognize deconstructed variables with initiali…
Copilot Oct 12, 2025
16d6e8f
Add test for pattern matching reassigned in local function
Copilot Oct 12, 2025
b77921c
Update src/Workspaces/CSharp/Portable/ReassignedVariable/CSharpReassi…
CyrusNajmabadi Oct 12, 2025
46fba08
Add tests for explicit type and nested deconstruction reassigned in l…
Copilot Oct 12, 2025
ac08e4c
Fix patterns
CyrusNajmabadi Oct 12, 2025
6cd11f0
Add support for incomplete parenthesized tuples in DeclarationNameInfo
Copilot Oct 12, 2025
33912a4
Add additional test cases for incomplete parenthesized tuples
Copilot Oct 12, 2025
8035b9d
Add test cases with closing paren after cursor position
Copilot Oct 12, 2025
3bac03f
Add test variants for fully qualified generic types and array types
Copilot Oct 12, 2025
74bc70f
Lint
CyrusNajmabadi Oct 12, 2025
eaec8a1
Fixes
CyrusNajmabadi Oct 12, 2025
958e90b
UPdate tests
CyrusNajmabadi Oct 12, 2025
e6c1929
Fix existing test
CyrusNajmabadi Oct 12, 2025
3f38112
Port 80643 to main (#80652)
dibarbet Oct 13, 2025
6a5c2d3
Update formatting and add PROTOTYPE comments note (#80677)
akhera99 Oct 13, 2025
19a9bf5
Add failing test for IDE0200 with nullability difference in Task retu…
Copilot Oct 12, 2025
8b4cf31
Fix IDE0200 to avoid suggesting conversion when nullability differs
Copilot Oct 12, 2025
0cdcff2
Add test for nullability match case in Task return type
Copilot Oct 12, 2025
634627a
Simplify nullability check using boolean logic
Copilot Oct 12, 2025
65fda8a
Add tests for covariance/contravariance with nullability enabled
Copilot Oct 12, 2025
f94f8b1
Add option for single-line XML documentation comment generation
Copilot Oct 12, 2025
12382d2
Add tests for single-line XML documentation comment generation
Copilot Oct 12, 2025
701a890
Fix VB compilation issue by removing 'in' modifier from abstract method
Copilot Oct 12, 2025
d3e7392
Add WorkItem attributes to new collapsed XML doc comment tests
Copilot Oct 12, 2025
44eb19c
Apply code review feedback: rename option, simplify code, consolidate…
Copilot Oct 12, 2025
e400f7f
Add GenerateOnlySummaryTag option and Enter key test for single-line …
Copilot Oct 12, 2025
e4365ee
Inline trimmedText variable in single-line summary generation
Copilot Oct 12, 2025
e5ed884
Rename automation properties and add VB tests for single-line options
Copilot Oct 12, 2025
9e03b9a
Update src/VisualStudio/Core/Def/ServicesVSResources.resx
CyrusNajmabadi Oct 12, 2025
1f23141
Update resources
CyrusNajmabadi Oct 12, 2025
9e3a109
Lint
CyrusNajmabadi Oct 12, 2025
44b5817
Add storage location
CyrusNajmabadi Oct 12, 2025
dd78ab4
Remove explicit margins from documentation comment checkboxes in XAML
Copilot Oct 12, 2025
7532f89
Fix caret position calculation for single-line summary tags
Copilot Oct 12, 2025
25a55e8
Fix caret offset to account for shaved exterior trivia
Copilot Oct 12, 2025
e19fa0d
Fix
CyrusNajmabadi Oct 12, 2025
9c9f12b
Update test
CyrusNajmabadi Oct 12, 2025
c821d47
Extend `ToArray` optimization when targeting read-only collection typ…
DoctorKrolic Oct 13, 2025
e677f41
Add primary constructor support to AddConstructorParametersFromMember…
Copilot Oct 11, 2025
8f55e07
Use SyntaxGenerator.WithInitializer for adding property/field initial…
Copilot Oct 11, 2025
666fd0f
Use reflection to call C# syntax methods for property initializers
Copilot Oct 11, 2025
8d8eaf7
Move IsPrimaryConstructor to IMethodSymbolExtensions and simplify logic
Copilot Oct 12, 2025
b44d8d1
Replace reflection with SyntaxGeneratorInternal.WithPropertyInitializ…
Copilot Oct 12, 2025
264becf
Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extension…
CyrusNajmabadi Oct 12, 2025
a6014ef
Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extension…
CyrusNajmabadi Oct 12, 2025
262c67a
Apply code review suggestions: simplify return and fix WithPropertyIn…
Copilot Oct 12, 2025
a5e53cc
Add WorkItem attributes to primary constructor tests
Copilot Oct 12, 2025
f1af12e
Match WithInitializer pattern: cast to EqualsValueClauseSyntax and wr…
Copilot Oct 12, 2025
5e0ec1f
Lift initializerExpression and equalsValueClause out of if-else blocks
Copilot Oct 12, 2025
aaf634f
Move foreach loop outside if-else to share logic between property and…
Copilot Oct 12, 2025
647da20
Update src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBa…
CyrusNajmabadi Oct 12, 2025
17ddfaa
Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extension…
CyrusNajmabadi Oct 12, 2025
7ba3b32
Always provide token
CyrusNajmabadi Oct 12, 2025
33750ef
IN progress
CyrusNajmabadi Oct 12, 2025
47b37cb
In progress
CyrusNajmabadi Oct 12, 2025
9a68beb
Got connfused
CyrusNajmabadi Oct 12, 2025
09810ea
In progress
CyrusNajmabadi Oct 12, 2025
86bc7b3
In progress
CyrusNajmabadi Oct 13, 2025
824b12e
Cleanup
CyrusNajmabadi Oct 13, 2025
282b215
Add back
CyrusNajmabadi Oct 13, 2025
b0d1032
Revert
CyrusNajmabadi Oct 13, 2025
918846e
Remove
CyrusNajmabadi Oct 13, 2025
99e8c4f
In progress
CyrusNajmabadi Oct 13, 2025
d3994a6
Simplify
CyrusNajmabadi Oct 13, 2025
3bbb699
Docs
CyrusNajmabadi Oct 13, 2025
c5f2f08
Simplify
CyrusNajmabadi Oct 13, 2025
1acf1f2
Fix
CyrusNajmabadi Oct 13, 2025
e72f2a6
Add DocCommentCodeBlockClassifier for syntax highlighting in doc comm…
Copilot Oct 12, 2025
4d738b0
Add test for doc comment code block classification
Copilot Oct 12, 2025
a9f30e4
Update test expectations for syntactic classification in doc comment …
Copilot Oct 12, 2025
9f59f8e
Extract VirtualCharSequenceSourceText to shared location and IsCodeBl…
Copilot Oct 12, 2025
d7e73cb
Address code review feedback: refactor classification logic and trivi…
Copilot Oct 12, 2025
853a882
Fix test
CyrusNajmabadi Oct 12, 2025
7d323f6
Extract out helpers
CyrusNajmabadi Oct 12, 2025
f61135c
in progrss
CyrusNajmabadi Oct 12, 2025
159154e
in progress
CyrusNajmabadi Oct 12, 2025
5528b95
in progress
CyrusNajmabadi Oct 12, 2025
86eb5f7
Simplify
CyrusNajmabadi Oct 12, 2025
41d150f
Use builder
CyrusNajmabadi Oct 12, 2025
ff3cbf2
In progress
CyrusNajmabadi Oct 12, 2025
8b04842
In progress
CyrusNajmabadi Oct 12, 2025
e98c5dc
in progress
CyrusNajmabadi Oct 12, 2025
eb73a40
in progress
CyrusNajmabadi Oct 12, 2025
dae09d7
in progress
CyrusNajmabadi Oct 12, 2025
325302f
in progress
CyrusNajmabadi Oct 12, 2025
800eacb
in progress
CyrusNajmabadi Oct 12, 2025
71f7908
IN progress
CyrusNajmabadi Oct 12, 2025
709d770
in progress
CyrusNajmabadi Oct 12, 2025
8e237ac
Need to keep all text in
CyrusNajmabadi Oct 12, 2025
8a1a590
Update test
CyrusNajmabadi Oct 12, 2025
06110dd
Working
CyrusNajmabadi Oct 12, 2025
9315c8b
Update tests
CyrusNajmabadi Oct 12, 2025
07c605d
Update tests
CyrusNajmabadi Oct 12, 2025
6f6e8bb
Update tests
CyrusNajmabadi Oct 12, 2025
511b93b
Bacckground fill
CyrusNajmabadi Oct 12, 2025
c05508e
Split test and non-test handling
CyrusNajmabadi Oct 12, 2025
42ee2b4
The hard way
CyrusNajmabadi Oct 12, 2025
0bf0081
Fix tests
CyrusNajmabadi Oct 12, 2025
831640f
Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Comp…
CyrusNajmabadi Oct 12, 2025
c261366
remove
CyrusNajmabadi Oct 13, 2025
4839e64
Doc
CyrusNajmabadi Oct 13, 2025
222b883
Pass value down
CyrusNajmabadi Oct 13, 2025
bbce912
Add the translated values
CyrusNajmabadi Oct 13, 2025
9564bc7
Add IDE/Compiler specific custom instructions (#80617)
akhera99 Oct 13, 2025
16883a5
Handle potential null in extension lookup (#80621)
333fred Oct 13, 2025
891b50e
Avoid deep recursion in PatternExplainer.VisitPathsToNode (#80685)
AlekseyTs Oct 14, 2025
6e00487
Disable CS8002 warning when targeting .NET Core (#80596)
Copilot Oct 14, 2025
95400eb
Add limited support for binarylogger to MSBuildWorkspace (#80120)
JoeRobich Oct 14, 2025
f08f003
Fix rename conflict detection for methods differing by ref/out/in
Copilot Oct 14, 2025
aebf02c
Make ref kind distinction language-aware for C# and VB
Copilot Oct 14, 2025
2baf56f
Make distinguishRefKind parameter non-optional and pass explicitly in C#
Copilot Oct 14, 2025
9cd28f0
Avoid using "1" as a test assembly name in VB NoPia tests (#80689)
AlekseyTs Oct 14, 2025
5b55ed4
Add comment to improve localization
DoctorKrolic Oct 5, 2025
225ca71
Ensure `LspWorkspaceManager` returns solutions without misc document …
dibarbet Oct 14, 2025
942749c
Add regeneration instructions to VB Syntax.xml (#80703)
Copilot Oct 14, 2025
0789ca5
Disallow simplifying `if` operator in case of `return` when `true`/`f…
DoctorKrolic Oct 14, 2025
1e9767d
Remove anonymous type member renaming block and add tests
Copilot Oct 14, 2025
5d867f8
Add inline rename test for anonymous type members
Copilot Oct 14, 2025
4e9d0ef
Remove unused error message resource for anonymous type renaming
Copilot Oct 14, 2025
fa9128d
Update src/EditorFeatures/CSharpTest/Rename/CSharpInlineRenameService…
CyrusNajmabadi Oct 14, 2025
32a3766
Add `HelpLinkUri` to `CodeStyleConfigFileGenerator` (#77227)
xtqqczze Oct 14, 2025
93f2ebf
Add LocalRewritingValidator check for BoundUnconvertedObjectCreationE…
Copilot Oct 15, 2025
d8df310
Revert "Go To Definition: Automatically navigate to user code when mu…
peterwald Oct 15, 2025
e117e18
Update docs with clearer RoslynDeployment info and fix outdated proje…
Copilot Oct 14, 2025
51fa6c3
Update docs for building runtime with local Roslyn (#80725)
RikkiGibson Oct 15, 2025
77de555
Add visualizer support for the StringBuilder class in VS (#80735)
mpeyrotc Oct 15, 2025
701f4d6
Extensions: fix betterness with params and issues with `this` modifie…
jcouv Oct 15, 2025
f5dcba8
Improve XML documentation clarity for IMethodSymbol.Arity property (#…
Copilot Oct 16, 2025
ecd69b8
Update repository to .NET 10 RC2 (#80738)
Copilot Oct 16, 2025
0085047
Add code style elements to doc comment completion
Copilot Oct 16, 2025
6f768fe
Trim whitespace in rename dialog input to prevent invalid identifiers
Copilot Oct 16, 2025
a09d02e
Improve comment clarity in IdentifierText setter
Copilot Oct 16, 2025
cf6be3f
Remove all whitespace from identifiers, not just trim ends
Copilot Oct 16, 2025
4b0d880
Simplify
CyrusNajmabadi Oct 16, 2025
d5cd110
Avoid deep recursion in NullabilityRewriter.VisitBinaryPattern (#80711)
AlekseyTs Oct 16, 2025
0628585
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
c6e581c
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
39264e9
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
0b9ce5f
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
995392b
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
c57b790
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
f849563
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
7c05d4b
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
3344196
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
0bc095a
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
02441df
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
effcf90
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
1cd49d7
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
a77fec6
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
36dc7f5
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
03cf38c
Simplify code fixers
CyrusNajmabadi Oct 16, 2025
d909cc0
Reove
CyrusNajmabadi Oct 16, 2025
e0e4c38
Revert
CyrusNajmabadi Oct 16, 2025
8ae9fe9
Revert
CyrusNajmabadi Oct 16, 2025
bcef4ec
Fix
CyrusNajmabadi Oct 16, 2025
a698a3f
Revert
CyrusNajmabadi Oct 16, 2025
e995eaa
Revert
CyrusNajmabadi Oct 16, 2025
bea1167
Fix tests
CyrusNajmabadi Oct 16, 2025
3e16ed9
Fix tests
CyrusNajmabadi Oct 16, 2025
51177e3
Add analyzer to remove unnecessary nullable suppressions
CyrusNajmabadi Sep 22, 2025
78cf268
Make into static class
CyrusNajmabadi Sep 22, 2025
b02760c
Add fixer
CyrusNajmabadi Sep 22, 2025
0a9af78
Fix al
CyrusNajmabadi Sep 22, 2025
77c35dd
Add tests
CyrusNajmabadi Sep 22, 2025
21dd821
Process entire doc at once
CyrusNajmabadi Sep 22, 2025
7e6c008
In progress
CyrusNajmabadi Sep 22, 2025
a07d4a2
performance
CyrusNajmabadi Sep 22, 2025
9e9cd2b
Syntax only
CyrusNajmabadi Sep 22, 2025
b4a6e0f
Add tests
CyrusNajmabadi Sep 22, 2025
32e166d
Remove helper
CyrusNajmabadi Sep 22, 2025
fe87597
Do not suppress warnings
CyrusNajmabadi Sep 22, 2025
5c1fe83
Change span
CyrusNajmabadi Sep 22, 2025
17c4a41
Spans to check
CyrusNajmabadi Sep 22, 2025
79acd31
Check whole span
CyrusNajmabadi Sep 22, 2025
e752885
No need for check
CyrusNajmabadi Sep 22, 2025
fed513f
Improving fixer
CyrusNajmabadi Sep 23, 2025
8bf90f2
Fixes
CyrusNajmabadi Oct 16, 2025
33d67be
Fix test
CyrusNajmabadi Oct 16, 2025
2f95d3c
Update src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
CyrusNajmabadi Oct 16, 2025
ceee528
Fix
CyrusNajmabadi Oct 16, 2025
c866f05
Update src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems
CyrusNajmabadi Oct 16, 2025
25bfa73
Update src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
CyrusNajmabadi Oct 16, 2025
8134d75
Update tests
CyrusNajmabadi Oct 16, 2025
b99275b
Add missing rule
CyrusNajmabadi Oct 16, 2025
b120e27
Add tests for file keyword completion after extern keyword
Copilot Oct 16, 2025
bd6850f
Fix FileKeywordRecommender to not offer 'file' after 'extern' keyword
Copilot Oct 16, 2025
9b3ecb1
Fix indentation in FileKeywordRecommenderTests
Copilot Oct 16, 2025
14cddd4
Refactor: Move extern check to s_validModifiers
Copilot Oct 16, 2025
6419c22
Compute if a doc is generated code or not in OOP not on the host
CyrusNajmabadi Oct 14, 2025
7cc83f7
Fix
CyrusNajmabadi Oct 16, 2025
3020e07
[main] Source code updates from dotnet/dotnet (#80654)
dotnet-maestro[bot] Oct 17, 2025
2be7b9d
Update dependencies from https://github.com/maestro-auth-test/dotnet …
dotnet-maestro[bot] Oct 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 15 additions & 12 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
**Building**:
- `build.sh` - Full solution build
- `dotnet build Compilers.slnf` - Compiler-only build
- Run `dotnet msbuild <path to csproj> /t:UpdateXlf` when .resx files are modified to update corresponding .xlf files
- `dotnet msbuild <path to csproj> /t:UpdateXlf` - Update .xlf files when their corresponding .resx file is modified

**Testing**:
- `test.sh` - Run all tests
Expand All @@ -24,7 +24,8 @@

**Formatting**:
- Whitespace formatting preferences are stored in the `.editorconfig` file
- Run `dotnet format whitespace -f . --include ` followed by the relative paths to changed .cs and .vb files to apply formatting preferences
- When running `dotnet format whitespace` use the `--folder .` option followed by `--include <relative path to file>` to avoid a design-time build.
- `dotnet format whitespace --folder . --include <relative path to file>` - Applies formatting preferences to a particular .cs or .vb file

## Code Patterns

Expand Down Expand Up @@ -52,21 +53,23 @@ var symbolInfo = semanticModel.GetSymbolInfo(expression);
- Use `UseExportProvider` for MEF services
- Test utilities in `Microsoft.CodeAnalysis.Test.Utilities`
- Language-specific test bases: `CSharpTestBase`, `VisualBasicTestBase`
- Add `[WorkItem("https://github.com/dotnet/roslyn/issues/issueNumber")]` attribute to tests that fix specific GitHub issues

## Critical Integration Points

**Language Server Protocol**: `src/LanguageServer/` contains LSP implementation used by VS Code extension
**ServiceHub**: Remote services (`src/Workspaces/Remote/`) run out-of-process for performance
**Analyzers**: `src/Analyzers/` for static analysis, separate from `src/RoslynAnalyzers/` (internal tooling)
**VSIX Packaging**: Multiple deployment targets - `src/VisualStudio/Setup/` for main VS integration
- **Language Server Protocol**: `src/LanguageServer/` contains LSP implementation used by VS Code extension
- **ServiceHub**: Remote services (`src/Workspaces/Remote/`) run out-of-process for performance
- **Analyzers**: `src/Analyzers/` for static analysis, separate from `src/RoslynAnalyzers/` (internal tooling)
- **VSIX Packaging**: Multiple deployment targets - `src/VisualStudio/Setup/` for main VS integration

## Key Conventions

**Namespace Strategy**: `Microsoft.CodeAnalysis.[Language].[Area]` (e.g., `Microsoft.CodeAnalysis.CSharp.Formatting`)
**File Organization**: Group by feature area, separate language-specific implementations
**Immutability**: All syntax trees, documents, and solutions are immutable - create new instances for changes
**Cancellation**: Always thread `CancellationToken` through async operations
**MEF Lifecycle**: Use `[ImportingConstructor]` with obsolete attribute for MEF v2 compatibility
- **Namespace Strategy**: `Microsoft.CodeAnalysis.[Language].[Area]` (e.g., `Microsoft.CodeAnalysis.CSharp.Formatting`)
- **File Organization**: Group by feature area, separate language-specific implementations
- **Immutability**: All syntax trees, documents, and solutions are immutable - create new instances for changes
- **Cancellation**: Always thread `CancellationToken` through async operations
- **MEF Lifecycle**: Use `[ImportingConstructor]` with obsolete attribute for MEF v2 compatibility
- **PROTOTYPE Comments**: Only used to track follow-up work in feature branches and are disallowed in main branch

## Common Gotchas

Expand All @@ -82,4 +85,4 @@ var symbolInfo = semanticModel.GetSymbolInfo(expression);
- `docs/contributing/Building, Debugging, and Testing on Unix.md` - Development setup
- `src/Compilers/Core/Portable/` - Core compiler APIs
- `src/Workspaces/Core/Portable/` - Workspace object model
- Solution filters: `Roslyn.sln`, `Compilers.slnf`, `Ide.slnf` for focused builds
- Solution filters: `Roslyn.sln`, `Compilers.slnf`, `Ide.slnf` for focused builds
95 changes: 95 additions & 0 deletions .github/instructions/Compiler.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Roslyn Compiler Instructions for AI Coding Agents

---
applyTo: "src/{Compilers,Dependencies,ExpressionEvaluator,Tools}/**/*.{cs,vb}"
---

## Architecture Overview

Roslyn follows a **layered compiler architecture**:
- **Lexer → Parser → Syntax Trees → Semantic Analysis → Lowering/Rewriting → Symbol Tables → Emit**
- Core abstraction: `Compilation` is immutable and reusable. Create new compilations via `AddSyntaxTrees()`, `RemoveSyntaxTrees()`, `ReplaceSyntaxTree()` for incremental changes
- **Internal vs Public APIs**: Use `InternalSyntax` namespace for performance-critical parsing; `Microsoft.CodeAnalysis` for public consumption

### Key Directories
- `src/Compilers/Core/Portable/` - Language-agnostic compiler infrastructure
- `src/Compilers/CSharp/Portable/` - C# compiler implementation
- `src/Compilers/VisualBasic/Portable/` - VB compiler implementation
- `src/Dependencies/` - High-performance collections (`PooledObjects`, `Threading`)
- `src/ExpressionEvaluator/` - Debugger expression evaluation (uses special `LexerMode.DebuggerSyntax`)
- `src/Tools/` - Compiler tooling (BuildBoss, format tools, analyzers)

## Essential Patterns

### Test Structure Convention
Inherit from language-specific base classes: `CSharpTestBase` for C#, `VisualBasicTestBase` for VB
```cs
public class MyTests : CSharpTestBase
{
[Fact]
public void TestMethod()
{
var comp = CreateCompilation(sourceCode);
// Test compilation, symbols, diagnostics
}
}
```

### Memory Management
- **Avoid LINQ in hot paths** - use manual enumeration or `struct` enumerators
- **Avoid `foreach` over collections without struct enumerators**
- **Use object pools extensively** - see patterns in `src/Dependencies/PooledObjects/`
- **Prefer `Debug.Assert()` over exceptions** for internal validation

## Build & Test Workflows

### Essential Build Commands
```powershell
# Full build (use VS Code tasks when available)
./build.sh

# Build specific components
dotnet build Compilers.slnf # Compiler-only build
dotnet build src/Compilers/CSharp/csc/AnyCpu/ # C# compiler

# Generate compiler code after changes
dotnet run --file eng/generate-compiler-code.cs
```

### Testing Strategy
- **Unit tests**: Test individual compiler phases (lexing, parsing)
- **Compilation tests**: Create `Compilation` objects and verify symbols/diagnostics
- **Cross-language patterns**: Many test patterns work for both C# and VB with minor syntax changes

## Debugger Integration

**Expression Evaluator** uses special parsing modes:
- `LexerMode.DebuggerSyntax` for expression evaluation
- `IsInFieldKeywordContext` flag for context-aware parsing
- `ConsumeFullText` parameter for complete expression parsing

## MSBuild Integration

Compiler tasks are in `src/Compilers/Core/MSBuildTask/`:
- `Csc.cs` - C# compiler task
- `Vbc.cs` - VB compiler task
- `ManagedCompiler.cs` - Base compiler task functionality

## Performance Considerations

1. **Lexer/Parser optimizations**: Use `InternalSyntax` types for performance-critical code
2. **Immutable data structures**: Roslyn heavily uses immutable collections and copy-on-write semantics
3. **Caching**: `Compilation` objects cache semantic information - reuse when possible
4. **Threading**: Most compiler operations are thread-safe through immutability

## Symbol Resolution

Navigate the symbol hierarchy:
```cs
var compilation = CreateCompilation(source);
var globalNamespace = compilation.GlobalNamespace;
var typeSymbol = globalNamespace.GetTypeMembers("MyClass").Single();
var methodSymbol = typeSymbol.GetMembers("MyMethod").Single();
```

Symbol equality is complex due to generics and substitution - always test with multiple generic scenarios.
154 changes: 154 additions & 0 deletions .github/instructions/IDE.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
applyTo: "src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}"
---

# Roslyn IDE Development Guide

This guide provides essential knowledge for working effectively with Roslyn's IDE-focused codebase.

## Architecture Overview

Roslyn uses a **layered service architecture** built on MEF (Managed Extensibility Framework):

- **Workspaces** (`src/Workspaces/`): Core abstractions - `Workspace`, `Solution`, `Project`, `Document`
- **Features** (`src/Features/`): Language-agnostic IDE features (refactoring, navigation, completion)
- **LanguageServer** (`src/LanguageServer/`): Shared LSP protocol implementation and Roslyn LSP executable
- **EditorFeatures** (`src/EditorFeatures/`): VS Editor integration and text manipulation
- **VisualStudio** (`src/VisualStudio/`): Visual Studio-specific implementations

### Service Resolution Pattern

```csharp
// Get workspace services
var service = workspace.Services.GetRequiredService<IMyWorkspaceService>();

// Get language-specific services
var csharpService = workspace.Services.GetLanguageServices(LanguageNames.CSharp)
.GetRequiredService<IMyCSharpService>();

// In tests, use ExportProvider directly
var service = ExportProvider.GetExportedValue<IMyService>();
```

### MEF Export Patterns

```csharp
// Workspace service
[ExportWorkspaceService(typeof(IMyService)), Shared]
internal class MyService : IMyService { }

// Language service
[ExportLanguageService(typeof(IMyService), LanguageNames.CSharp), Shared]
internal class CSharpMyService : IMyService { }

// Always use ImportingConstructor with obsolete warning
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public MyService(IDependency dependency) { }
```

## Key Development Patterns

### TestAccessor Pattern
For exposing internal state to tests without making it public:

```csharp
internal class ProductionClass
{
private int _privateField;

internal TestAccessor GetTestAccessor() => new(this);

internal readonly struct TestAccessor
{
private readonly ProductionClass _instance;
internal TestAccessor(ProductionClass instance) => _instance = instance;
internal ref int PrivateField => ref _instance._privateField;
}
}
```

### Diagnostic Analyzer Structure
```csharp
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public sealed class MyAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor s_rule = new(
"MyAnalyzer001", "Title", "Message format", "Category",
DiagnosticSeverity.Warning, isEnabledByDefault: true);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
=> ImmutableArray.Create(s_rule);

public override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.ClassDeclaration);
}
}
```

## Essential Build & Test Commands

```bash
# Full build
.build.sh

# Run specific test project
dotnet test src/EditorFeatures/Test/

# Build with analyzers
.build.sh -testUsedAssemblies

# Generate compiler code (if changing syntax)
dotnet run --file eng/generate-compiler-code.cs
```

## Working with Tests

### Test Workspace Creation
```csharp
[UseExportProvider]
public class MyTests
{
[Fact]
public async Task TestSomething()
{
var workspace = EditorTestWorkspace.CreateCSharp("class C { }");
var document = workspace.Documents.Single();
// Test logic here
}
}
```

### Common Test Utilities
- `DescriptorFactory.CreateSimpleDescriptor()` - Create test diagnostic descriptors
- `VerifyCS.VerifyAnalyzerAsync()` - Verify C# analyzer behavior
- `TestWorkspace.CreateCSharp()` - Create test workspaces
- `UseExportProviderAttribute` - Required for MEF-dependent tests

## Coding Conventions

### Performance Rules
- **Avoid LINQ in hot paths** - Use manual loops in compiler/analyzer code
- **Avoid `foreach` over non-struct enumerators** - Use `for` loops or `.AsSpan()`
- **Use object pooling** - See `ObjectPool<T>` usage patterns
- **Prefer `ReadOnlySpan<T>`** over `IEnumerable<T>` for performance-critical APIs

### Naming Conventions
- Private fields: `_camelCase`
- Internal test accessors: `GetTestAccessor()` returning `TestAccessor` struct
- Diagnostic IDs: Consistent prefixes (RS, CA, IDE followed by numbers)
- MEF exports: Match interface names without "I" prefix

### Resource Management
- MEF services are automatically disposed by the container
- Use `TestAccessor` pattern instead of `internal` accessibility for test-only APIs
- Always implement `IDisposable` for stateful services

## Common Gotchas

- **ImportingConstructor must be marked `[Obsolete]`** with `MefConstruction.ImportingConstructorMessage`
- **Use `Contract.ThrowIfNull()`** instead of manual null checks in public APIs
- **TestAccessor calls are forbidden in production code** - enforced by analyzer RS0043
- **Language services must be exported with specific language name** - don't use generic exports
- **Workspace changes must use immutable updates** - call `Workspace.SetCurrentSolution()` appropriately
4 changes: 2 additions & 2 deletions Roslyn.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.0.11101.28 d18.0
# Visual Studio Version 17
VisualStudioVersion = 17.14.36511.14 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynDeployment", "src\Deployment\RoslynDeployment.csproj", "{600AF682-E097-407B-AD85-EE3CED37E680}"
EndProject
Expand Down
Loading