Remove unsafe generic-body convenience properties from OperationSyntax#16
Closed
Remove unsafe generic-body convenience properties from OperationSyntax#16
Conversation
Agent-Logs-Url: https://github.com/jonathanvdc/MLIR.NET/sessions/82d5d62a-af08-4a30-bfe4-e8c5412353e2 Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove unsafe generic-body convenience properties from OperationSyntax
Remove unsafe generic-body convenience properties from OperationSyntax
Mar 29, 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.
OperationSyntaxexposed properties (GenericBody,OperandList,SuccessorList,Regions,Attributes,TypeSignatureColonToken,TypeSignatureSyntax, and several derivatives) that implicitly calledBody.GetGenericBody(), which throws for custom assembly bodies. This hid the generic/custom body distinction and caused runtime exceptions in otherwise reasonable-looking code.Changes
OperationSyntax— Removed all 11 properties that delegated throughGetGenericBody(), including the explicit 7 from the issue scope plus audited derivatives:TryGetRawTypeSignature,RawTypeSignature,Operands,Successors.TryGetGenericBodyis retained as the safe, explicit accessor.Binder,GenericSyntaxBuilder,AssemblySyntaxBuilder— Updated to branch onTryGetGenericBody. Binder falls back to empty collections when no generic projection is available;AssemblySyntaxBuilder.BuildGenericBodythrowsInvalidOperationException(programming error);GenericSyntaxBuilderskips operations without a generic projection.Operation.TypeSignature— Updated to useTryGetGenericBodyinstead ofSyntax.RawTypeSignature.Tests — Updated all call sites to explicitly pattern-match on
Body:⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.