-
Notifications
You must be signed in to change notification settings - Fork 0
Simplify template parameters to single FullTaskName, add analyzer and… #12
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
Conversation
… error handling, include changelog and migration file
WalkthroughThe PR refactors the template configuration to use a unified Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The PR spans multiple files across configuration, infrastructure, and testing layers, but most changes follow consistent patterns: parameter restructuring through derived values, straightforward utility addition, and property initialization updates. The primary complexity lies in understanding the template configuration refactoring and verifying the regex patterns for Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 3
🧹 Nitpick comments (3)
Frends.Template/Frends.Echo.Execute/migration.json (1)
7-7: Empty Description field in migration metadata.The Description field is empty for the 1.0.0 migration entry. Consider adding a brief description such as "Initial release" or "Initial implementation" to document the purpose of this migration version.
Apply this diff to add a description:
- "Description": "", + "Description": "Initial release",Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (1)
40-41: Consider using ArgumentException for input validation.While the validation correctly prevents negative repeat counts, using
ArgumentExceptionorArgumentOutOfRangeExceptionwould be more semantically appropriate for parameter validation than the genericException.Apply this diff to use a more specific exception type:
- if (input.Repeat < 0) - throw new Exception("Repeat count cannot be negative."); + if (input.Repeat < 0) + throw new ArgumentOutOfRangeException(nameof(input.Repeat), "Repeat count cannot be negative.");Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs (1)
8-8: Consider removing or clarifying the TODO comment.The current test implementation uses
Repeat = -1to trigger validation exceptions, which is a reasonable approach for testing error handling. If this scenario is acceptable, the TODO can be removed; otherwise, clarify what additional scenarios are needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
Frends.Template/.template.config/template.json(3 hunks)Frends.Template/CHANGELOG.md(1 hunks)Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs(1 hunks)Frends.Template/Frends.Echo.Execute.Tests/GlobalSuppressions.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Definitions/Options.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs(3 hunks)Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.csproj(1 hunks)Frends.Template/Frends.Echo.Execute/GlobalSuppressions.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs(1 hunks)Frends.Template/Frends.Echo.Execute/migration.json(1 hunks)Frends.Template/workflows/Execute_build_and_test_on_main.yml(1 hunks)Frends.Template/workflows/Execute_build_and_test_on_push.yml(1 hunks)Frends.Template/workflows/Execute_release.yml(1 hunks)README.md(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
Frends.*/Frends.*/*.cs
⚙️ CodeRabbit configuration file
Frends.*/Frends.*/*.cs: Ensure every public method and class:
- Has
and XML comments
- If the documentation is very long then it can also use element
- Follows Microsoft C# code conventions
- Uses semantic task result documentation (e.g., Success, Error, Data)
Frends.*/Frends.*/*.cs: Validate all task result classes include:
- Success (bool)
- Task-specific return value (e.g. Data, FilePaths)
- Error object with Message and AdditionalInfo
- Ensure result structure is flat, simple, and avoids 3rd-party types.
- Use dynamic or JToken only when the structure is unknown.
Files:
Frends.Template/Frends.Echo.Execute/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute/Frends.Echo.Execute.csFrends.Template/Frends.Echo.Execute.Tests/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs
Frends.*/**/*.cs
⚙️ CodeRabbit configuration file
Frends.*/**/*.cs: Code must follow Microsoft C# coding standards, including:
- PascalCase for public members and task parameters
- Proper naming for abbreviations (Csv, Url, Api)
- Use of var only when type is obvious
- Clean structure and no unused code
Files:
Frends.Template/Frends.Echo.Execute/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.csFrends.Template/Frends.Echo.Execute/Frends.Echo.Execute.csFrends.Template/Frends.Echo.Execute/Definitions/Options.csFrends.Template/Frends.Echo.Execute.Tests/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs
Frends.*/CHANGELOG.md
⚙️ CodeRabbit configuration file
Frends.*/CHANGELOG.md: Validate format against Keep a Changelog (https://keepachangelog.com/en/1.0.0/)
Include all functional changes and indicate breaking changes with upgrade notes.
Avoid notes like "refactored xyz" unless it affects functionality.
Files:
Frends.Template/CHANGELOG.md
Frends.*/Frends.*/*.csproj
⚙️ CodeRabbit configuration file
Frends.*/Frends.*/*.csproj: Ensure the .csproj targets .NET 6 or 8, uses the MIT license, and includes the following fields:
= Frends
= true
= MIT
Follow Microsoft C# project file conventions.
Files:
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.csproj
Frends.*/Frends.*.Tests/*
⚙️ CodeRabbit configuration file
Frends.*/Frends.*.Tests/*: Confirm unit tests exist and provide at least 80% coverage.
Tests should:
- Load secrets via dotenv
- Use mocking where real systems can't be simulated
- Follow Microsoft unit testing naming and structuring conventions
Files:
Frends.Template/Frends.Echo.Execute.Tests/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs
🧬 Code graph analysis (3)
Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (4)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (2)
Echo(13-57)Result(25-56)Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs (1)
Options(49-53)Frends.Template/Frends.Echo.Execute/Definitions/Options.cs (1)
Options(9-33)Frends.Template/Frends.Echo.Execute/Definitions/Error.cs (1)
Error(6-20)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (1)
Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (1)
ErrorHandler(9-41)
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs (2)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (1)
Echo(13-57)Frends.Template/Frends.Echo.Execute/Definitions/Options.cs (1)
Options(9-33)
🔇 Additional comments (24)
Frends.Template/Frends.Echo.Execute/GlobalSuppressions.cs (1)
9-9: LGTM: Documentation suppression aligns with custom analyzer approach.The suppression of SA1600 is appropriate since FrendsTaskAnalyzers (added to the .csproj) will handle documentation validation.
Frends.Template/CHANGELOG.md (1)
5-7: LGTM: Correct changelog category.Using "Added" for initial implementation follows the Keep a Changelog format correctly.
README.md (2)
37-37: LGTM: Simplified template command.The updated command using a single
--FullTaskNameparameter simplifies the template usage and aligns with the template.json changes.
66-68: LGTM: Clear template option documentation.The template options section accurately documents the new FullTaskName parameter with its format and default value.
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.csproj (2)
34-36: LGTM: Correct use of AdditionalFiles for metadata.Changing FrendsTaskMetadata.json to AdditionalFiles enables the FrendsTaskAnalyzers to access and validate the metadata during build.
40-41: LGTM: Proper packaging of migration and changelog files.The migration.json and CHANGELOG.md files are correctly configured to be included in the NuGet package root, as required by the coding guidelines.
Frends.Template/Frends.Echo.Execute.Tests/GlobalSuppressions.cs (2)
3-3: LGTM: Standard test project suppressions.The SA0001 suppression is appropriate for test projects and follows Frends documentation guidelines.
11-11: LGTM: File header suppression for tests.The SA1633 suppression for file headers is standard for test projects and aligns with Frends documentation guidelines.
Frends.Template/.template.config/template.json (2)
17-23: LGTM: Simplified template parameter.The new FullTaskName parameter consolidates the previous separate parameters into a single, more intuitive input. The format "Frends.ClassName.MethodName" is clear and follows Frends naming conventions.
24-35: LGTM: Derived symbols reduce user input.Converting className and taskName to derived symbols eliminates redundant user input and ensures consistency between the FullTaskName and its components.
Frends.Template/workflows/Execute_build_and_test_on_main.yml (1)
17-17: LGTM: Enabling strict analyzers improves code quality.Adding
strict_analyzers: trueenables stricter analyzer checks in the CI/CD pipeline, which aligns with the addition of FrendsTaskAnalyzers and helps catch issues earlier.Frends.Template/workflows/Execute_release.yml (1)
12-12: LGTM! Enabling strict analyzers in release workflow.This change aligns with the PR's goal of introducing stricter analyzer checks across all workflows.
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (2)
6-6: LGTM! Helper namespace imported for centralized error handling.The using directive correctly references the new ErrorHandler helper class.
52-54: LGTM! Error handling properly delegated to centralized handler.The error handling is correctly delegated to
ErrorHandler.Handle, which provides consistent error processing based on theOptionsconfiguration.Frends.Template/workflows/Execute_build_and_test_on_push.yml (1)
17-17: LGTM! Enabling strict analyzers in build/test workflow.This change aligns with the PR's goal of introducing stricter analyzer checks across all workflows.
Frends.Template/Frends.Echo.Execute/Definitions/Options.cs (2)
24-24: LGTM! Property initializer ensures runtime default.The initializer guarantees the property defaults to
trueat runtime, complementing the[DefaultValue]attribute which serves the design-time/UI layer.
32-32: LGTM! Property initializer ensures runtime default.The initializer guarantees the property defaults to an empty string at runtime, complementing the
[DefaultValue]attribute which serves the design-time/UI layer.Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (3)
6-16: LGTM! Complete XML documentation provided.The class and method have proper
<summary>,<param>, and<returns>XML documentation as required by the coding guidelines.
29-39: LGTM! Error result construction follows task result requirements.The error result properly includes:
Success = falseErrorobject withMessageandAdditionalInfo- Flat structure as required by coding guidelines
17-27: Critical:throw ex;loses stack trace information.Line 26 uses
throw ex;which resets the stack trace. Usethrow;to preserve the original exception's stack trace for better debugging.Apply this diff to preserve stack trace:
if (!string.IsNullOrEmpty(options.ErrorMessageOnFailure)) { throw new Exception(options.ErrorMessageOnFailure, ex); } - throw ex; + throw;Likely an incorrect or invalid review comment.
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest..cs (4)
14-20: LGTM! Test correctly validates exception throwing behavior.The test properly verifies that an exception is thrown when
ThrowErrorOnFailureistrue.
22-29: LGTM! Test correctly validates failure result behavior.The test properly verifies that a failed
Resultis returned whenThrowErrorOnFailureisfalse.
31-40: LGTM! Test correctly validates custom error message.The test properly verifies that the custom error message is included in the thrown exception.
42-53: LGTM! Helper methods provide clear test data.The helper methods properly construct test inputs with documented invalid values to trigger error scenarios.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
|
Fix README to |
|
Fix README to Third-party licenses(hyphenate) |
|
Fix Execute.cs to |
|
Make errorhandler internal and remove all xml comments from this file (we dont need that) |
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
Frends.Template/Frends.Echo.Execute/Definitions/Connection.cs (1)
18-19: Remove redundant DefaultValue attribute.The
[DefaultValue("")]attribute is now redundant with the inline initializer= string.Empty;. Modern C# best practice is to use inline initialization for default values.Apply this diff to remove the redundant attribute:
[DisplayFormat(DataFormatString = "Text")] - [DefaultValue("")] public string ConnectionString { get; set; } = string.Empty;Frends.Template/Frends.Echo.Execute/Definitions/Error.cs (1)
1-1: Good refactor to strong typing, but consider serialization implications.The change from
dynamictoExceptionprovides better type safety and aligns with the TODO comment recommending strong typing. TheExceptiontype is a .NET built-in (not third-party), so it complies with the coding guidelines.Note that
Exceptionobjects may not serialize cleanly in all scenarios (e.g., JSON over HTTP). Consider documenting this limitation or providing guidance in the template TODO comment if Error objects will cross serialization boundaries.Also applies to: 19-21
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.cs (2)
8-20: TODO comment may be outdated.The test uses
Repeat = -1which IS a real invalid input scenario (triggers the validation at line 40 in Execute.cs). The TODO comment suggests adjusting to use "real invalid Input scenario," but this is already valid.Consider updating or removing the TODO comment.
14-40: Good test coverage of error-handling paths.The three test methods cover the main error-handling scenarios: throwing on failure, returning failed result, and custom error messages. The test design is clean and follows NUnit conventions.
Consider adding assertions to verify:
Error.AdditionalInfois populated in the failed result test (line 27)Error.Messagecontent in the failed result testExample:
var result = Echo.Execute(DefaultInput(), DefaultConnection(), options, CancellationToken.None); Assert.That(result.Success, Is.False); +Assert.That(result.Error, Is.Not.Null); +Assert.That(result.Error.AdditionalInfo, Is.Not.Null);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Definitions/Connection.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Definitions/Error.cs(2 hunks)Frends.Template/Frends.Echo.Execute/Definitions/Result.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs(4 hunks)Frends.Template/Frends.Echo.Execute/GlobalSuppressions.cs(1 hunks)Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs(1 hunks)Frends.Template/README.md(2 hunks)FrendsTaskTemplate.csproj(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- Frends.Template/README.md
🧰 Additional context used
📓 Path-based instructions (3)
Frends.*/**/*.cs
⚙️ CodeRabbit configuration file
Frends.*/**/*.cs: Code must follow Microsoft C# coding standards, including:
- PascalCase for public members and task parameters
- Proper naming for abbreviations (Csv, Url, Api)
- Use of var only when type is obvious
- Clean structure and no unused code
Files:
Frends.Template/Frends.Echo.Execute/Definitions/Error.csFrends.Template/Frends.Echo.Execute/Definitions/Connection.csFrends.Template/Frends.Echo.Execute/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute/Definitions/Result.csFrends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.csFrends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.csFrends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs
Frends.*/Frends.*/*.cs
⚙️ CodeRabbit configuration file
Frends.*/Frends.*/*.cs: Ensure every public method and class:
- Has
and XML comments
- If the documentation is very long then it can also use element
- Follows Microsoft C# code conventions
- Uses semantic task result documentation (e.g., Success, Error, Data)
Frends.*/Frends.*/*.cs: Validate all task result classes include:
- Success (bool)
- Task-specific return value (e.g. Data, FilePaths)
- Error object with Message and AdditionalInfo
- Ensure result structure is flat, simple, and avoids 3rd-party types.
- Use dynamic or JToken only when the structure is unknown.
Files:
Frends.Template/Frends.Echo.Execute/GlobalSuppressions.csFrends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.csFrends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs
Frends.*/Frends.*.Tests/*
⚙️ CodeRabbit configuration file
Frends.*/Frends.*.Tests/*: Confirm unit tests exist and provide at least 80% coverage.
Tests should:
- Load secrets via dotenv
- Use mocking where real systems can't be simulated
- Follow Microsoft unit testing naming and structuring conventions
Files:
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.cs
🧬 Code graph analysis (4)
Frends.Template/Frends.Echo.Execute/Definitions/Result.cs (1)
Frends.Template/Frends.Echo.Execute/Definitions/Error.cs (1)
Error(8-22)
Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.cs (2)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (1)
Echo(13-57)Frends.Template/Frends.Echo.Execute/Definitions/Connection.cs (1)
Connection(11-20)
Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (3)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (2)
Echo(13-57)Result(25-56)Frends.Template/Frends.Echo.Execute/Definitions/Result.cs (1)
Result(6-25)Frends.Template/Frends.Echo.Execute/Definitions/Error.cs (1)
Error(8-22)
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (1)
Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (1)
ErrorHandler(6-32)
🔇 Additional comments (10)
Frends.Template/Frends.Echo.Execute/GlobalSuppressions.cs (2)
9-9: LGTM! Appropriate suppression for custom analyzer integration.The SA1600 suppression is correctly configured to delegate documentation enforcement to the custom FrendsTaskAnalyzers, which aligns with the PR's goal of integrating analyzer-based checks. This allows internal/private members to remain undocumented while custom analyzers enforce documentation on public APIs as required by the coding guidelines.
12-12: LGTM! Standard file header suppression.The SA1633 suppression is appropriate for the template project structure and follows the established Frends documentation guidelines.
FrendsTaskTemplate.csproj (1)
5-5: LGTM! Version and framework updates are appropriate.The PackageVersion bump to 1.4.0 and TargetFramework update to net8.0 align with the PR objectives and template modernization.
Also applies to: 12-12
Frends.Template/Frends.Echo.Execute/Definitions/Result.cs (1)
23-23: LGTM! Documentation updated to match Error structure.The XML example now correctly reflects the updated Error.AdditionalInfo type and aligns with the changes in Error.cs.
Frends.Template/Frends.Echo.Execute/Frends.Echo.Execute.cs (4)
6-6: LGTM! Necessary import for centralized error handling.
11-11: LGTM! Documentation updates match PR requirements.The class summary and return documentation have been updated correctly as requested in PR comments.
Also applies to: 23-23
40-41: Good defensive validation.The negative repeat count validation prevents invalid input and provides clear error messaging.
52-54: Excellent refactor to centralize error handling.Delegating to
ErrorHandler.Handleprovides consistent error behavior across the task and simplifies maintenance.Frends.Template/Frends.Echo.Execute.Tests/ErrorHandlerTest.cs (1)
42-53: LGTM! Helper methods improve test readability.Frends.Template/Frends.Echo.Execute/Helpers/ErrorHandler.cs (1)
6-31: LGTM! Clean centralized error-handling implementation.The
ErrorHandlerclass provides consistent error-handling behavior:
- Correctly throws exceptions when
throwOnFailureis true (with optional custom message wrapper)- Builds failed
Resultobjects with properErrorstructure when not throwing- Error message composition handles both empty and non-empty
errorMessageOnFailurevaluesThe internal visibility and absence of XML comments align with PR comment requirements.
… error handling, include changelog and migration file
[]# Frends Task Pull Request
Summary
Review Checklist
1. Frends Task Project Files
Frends.*/Frends.*/*.csproj<PackageLicenseExpression>MIT</PackageLicenseExpression>)<Version><Authors>Frends</Authors><Description><RepositoryUrl><GenerateDocumentationFile>true</GenerateDocumentationFile>2. File: FrendsTaskMetadata.json
Frends.*/Frends.*/FrendsTaskMetadata.json3. File: README.md
Frends.*/README.md4. File: CHANGELOG.md
Frends.*/CHANGELOG.md5. File: migration.json
Frends.*/Frends.*/migration.json6. Source Code Documentation
Frends.*/Frends.*/*.cs<summary>XML comments<example>XML comments<frendsdocs>XML comments, if needed7. GitHub Actions Workflows
.github/workflows/*.yml*_test.yml*_main.yml*_release.yml8. Task Result Object Structure
Frends.*/Frends.*/*.csSuccess(bool)Additional Notes
Summary by CodeRabbit
Release Notes
New Features
FullTaskNameparameterImprovements
Tests
Chores