-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Definition generation on Requests and CSharp syntax formatting #35
base: main
Are you sure you want to change the base?
Conversation
galadril
commented
Jul 12, 2024
•
edited
Loading
edited
- Definition json generation on Requests
- CSharp / Json Syntax Formatting (and a copy button for easy copying)
- Copy buttons for Code / Definition
- Reordered `using` directives to place `System` at the top. - Reformatted `Document` object initialization for clarity. - Changed `StringField` to `TextField` for `request.body`, `response.body`, and `response.bodyAsJson` to handle large text data better.
Updated the following package versions in `WireMock.Net.Extensions.WireMockInspector.csproj`: - `WireMock.Net.Abstractions` from `1.5.24` to `1.5.60`. Updated the following package versions in `WireMockInspector.csproj`: - `Avalonia` from `11.0.6` to `11.0.11`. - `Avalonia.AvaloniaEdit` from `11.0.5` to `11.0.6`. - `Avalonia.Controls.DataGrid` from `11.0.6` to `11.0.11`. - `Avalonia.Desktop` from `11.0.6` to `11.0.11`. - `Avalonia.Svg` from `11.0.0.9` to `11.0.0.18`. - `Avalonia.Themes.Fluent` from `11.0.6` to `11.0.11`. - Conditional package `Avalonia.Diagnostics` for `Debug` configuration from `11.0.6` to `11.0.11`. - `Avalonia.ReactiveUI` from `11.0.6` to `11.0.11`. - `AvaloniaEdit.TextMate` from `11.0.5` to `11.0.6`. - `Fluid.Core` from `2.5.0` to `2.10.0`. - `TextMateSharp.Grammars` from `1.0.56` to `1.0.58`. - `WireMock.Net.RestClient` from `1.5.46` to `1.5.60`. These updates ensure the projects use the latest features, improvements, and bug fixes provided by these packages.
The namespace of the `CSharpFormatter` class has been changed from `WireMockInspector.ViewModels` to `WireMockInspector.CodeGenerators`. This reorganization better categorizes the class under a namespace that aligns with its functionality related to code generation.
- Added `FormatArray` method to `CSharpFormatter`. - Removed `MappingCodeGenerator` class and its methods. - Cleared `default_template.liquid` content. - Changed `EndNode` class visibility to private in `GraphConverter`. - Made several methods in `GraphConverter` private. - Removed unused imports from `MainWindowViewModel`. - Updated `SelectedTemplate` property initialization in `MainWindowViewModel`. - Added `JsonGenerator` property to `MainWindowViewModel`. - Added `CopyActualValue` command to `MappingCodeGeneratorViewModel`. - Updated `OutputCode` property in `MappingCodeGeneratorViewModel`. - Made formatting and visibility changes in `MatchDetailsViewModel`. - Made `luceneVersion` constant private in `SearchHelper`. - Updated XAML layouts in `MappingPage` and `RequestPage`. - Added `Definition` tab in `RequestPage` for JSON generator options.
- Updated `MarkdownCode` language identifier to "csharp" in `MainWindowViewModel.cs` and `MappingCodeGeneratorViewModel.cs`. - Refactored `CodeBlockViewer.cs` for better readability: - Restructured class to organize constructor and methods. - Updated `SetMarkdown` method to use `CSharpSyntaxHighlighter`. - Moved `DiffLineBackgroundRenderer` class to a separate file. - Added `CSharpSyntaxHighlighter` class in `CSharpSyntaxHighlighter.cs`. - Moved and refactored `DiffLineBackgroundRenderer` class to `DiffLineBackgroundRenderer.cs` for improved clarity and separation of concerns.
Hope you like the changes @cezarypiatek ;) |
I took your words for granted that it solves the issu |
Ok thanks, so this PR is going to take you a bit more time ;) |
- Removed `HttpStatusCodeToDescriptionConverter`, `RequestMethodToColorConverter`, and `ResponseCodeToColorConverter` from `WireMockInspector.ViewModels`. - Re-added the above converters in `WireMockInspector.Converters` for better modularity. - Updated namespace references in XAML files from `viewModels` to `converters`. - Introduced `XmlSyntaxHighlighter` in `WireMockInspector.Views.Transformer` for XML syntax highlighting. - Enhanced `CodeBlockViewer.cs` to support XML highlighting, improving readability. - Adjusted XAML files to use the new converter namespace, ensuring UI consistency.
This commit represents a significant refactoring and enhancement of the converter usage within the WireMockInspector application. Key changes include the relocation of converter classes (`EnumItemsConverter`, `GraphConverter`, `StringListConverter`, `StringMatchConverter`) from the `WireMockInspector.ViewModels` namespace to a new `WireMockInspector.Converters` namespace, improving modularity and clarity. New converter classes have been added, encapsulating the conversion logic for better reusability. Updates in various XAML files reflect these namespace changes, ensuring correct converter references in data-binding expressions. Additionally, unused `using` directives have been cleaned up, and a new `SettingsWrapperTemplateSelector` class has been introduced to enhance dynamic UI generation capabilities. These changes collectively aim to improve the maintainability and functionality of the application's UI data presentation.
- Adopted target-typed `new` expressions across various files for cleaner instantiation. - Enhanced graph drawing in `GraphConverter.cs` with streamlined object creation. - Simplified `XmlDocument` object instantiation in multiple files for conciseness. - Updated singleton patterns in converters and formatters to modern C# practices. - Improved XML content formatting in markdown with `.TryToReformat()` in `MainWindowViewModel.cs`. - Refined syntax highlighting in `CSharpSyntaxHighlighter.cs`, `JsonSyntaxHighlighter.cs`, and `XmlSyntaxHighlighter.cs` with updated regex patterns and object instantiation. - Added `XmlFormatter.cs` for better XML handling, including escaping, pretty-printing, and conversion utilities. - Adjusted `Fluid.Core` package version in `WireMockInspector.csproj` for compatibility or feature requirements.
Added XML formatting and styling
this.TextArea.TextView.LineTransformers.Add(new DiffLineBackgroundRenderer(md.oldTextLines)); | ||
if (md.lang == "csharp") | ||
{ | ||
this.TextArea.TextView.LineTransformers.Add(new CSharpSyntaxHighlighter()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax highliting should be handled automatically by Avalonia.Edit and I'm pretty sure it was working correctly so far (for json and csharp). Why did you implemented custom syntax highlighers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it was just all white, i didnt saw any syntax highliting.
Ignore my last comment, I was checking it on mobile and I thought it was in different thread (previous pr). |
I will try to fix those things later and integrated your changes. |
ok thanks Btw JsonCodeGenerator does have a bit different code then the other CodeGenerator Mainly on (re)formatting and escaping |
Ok, you added a dedicated json escaping function and a default template selector. It could be incorporated in the original implementation. The only thing that I don't understand is the code below, could you explain what's the purpose od that replace?
|