cobbr / Covenant

Covenant is a collaborative .NET C2 framework for red teamers.

Home Page:https://cobbr.io/Covenant.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Refactor .razor blazor components to use partial classes

Selora opened this issue · comments

Feature Request

Refactor large blazer components so their code section is in dedicated CSharp classes.

Large Blazer components are hard to debug. A breakpoint can only be set for the whole @code{...} section, and the behavior is erratic at best.

Detailed Problem

For example, if one wants to attach a debugger and inspect the values passed on to a task through the grunt interact menu, a "global breakpoint" can be set in the component in the @code {...} section of GruntInteract.razor. This will result in several false hit to whatever property is being accessed at a given time instead of being able to precisely target the OnInteract function.

Example of a 'debuggable' component

It is possible to externalize the component code in a partial class as highlighted here:

The resulting class can be debugged like a regular C# class. From my limited testing, just a cut/paste of whatever is inside the code section, and adding imports/using statement will work. Example. Intellisense does not like it one bit, and if there's any compilation error, it will result in a compiler-error-flood that makes C++ templating code errors pale in comparison, but just cut pasting and adding imports seems to work pretty well.

Definitely not all components would benefit from that, as some are quite small and contains very little logic.

Final thoughts

That needs stems from my limited understanding of the technologies used in this project.
I don't doubt there's much easier ways to troubleshoot how user interactions are consumed by the components, I'm still poking my way through this.

There might also be some ways to have a more targeted approach at debugging the @code{...} section of a component, however with Blazer Web Assembly gaining traction, getting a reliable source of information on server-side blazer components is quite time consuming.

Apologies if the format deviates from the template, it's kind of an unusual "feature request" and more a discussion about the design and how to achieve certain things.

My IDE is able to debug inside a component just fine.

image

Seems like a Visual Studio related issue. By switching to another IDE I'm indeed able to debug a component @code{...} section just fine.
As a bonus, I even get syntax coloring and code completion inside a .razor file, which seems to be too much for VS.

Closing the issue.
For posterity, JetBrains Rider, VSCode or VS 2022 preview will work just fine. Seems like my build of VS 2019 16.11 has some issues.