Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/copilot-instructions.md
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
{
}
```
102 changes: 57 additions & 45 deletions Core/Resgrid.Localization/Areas/User/Department/Department.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,51 @@
<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>Request deletion of your department. This is a permanent and non-reversable operation that takes 25 days to complete and needs to run after hours. During the wait period you can cancel the request if you choose.</value>
</data>
<data name="RequestDepartmentDeletion" xml:space="preserve">
<value>Request Department Deletion</value>
</data>
<data name="DeleteDepartmentCurrentlyPendingInfo" xml:space="preserve">
<value>Your department has a currently pending deletion request. If you want this request to proceed there is nothing you need to do after the timestamp below (during our nightly process) your department and all of it’s data will be removed. If you wish to cancel the request and not delete the department press the “Cancel Department Deletion” button below. Please note, any changes to admins and owners will cause the process to not complete, it’s recommended that you only use the system in a read only mode to download data you wish to save.</value>
</data>
<data name="MappingSettingsHeader" xml:space="preserve">
<value>Mapping Settings</value>
</data>
<data name="SavedMappingSettings" xml:space="preserve">
<value>Successfully saved Mapping Settings.</value>
</data>
<data name="MappingSettingsPersonnelHeader" xml:space="preserve">
<value>Personnel Mapping Settings</value>
</data>
<data name="MappingSettingsUnitsHeader" xml:space="preserve">
<value>Units Mapping Settings</value>
</data>
<data name="MappingSettingsPersonnelAllowOverwriteLabel" xml:space="preserve">
<value>Allow Status with No Location Data to hide previous location</value>
</data>
<data name="MappingSettingsPersonnelTTLLabel" xml:space="preserve">
<value>TTL In Minutes for Personnel Locations</value>
</data>
<data name="MappingSettingsUnitAllowOverwriteLabel" xml:space="preserve">
<value>Allow Unit Status with No Location Data to hide previous location</value>
</data>
<data name="MappingSettingsUnitTTLLabel" xml:space="preserve">
<value>TTL In Minutes for Unit Locations</value>
</data>
<data name="PersonnelAllowOverwriteHelp" xml:space="preserve">
<value>If enabled and a status comes in for that user (i.e. Standing By) without a geolocation it'll hide the users location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
</data>
<data name="UnitAllowOverwriteHelp" xml:space="preserve">
<value>If enabled and a status comes in for that unit (i.e. In Quarters) without a geolocation it'll hide the units location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
</data>
<data name="PersonnelTTLHelp" xml:space="preserve">
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a person would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
</data>
<data name="UnitTTLHelp" xml:space="preserve">
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a unit would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
</data>
<data name="AccountOwner" xml:space="preserve">
<value>Account Owner</value>
</data>
Expand Down Expand Up @@ -375,15 +420,6 @@
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
<value>Delete Your Department</value>
</data>
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
<value>Request deletion of your department. This is a permanent and non-reversable operation that takes 25 days to complete and needs to run after hours. During the wait period you can cancel the request if you choose.</value>
</data>
<data name="RequestDepartmentDeletion" xml:space="preserve">
<value>Request Department Deletion</value>
</data>
<data name="DeleteDepartmentCurrentlyPendingInfo" xml:space="preserve">
<value>Your department has a currently pending deletion request. If you want this request to proceed there is nothing you need to do after the timestamp below (during our nightly process) your department and all of it’s data will be removed. If you wish to cancel the request and not delete the department press the “Cancel Department Deletion” button below. Please note, any changes to admins and owners will cause the process to not complete, it’s recommended that you only use the system in a read only mode to download data you wish to save.</value>
</data>
<data name="EnableSupressStaffings" xml:space="preserve">
<value>Enable Staffing Supress</value>
</data>
Expand All @@ -393,42 +429,6 @@
<data name="SupressStaffingsInfo" xml:space="preserve">
<value>Select the Personnel Staffing Levels below that will be prevented from receiving any notifications, dispatches, alerts, messages, or any other communication. Most commonly these are your "Off Duty" or "On Leave" staffing levels.</value>
</data>
<data name="MappingSettingsHeader" xml:space="preserve">
<value>Mapping Settings</value>
</data>
<data name="SavedMappingSettings" xml:space="preserve">
<value>Successfully saved Mapping Settings.</value>
</data>
<data name="MappingSettingsPersonnelHeader" xml:space="preserve">
<value>Personnel Mapping Settings</value>
</data>
<data name="MappingSettingsUnitsHeader" xml:space="preserve">
<value>Units Mapping Settings</value>
</data>
<data name="MappingSettingsPersonnelAllowOverwriteLabel" xml:space="preserve">
<value>Allow Status with No Location Data to hide previous location</value>
</data>
<data name="MappingSettingsPersonnelTTLLabel" xml:space="preserve">
<value>TTL In Minutes for Personnel Locations</value>
</data>
<data name="MappingSettingsUnitAllowOverwriteLabel" xml:space="preserve">
<value>Allow Unit Status with No Location Data to hide previous location</value>
</data>
<data name="MappingSettingsUnitTTLLabel" xml:space="preserve">
<value>TTL In Minutes for Unit Locations</value>
</data>
<data name="PersonnelAllowOverwriteHelp" xml:space="preserve">
<value>If enabled and a status comes in for that user (i.e. Standing By) without a geolocation it'll hide the users location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
</data>
<data name="UnitAllowOverwriteHelp" xml:space="preserve">
<value>If enabled and a status comes in for that unit (i.e. In Quarters) without a geolocation it'll hide the units location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
</data>
<data name="PersonnelTTLHelp" xml:space="preserve">
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a person would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
</data>
<data name="UnitTTLHelp" xml:space="preserve">
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a unit would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
</data>
<data name="AddContact" xml:space="preserve">
<value>Add Contact</value>
</data>
Expand Down Expand Up @@ -477,4 +477,16 @@
<data name="SavedModuleSettings" xml:space="preserve">
<value>Department Module Settings Have Been Saved</value>
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value>Group Dispatch Settings</value>
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value>Unit Dispatch Settings</value>
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value>Also Dispatch To Assigned Personnel</value>
Copy link

Copilot AI Jul 16, 2025

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.

Suggested change
<value>Also Dispatch To Assigned Personnel</value>
<value>Also Dispatch To Assigned Personnel</value>

Copilot uses AI. Check for mistakes.
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value>Also Dispatch To Entire Group</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Spanish localization is missing entries for the new dispatch settings keys; add translations to match the English .resx.

Suggested change
<value />
<value>Información sobre la configuración de eliminación del departamento</value>

Copilot uses AI. Check for mistakes.
</data>
<data name="AccountOwner" xml:space="preserve">
<value>Propietario de la cuenta</value>
</data>
Expand Down Expand Up @@ -375,7 +378,16 @@
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value />
</data>
</root>
Loading
Loading