Add ITypeSymbol.UnionCaseTypes property - #84707
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new experimental Roslyn public API surface for unions by exposing union case types via ITypeSymbol.UnionCaseTypes, and wires it through the C# public model, VB implementation, and symbol wrappers, with baseline and test updates.
Changes:
- Introduces
ITypeSymbol.UnionCaseTypes(experimental) returning an empty array when the type is not a union. - Implements the new property in C# public symbols and VB symbols (VB returns empty since VB doesn’t support unions), plus forwards through metadata-as-source wrappers and code-generation symbols.
- Updates PublicAPI + SemanticSearch API lists and adds initial unit test coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationTypeSymbol.cs | Adds default UnionCaseTypes implementation for codegen symbols. |
| src/Tools/SemanticSearch/ReferenceAssemblies/Apis/Microsoft.CodeAnalysis.txt | Updates semantic-search reference API list to include the new getter. |
| src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs | Forwards UnionCaseTypes through the wrapped symbol. |
| src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb | Implements ITypeSymbol.UnionCaseTypes as empty (VB has no unions). |
| src/Compilers/CSharp/Test/CSharp15/UnionsTests.cs | Adds tests for the public API shape (basic union + non-union + VB view). |
| src/Compilers/CSharp/Portable/Symbols/PublicModel/TypeSymbol.cs | Implements ITypeSymbol.UnionCaseTypes for C# public symbols using UnionCaseTypesNoUseSiteDiagnostics. |
| src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs | Adds the new experimental UnionCaseTypes API with XML doc. |
| src/Compilers/Core/Portable/PublicAPI.Unshipped.txt | Registers the new experimental public API surface. |
RikkiGibson
approved these changes
Jul 30, 2026
333fred
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #84700.
Microsoft Reviewers: Open in CodeFlow