-
-
Notifications
You must be signed in to change notification settings - Fork 76
CU-868d85dv8 Fixing contact insert and adding delete message inbox api. #230
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| --- | ||
| description: "This file provides guidelines for writing clean, maintainable, and idiomatic C# code with a focus on functional patterns and proper abstraction." | ||
| --- | ||
| # Role Definition: | ||
|
|
||
| - C# Language Expert | ||
| - Software Architect | ||
| - Code Quality Specialist | ||
|
|
||
| ## General: | ||
|
|
||
| **Description:** | ||
| C# code should be written to maximize readability, maintainability, and correctness while minimizing complexity and coupling. Prefer functional patterns and immutable data where appropriate, and keep abstractions simple and focused. | ||
|
|
||
| **Requirements:** | ||
| - Write clear, self-documenting code | ||
| - Keep abstractions simple and focused | ||
| - Minimize dependencies and coupling | ||
| - Use modern C# features appropriately | ||
| - Use repository pattern utilizing Dapper at the Repo layer for database communication for SQL Server and Postgresql | ||
|
|
||
| ## Code Organization: | ||
|
|
||
| - Use meaningful names: | ||
| ```csharp | ||
| // Good: Clear intent | ||
| public async Task<Result<Order>> ProcessOrderAsync(OrderRequest request, CancellationToken cancellationToken) | ||
|
|
||
| // Avoid: Unclear abbreviations | ||
| public async Task<Result<T>> ProcAsync<T>(ReqDto r, CancellationToken ct) | ||
| ``` | ||
| - Separate state from behavior: | ||
| ```csharp | ||
| // Good: Behavior separate from state | ||
| public sealed record Order(OrderId Id, List<OrderLine> Lines); | ||
|
|
||
| public static class OrderOperations | ||
| { | ||
| public static decimal CalculateTotal(Order order) => | ||
| order.Lines.Sum(line => line.Price * line.Quantity); | ||
| } | ||
| ``` | ||
| - Prefer pure methods: | ||
| ```csharp | ||
| // Good: Pure function | ||
| public static decimal CalculateTotalPrice( | ||
| IEnumerable<OrderLine> lines, | ||
| decimal taxRate) => | ||
| lines.Sum(line => line.Price * line.Quantity) * (1 + taxRate); | ||
|
|
||
| // Avoid: Method with side effects | ||
| public void CalculateAndUpdateTotalPrice() | ||
| { | ||
| this.Total = this.Lines.Sum(l => l.Price * l.Quantity); | ||
| this.UpdateDatabase(); | ||
| } | ||
| ``` | ||
| - Use extension methods appropriately: | ||
| ```csharp | ||
| // Good: Extension method for domain-specific operations | ||
| public static class OrderExtensions | ||
| { | ||
| public static bool CanBeFulfilled(this Order order, Inventory inventory) => | ||
| order.Lines.All(line => inventory.HasStock(line.ProductId, line.Quantity)); | ||
| } | ||
| ``` | ||
| - Design for testability: | ||
| ```csharp | ||
| // Good: Easy to test pure functions | ||
| public static class PriceCalculator | ||
| { | ||
| public static decimal CalculateDiscount( | ||
| decimal price, | ||
| int quantity, | ||
| CustomerTier tier) => | ||
| // Pure calculation | ||
| } | ||
|
|
||
| // Avoid: Hard to test due to hidden dependencies | ||
| public decimal CalculateDiscount() | ||
| { | ||
| var user = _userService.GetCurrentUser(); // Hidden dependency | ||
| var settings = _configService.GetSettings(); // Hidden dependency | ||
| // Calculation | ||
| } | ||
| ``` | ||
|
|
||
| ## Dependency Management: | ||
|
|
||
| - Minimize constructor injection: | ||
| ```csharp | ||
| // Good: Minimal dependencies | ||
| public sealed class OrderProcessor(IOrderRepository repository) | ||
| { | ||
| // Implementation | ||
| } | ||
|
|
||
| // Avoid: Too many dependencies | ||
| // Too many dependencies indicates possible design issues | ||
| public class OrderProcessor( | ||
| IOrderRepository repository, | ||
| ILogger logger, | ||
| IEmailService emailService, | ||
| IMetrics metrics, | ||
| IValidator validator) | ||
| { | ||
| // Implementation | ||
| } | ||
| ``` | ||
| - Prefer composition with interfaces: | ||
| ```csharp | ||
| // Good: Composition with interfaces | ||
| public sealed class EnhancedLogger(ILogger baseLogger, IMetrics metrics) : ILogger | ||
| { | ||
| } | ||
| ``` |
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -117,6 +117,9 @@ | |||||
| <resheader name="writer"> | ||||||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||||||
| </resheader> | ||||||
| <data name="DeleteDepartmentSettingsInfo" xml:space="preserve"> | ||||||
| <value /> | ||||||
|
||||||
| <value /> | |
| <value>Información sobre la configuración de eliminación del departamento</value> |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
[nitpick] There are two spaces between "Assigned" and "Personnel"; reduce to a single space for consistency.