Fix right side panel C# code viewer for Roslyn compilation#95
Merged
Fix right side panel C# code viewer for Roslyn compilation#95
Conversation
Co-authored-by: snakex64 <39806655+snakex64@users.noreply.github.com>
Co-authored-by: snakex64 <39806655+snakex64@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix right side menu for C# code preview
Fix right side panel C# code viewer for Roslyn compilation
Jan 5, 2026
Collaborator
|
@copilot No need to store the generated C#, we can build on the fly. Also, explore the possibility of getting only the result of the method build (the SyntaxNode) and only using that to create the string, this would prevent having to do string manipulation to find the method in the whole class |
- Remove _lastGeneratedSourceCode field (no longer storing generated code) - Replace GetGeneratedCSharpCode() with on-the-fly generation using RoslynGraphBuilder - Get MethodDeclarationSyntax directly from RoslynGraphBuilder.BuildMethod() - Convert syntax node to string using NormalizeWhitespace().ToFullString() - Eliminate complex string parsing logic - now uses Roslyn's syntax tree directly Co-authored-by: snakex64 <39806655+snakex64@users.noreply.github.com>
Contributor
Author
Done in d72b6bf. The implementation now:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
The right side panel stopped working after migrating from expression tree generation to Roslyn compilation. The viewer was calling the old
GetBodyAsCsAndMsilCode()method which relied on expression tree APIs.Changes
Project.cs: Added
GetGeneratedCSharpCode()method that builds C# code on-the-fly usingRoslynGraphBuilder. Gets theMethodDeclarationSyntaxdirectly from the graph builder and converts it to string using Roslyn'sNormalizeWhitespace().ToFullString(). No storage of generated code needed.SourceViewer.razor: Replaced expression tree-based code extraction with on-demand Roslyn code generation. IL Code tab now shows placeholder message.
E2E Tests: Added
SourceViewerTests.cscovering panel display, null method handling, and method switching scenarios.Implementation
The C# code generation now uses Roslyn's syntax tree API directly instead of string parsing:
This approach is cleaner and more efficient - it generates code only when requested and uses Roslyn's built-in syntax tree APIs instead of complex string manipulation.
Screenshots
Generated C# Code Display

IL Code Placeholder

Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.