Skip to content

Fixed warnings, removed schema generator#58

Open
Lantzify wants to merge 1 commit intomainfrom
settings
Open

Fixed warnings, removed schema generator#58
Lantzify wants to merge 1 commit intomainfrom
settings

Conversation

@Lantzify
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 15, 2026 22:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR focuses on reducing nullable-reference warnings across the uSupport codebase (mostly by making DTO/schema properties nullable and adding additional null checks), updates a couple of email templates, and removes the standalone schema generator project.

Changes:

  • Enabled project-wide suppression for CS8603 and introduced widespread null-tolerant patterns (nullable DTO/schema properties, null-conditional access, and guard clauses).
  • Updated ticket email templates (“Submitted”/“Last updated” labels and date formatting).
  • Removed the uSupport.SchemaGenerator project and its implementation files.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/uSupport/uSupport.csproj Suppresses CS8603 warnings at the project level.
src/uSupport/Views/Partials/uSupport/Emails/UpdateTicketEmail.cshtml Displays “Last updated” and uses LastUpdated for the date.
src/uSupport/Views/Partials/uSupport/Emails/NewTicketEmail.cshtml Renames “Created” label to “Submitted”.
src/uSupport/Services/uSupportTicketTypeService.cs Returns Guid.Empty instead of throwing on missing type.
src/uSupport/Services/uSupportTicketStatusService.cs Returns Guid.Empty instead of throwing on missing status.
src/uSupport/Services/uSupportServiceBase.cs Adds null-tolerant reflection-based Id extraction with Guid.Empty fallback.
src/uSupport/Notifications/Handlers/TicketHistoryNotificationHandler.cs Adds null-safe access to ticket status activity.
src/uSupport/Migrations/Updates/2.0.0/AddSectionForAdminsMigration.cs Guards admin group section assignment with null check.
src/uSupport/Migrations/Schemas/uSupportTypeBaseSchema.cs Makes optional schema fields nullable.
src/uSupport/Migrations/Schemas/uSupportTicketTypeSchema.cs Makes optional schema fields nullable.
src/uSupport/Migrations/Schemas/uSupportTicketSchema.cs Makes Type/Status result columns nullable.
src/uSupport/Migrations/Schemas/uSupportTicketHistorySchema.cs Makes User/Changes result columns nullable.
src/uSupport/Migrations/Schemas/uSupportTicketCommentSchema.cs Makes User result column nullable.
src/uSupport/Extensions/uSupportTemplate.cs Returns empty string instead of null from GetBaseUrl.
src/uSupport/Dtos/uSupportUserSaveDto.cs Makes DTO fields nullable.
src/uSupport/Dtos/uSupportReadonlyDto.cs Makes DTO fields nullable.
src/uSupport/Dtos/uSupportChange.cs Removes unused usings; makes fields nullable.
src/uSupport/Dtos/Tables/uSupportTypeBase.cs Makes Color nullable.
src/uSupport/Dtos/Tables/uSupportTicketType.cs Makes optional strings nullable.
src/uSupport/Dtos/Tables/uSupportTicketHistory.cs Makes result columns and JSON nullable.
src/uSupport/Dtos/Tables/uSupportTicketComment.cs Makes User nullable.
src/uSupport/Dtos/Tables/uSupportTicket.cs Makes several navigation/result properties nullable.
src/uSupport/Dtos/SortActionDto.cs Makes fields nullable.
src/uSupport/Dtos/PreviewDeleteItemDto.cs Makes fields nullable.
src/uSupport/Dtos/DeleteActionDto.cs Makes Type nullable.
src/uSupport/Controllers/uSupportTicketTypeAuthorizedApiController.cs Adjusts nullability/guards for API endpoints.
src/uSupport/Controllers/uSupportTicketCommentAuthorizedApiController.cs Adds author lookup/mapping during comment flow.
src/uSupport/Controllers/uSupportTicketAuthorizedApiController.cs Adds email guards + warning logging; null-safe status check.
src/uSupport/Controllers/uSupportHelperAuthorizedApiController.cs Adds null checks; changes DTO assignments and parsing logic.
src/uSupport/Controllers/uSupportActionAuthorizedApiController.cs Adds null/empty guard for Sort; adjusts null propagation.
src/uSupport/Backoffice/Trees/uSupportTicketsTreeController.cs Makes root node result nullable and adds null-safe menu calls.
src/uSupport/Backoffice/Trees/uSupportTicketTypesTreeController.cs Makes root node result nullable and adds null-safe menu calls.
src/uSupport/Backoffice/Trees/uSupportTicketStatusesTreeController.cs Makes root node result nullable and adds null-safe menu calls.
src/uSupport/Backoffice/Trees/uSupportSettingsTreeController.cs Makes root node result nullable; removes unused using.
src/uSupport.Tests/Helpers/uSupportTokenHelperTests.cs Uses pragma to allow passing null in test.
src/uSupport.SchemaGenerator/uSupport.SchemaGenerator.csproj Deleted schema generator project file.
src/uSupport.SchemaGenerator/SchemaGenerator.cs Deleted schema generator implementation.
src/uSupport.SchemaGenerator/Program.cs Deleted schema generator entrypoint.
src/uSupport.SchemaGenerator/Options.cs Deleted CLI options.
src/uSupport.SchemaGenerator/AppSettings.cs Deleted schema root model.
Comments suppressed due to low confidence (1)

src/uSupport/Controllers/uSupportTicketAuthorizedApiController.cs:190

  • This warning message says settings are missing, but the condition also covers cases where the ticket author or author email is missing/blank. Consider splitting the condition (settings missing vs. missing recipient email) or updating the log message to reflect the actual failure reason so ops troubleshooting is accurate.
					if (settings != null && updatedTicket.Author != null && !string.IsNullOrWhiteSpace(updatedTicket.Author.Email))
					{
						_uSupportSettingsService.SendEmail(
							updatedTicket.Author.Email,
							uSupportTokenHelper.ReplaceTokens(settings.EmailSubjectUpdateTicket, updatedTicket),
							settings.EmailTemplateUpdateTicketPath,
							updatedTicket);

						_eventAggregator.Publish(new UpdateTicketSendEmailNotification(updatedTicket));
					}
					else
					{
 						_logger.LogWarning("Email was not sent for ticket '{TicketId}' on update because uSupport settings are missing.", updatedTicket.ExternalTicketId);
					}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>CS8603</NoWarn>
Comment on lines +88 to +90
var dtoType = dto?.GetType();
var dtoIdProperty = dtoType?.GetProperty("Id");
var id = Guid.Parse(dtoIdProperty?.GetValue(dto)?.ToString() ?? Guid.Empty.ToString());

[HttpGet]
public IEnumerable<string> GetAllDataTypes()
public IEnumerable<string?> GetAllDataTypes()
Comment on lines 79 to 84
[HttpPost]
public IEnumerable<uSupportTicketType> GetTicketTypes(List<Guid> ids)
{
if (ids == null) return null;
if (ids == null || !ids.Any()) return null;

return _uSupportTicketTypeService.GetByIds(ids);
Comment on lines 62 to +67
public IUser ClearAvatar(UserDisplay displayUser)
{
var user = _userService.GetUserById(int.Parse(displayUser.Id.ToString()));
int userId = int.Parse(displayUser.Id?.ToString() ?? string.Empty);
var user = _userService.GetUserById(userId);
if (user == null)
return null;
}
else
{
_logger.LogWarning("Email for ticket {ExternalTicketId} was not sent due to 'TicketUpdateEmail' not beeing set", createdTicket.ExternalTicketId);
Comment on lines +40 to +43
var dtoType = dto?.GetType();
var dtoIdProperty = dtoType?.GetProperty("Id");

return Get(Guid.Parse(dtoIdProperty.GetValue(dto).ToString()));
return Get(Guid.Parse(dtoIdProperty?.GetValue(dto)?.ToString() ?? Guid.Empty.ToString()));
Comment on lines 47 to 55
public UserDisplay SaveUser(uSupportUserSaveDto uSupportUserSaveDto)
{
var user = _userService.GetUserById(uSupportUserSaveDto.Id);
if (user == null)
return null;

user.Name = uSupportUserSaveDto.Name;
user.Email = uSupportUserSaveDto.Email;
user.Name = uSupportUserSaveDto?.Name;
user.Email = uSupportUserSaveDto?.Email ?? string.Empty;

Comment on lines 41 to +42
var ticketStatus = context.Scope.Database.Query<uSupportTicketType>($"SELECT Id FROM {TicketTypeTableAlias} WHERE [Name] = @name", new { name }).FirstOrDefault();
return ticketStatus.Id;
return ticketStatus?.Id ?? Guid.Empty;
Comment on lines 83 to +84
var ticketStatus = context.Scope.Database.Query<uSupportTicketStatus>($"SELECT Id FROM {TicketStatusTableAlias} WHERE [Name] = @name", new { name }).FirstOrDefault();
return ticketStatus.Id;
return ticketStatus?.Id ?? Guid.Empty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants