Address compiler warnings

This commit is contained in:
2025-12-26 13:58:41 -05:00
parent f2389fa1c1
commit f395dba043
25 changed files with 112 additions and 99 deletions
@@ -4,7 +4,7 @@ namespace Core.Calculation;
public class EventAssignmentThresholds public class EventAssignmentThresholds
{ {
public EventDefinition Event { get; set; } public EventDefinition Event { get; set; } = null!;
public int TeamCount { get; set; } public int TeamCount { get; set; }
public int LowerBound { get; set; } public int LowerBound { get; set; }
public int UpperBound { get; set; } public int UpperBound { get; set; }
+4 -4
View File
@@ -10,22 +10,22 @@ public class TeamScheduleTimeSlot
/// <summary> /// <summary>
/// Gets or sets the name of this time slot. /// Gets or sets the name of this time slot.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; } = null!;
/// <summary> /// <summary>
/// Gets or sets the teams scheduled in this time slot. /// Gets or sets the teams scheduled in this time slot.
/// </summary> /// </summary>
public Team[] Teams; public Team[] Teams = null!;
/// <summary> /// <summary>
/// Gets or sets the students who are not scheduled in any team during this time slot. /// Gets or sets the students who are not scheduled in any team during this time slot.
/// </summary> /// </summary>
public Student[] UnscheduledStudents; public Student[] UnscheduledStudents = null!;
/// <summary> /// <summary>
/// Gets or sets the students who have overlapping team meetings in this time slot. /// Gets or sets the students who have overlapping team meetings in this time slot.
/// </summary> /// </summary>
public IEnumerable<(Student student, IEnumerable<Team> teams)> StudentOverlaps; public IEnumerable<(Student student, IEnumerable<Team> teams)> StudentOverlaps = null!;
/// <summary> /// <summary>
/// Checks if a student has overlapping team meetings in this time slot. /// Checks if a student has overlapping team meetings in this time slot.
+2 -2
View File
@@ -9,7 +9,7 @@ public class EventDefinition
[Required] [Required]
[StringLength(100, MinimumLength = 2)] [StringLength(100, MinimumLength = 2)]
[Display(Name = "Event Name")] [Display(Name = "Event Name")]
public string Name { get; set; } public string Name { get; set; } = null!;
[Required] [Required]
[StringLength(40, MinimumLength = 2)] [StringLength(40, MinimumLength = 2)]
@@ -72,7 +72,7 @@ public class EventDefinition
[Required] [Required]
[StringLength(256)] [StringLength(256)]
public string Eligibility { get; set; } public string Eligibility { get; set; } = null!;
[StringLength(4096)] [StringLength(4096)]
public string? Theme { get; set; } public string? Theme { get; set; }
[StringLength(1024)] [StringLength(1024)]
+4 -4
View File
@@ -3,12 +3,12 @@ namespace Core.Entities
{ {
public class EventOccurrence public class EventOccurrence
{ {
public string Name { get; set; } public string Name { get; set; } = null!;
public string Time { get; set; } public string Time { get; set; } = null!;
public string Date { get; set; } public string Date { get; set; } = null!;
public DateTime StartTime { get; set; } public DateTime StartTime { get; set; }
public DateTime? EndTime { get; set; } public DateTime? EndTime { get; set; }
public string Location { get; set; } public string Location { get; set; } = null!;
public bool SignupSubmitPickup => public bool SignupSubmitPickup =>
Name.Contains("Sign-up") || Name.Contains("Sign-up") ||
+1 -1
View File
@@ -2,7 +2,7 @@
public class PartialTeam : Team public class PartialTeam : Team
{ {
public IList<Student> OmittedStudents { get; set; } public IList<Student> OmittedStudents { get; set; } = null!;
public override Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit) public override Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit)
{ {
+3 -3
View File
@@ -10,12 +10,12 @@ public class Student : IEquatable<Student>
[Required] [Required]
[StringLength(50,MinimumLength = 2)] [StringLength(50,MinimumLength = 2)]
[Display(Name = "First Name")] [Display(Name = "First Name")]
public string FirstName { get; set; } public string FirstName { get; set; } = null!;
[Required] [Required]
[StringLength(50, MinimumLength = 2)] [StringLength(50, MinimumLength = 2)]
[Display(Name = "Last Name")] [Display(Name = "Last Name")]
public string LastName { get; set; } public string LastName { get; set; } = null!;
[Range(5,12)] [Range(5,12)]
[Display(Name = "Grade")] [Display(Name = "Grade")]
@@ -44,7 +44,7 @@ public class Student : IEquatable<Student>
[Display(Name = "Officer Role")] [Display(Name = "Officer Role")]
public OfficerRole? OfficerRole { get; set; } public OfficerRole? OfficerRole { get; set; }
public List<Team> Teams { get; set; } = null; public List<Team> Teams { get; set; } = null!;
public List<EventDefinition> RankedEvents { get; } = []; public List<EventDefinition> RankedEvents { get; } = [];
public List<StudentEventRanking> EventRankings { get; } = []; public List<StudentEventRanking> EventRankings { get; } = [];
+1 -1
View File
@@ -2,7 +2,7 @@
public class StudentEventStatistics public class StudentEventStatistics
{ {
public Student Student { get; set; } public Student Student { get; set; } = null!;
public List<EventDefinition> Events { get; set; } = []; public List<EventDefinition> Events { get; set; } = [];
public int? TotalLevelOfEffort => Events.Sum(e => e.LevelOfEffort); public int? TotalLevelOfEffort => Events.Sum(e => e.LevelOfEffort);
+1 -1
View File
@@ -6,7 +6,7 @@ public class Team
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
public EventDefinition Event { get; set; } public EventDefinition Event { get; set; } = null!;
public List<Student> Students { get; set; } = []; public List<Student> Students { get; set; } = [];
+8 -4
View File
@@ -15,7 +15,7 @@ public class AssignmentRequirementParser : CsvParserBase
CsvReader.Read(); CsvReader.Read();
CsvReader.ReadHeader(); CsvReader.ReadHeader();
var studentColumns = var studentColumns =
CsvReader.HeaderRecord.Select(h => h.Trim()).Where(h => !string.IsNullOrEmpty(h)).ToArray(); CsvReader.HeaderRecord!.Select(h => h.Trim()).Where(h => !string.IsNullOrEmpty(h)).ToArray();
var studentArray = var studentArray =
studentColumns studentColumns
@@ -30,21 +30,25 @@ public class AssignmentRequirementParser : CsvParserBase
throw new Exception($"Could not find eventDefinition named {eventShortName}"); throw new Exception($"Could not find eventDefinition named {eventShortName}");
for (int i = 0; i <= studentArray.Length; i++) for (int i = 0; i <= studentArray.Length; i++)
{ {
var student = studentArray[i];
if (student == null)
continue;
var field = CsvReader.GetField(i + 1); var field = CsvReader.GetField(i + 1);
switch (field) switch (field)
{ {
case "x": case "x":
case "X": case "X":
assumptions.Add(new AssignmentRequirement(evt, studentArray[i], Requirement.Exclude)); assumptions.Add(new AssignmentRequirement(evt, student, Requirement.Exclude));
break; break;
case "i": case "i":
case "I": case "I":
assumptions.Add(new AssignmentRequirement(evt, studentArray[i], Requirement.Include)); assumptions.Add(new AssignmentRequirement(evt, student, Requirement.Include));
break; break;
default: default:
break; break;
} }
} }
} }
+4 -4
View File
@@ -53,8 +53,8 @@ public class EventDefinitionParser : CsvParserBase
var competitiveEvent = new EventDefinition var competitiveEvent = new EventDefinition
{ {
Name = name.Trim(), Name = name.Trim(),
ShortName = shortName.Trim(), ShortName = shortName?.Trim() ?? string.Empty,
EventFormat = format, EventFormat = format,
ChapterEligibilityCountState = stateTeams, ChapterEligibilityCountState = stateTeams,
MinTeamSize = min, MinTeamSize = min,
@@ -64,10 +64,10 @@ public class EventDefinitionParser : CsvParserBase
//RegionalPresubmit = regionalPresubmit.Trim() == "TRUE", //RegionalPresubmit = regionalPresubmit.Trim() == "TRUE",
Notes = regionalNotes, Notes = regionalNotes,
Documentation= documentation, Documentation= documentation,
Presubmission = statePresubmission.Trim() == "TRUE", Presubmission = statePresubmission?.Trim() == "TRUE",
//StatePretesting = statePretesting.Trim() == "TRUE", //StatePretesting = statePretesting.Trim() == "TRUE",
//StatePreliminaryRound = statePreliminary.Trim() == "TRUE", //StatePreliminaryRound = statePreliminary.Trim() == "TRUE",
Eligibility = eligibility, Eligibility = eligibility ?? string.Empty,
Theme = theme, Theme = theme,
Description = description, Description = description,
LevelOfEffort = levelOfEffort LevelOfEffort = levelOfEffort
+1 -1
View File
@@ -31,7 +31,7 @@ public class EventOccurrenceParser
public IDictionary<EventDefinition, List<EventOccurrence>> Parse() public IDictionary<EventDefinition, List<EventOccurrence>> Parse()
{ {
var occurrences = new Dictionary<EventDefinition, List<EventOccurrence>>(); var occurrences = new Dictionary<EventDefinition, List<EventOccurrence>>();
EventDefinition currentEventDefinition = null; EventDefinition? currentEventDefinition = null;
var lines = File.ReadLines(_txtFile.FullName); var lines = File.ReadLines(_txtFile.FullName);
foreach (var line in lines) foreach (var line in lines)
@@ -27,9 +27,9 @@
@code { @code {
[Parameter] [Parameter]
public EventDefinition EventDefinition { get; set; } public required EventDefinition EventDefinition { get; set; }
private string _attributes; private string _attributes = string.Empty;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
@@ -10,7 +10,7 @@
ShowBackButton="true" ShowBackButton="true"
BackButtonUrl="/events" /> BackButtonUrl="/events" />
<EditForm id="create-event-form" Model="EventDefinition" OnValidSubmit="OnValidSubmit" Enhance> <EditForm Model="EventDefinition" OnValidSubmit="OnValidSubmit" Enhance>
<FormChangeTracker @ref="_formChangeTracker" /> <FormChangeTracker @ref="_formChangeTracker" />
<AntiforgeryToken /> <AntiforgeryToken />
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@@ -45,13 +45,12 @@
</MudPaper> </MudPaper>
</MudItem> </MudItem>
</MudGrid> </MudGrid>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary">Create</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
</EditForm> </EditForm>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Form="create-event-form">Create</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
@code { @code {
[SupplyParameterFromForm] [SupplyParameterFromForm]
private EventDefinition EventDefinition { get; set; } = new(); private EventDefinition EventDefinition { get; set; } = new();
+5 -6
View File
@@ -17,7 +17,7 @@
ShowBackButton="true" ShowBackButton="true"
BackButtonUrl="/events" /> BackButtonUrl="/events" />
<EditForm id="edit-event-form" Model="EventDefinition" OnValidSubmit="OnValidSubmit" Enhance> <EditForm Model="EventDefinition" OnValidSubmit="OnValidSubmit" Enhance>
<FormChangeTracker @ref="_formChangeTracker" /> <FormChangeTracker @ref="_formChangeTracker" />
<AntiforgeryToken /> <AntiforgeryToken />
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@@ -52,13 +52,12 @@
</MudPaper> </MudPaper>
</MudItem> </MudItem>
</MudGrid> </MudGrid>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary">Save</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
</EditForm> </EditForm>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Form="edit-event-form">Save</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
@code { @code {
[SupplyParameterFromQuery] [SupplyParameterFromQuery]
private int Id { get; set; } private int Id { get; set; }
@@ -25,15 +25,13 @@
@context.Item.Name @context.Item.Name
</MudLink> </MudLink>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIconButton Icon="@Icons.Material.Filled.Edit" <IconButtonWithTooltip Icon="@Icons.Material.Filled.Edit"
Size="Size.Small" TooltipText="Edit"
Href="@($"/events/edit?id={context.Item.Id}")" Href="@($"/events/edit?id={context.Item.Id}")" />
Title="Edit" /> <IconButtonWithTooltip Icon="@Icons.Material.Outlined.Delete"
<MudIconButton Icon="@Icons.Material.Outlined.Delete" TooltipText="Delete"
Size="Size.Small" Color="Color.Error"
Color="Color.Error" OnClick="() => DeleteEventDefinition(context.Item!)" />
OnClick="() => DeleteEventDefinition(context.Item!)"
Title="Delete" />
</MudStack> </MudStack>
</MudStack> </MudStack>
</CellTemplate> </CellTemplate>
@@ -102,11 +102,11 @@
</MudPaper> </MudPaper>
@code { @code {
private Team[]? _teams; private Team[] _teams = null!;
private Student[]? _students; private Student[] _students = null!;
MudTable<TeamScheduleTimeSlot> _solutionData; MudTable<TeamScheduleTimeSlot> _solutionData = null!;
private TeamSchedulerSolution _solution; private TeamSchedulerSolution _solution = null!;
private TeamSchedulerOptions _parameters; private TeamSchedulerOptions _parameters = null!;
bool _isSolving; bool _isSolving;
private IEnumerable<Team> _scheduledTeams = []; private IEnumerable<Team> _scheduledTeams = [];
private IEnumerable<Student> _absentStudents = []; private IEnumerable<Student> _absentStudents = [];
@@ -10,7 +10,7 @@
ShowBackButton="true" ShowBackButton="true"
BackButtonUrl="/students" /> BackButtonUrl="/students" />
<EditForm id="create-student-form" Model="Student" OnValidSubmit="OnValidSubmit" Enhance> <EditForm Model="Student" OnValidSubmit="OnValidSubmit" Enhance>
<FormChangeTracker @ref="_formChangeTracker" /> <FormChangeTracker @ref="_formChangeTracker" />
<AntiforgeryToken /> <AntiforgeryToken />
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@@ -26,13 +26,12 @@
</MudPaper> </MudPaper>
</MudItem> </MudItem>
</MudGrid> </MudGrid>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary">Create</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
</EditForm> </EditForm>
<FormActions>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Form="create-student-form">Create</MudButton>
<MudButton OnClick="HandleCancel" Variant="Variant.Text">Cancel</MudButton>
</FormActions>
@code { @code {
[SupplyParameterFromForm] [SupplyParameterFromForm]
private Student Student { get; set; } = new() { TsaYear = 1 }; private Student Student { get; set; } = new() { TsaYear = 1 };
@@ -97,11 +97,11 @@ else
private Student[]? _students; private Student[]? _students;
private class EventStudentRankings { private class EventStudentRankings {
public EventDefinition Event {get; set; } public required EventDefinition Event {get; set; }
public Tuple<Student,int> [] StudentRanking { get; set; } public required Tuple<Student,int>[] StudentRanking { get; set; }
} }
private EventStudentRankings[] _eventStudentRankings; private EventStudentRankings[] _eventStudentRankings = null!;
private int _maxEventStudentRankings; private int _maxEventStudentRankings;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@@ -32,15 +32,13 @@
} }
</MudStack> </MudStack>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIconButton Icon="@Icons.Material.Filled.Edit" <IconButtonWithTooltip Icon="@Icons.Material.Filled.Edit"
Size="Size.Small" TooltipText="Edit"
Href="@($"/students/edit?id={context.Item.Id}&returnUrl=/students")" Href="@($"/students/edit?id={context.Item.Id}&returnUrl=/students")" />
Title="Edit" /> <IconButtonWithTooltip Icon="@Icons.Material.Outlined.Delete"
<MudIconButton Icon="@Icons.Material.Outlined.Delete" TooltipText="Delete"
Size="Size.Small" Color="Color.Error"
Color="Color.Error" OnClick="() => DeleteStudent(context.Item!)" />
OnClick="() => DeleteStudent(context.Item!)"
Title="Delete" />
</MudStack> </MudStack>
</MudStack> </MudStack>
</CellTemplate> </CellTemplate>
@@ -309,19 +309,19 @@
private readonly AssignmentParameters _parameters = new() { RequireOnSite = false, RequireRegional = false }; private readonly AssignmentParameters _parameters = new() { RequireOnSite = false, RequireRegional = false };
private ValidationService _validationService = new ValidationService(ValidationConfiguration.Default); private ValidationService _validationService = new ValidationService(ValidationConfiguration.Default);
private List<EventDefinition>? _events; private List<EventDefinition> _events = null!;
private List<Student>? _students; private List<Student> _students = null!;
private List<EventAssignmentThresholds> _eventAssignmentThresholds = []; private List<EventAssignmentThresholds> _eventAssignmentThresholds = [];
MudTable<Team> _teamData; MudTable<Team> _teamData = null!;
private Team[] _teams = []; private Team[] _teams = [];
MudTable<StudentEventStatistics> _statisticData; MudTable<StudentEventStatistics> _statisticData = null!;
private List<StudentEventStatistics> _statistics = []; private List<StudentEventStatistics> _statistics = [];
MudTable<AssignmentRequirement> _assignmentRequirementData; MudTable<AssignmentRequirement> _assignmentRequirementData = null!;
private List<AssignmentRequirement> _assignmentRequirements = []; private List<AssignmentRequirement> _assignmentRequirements = [];
MudTable<EventDefinition> _eventTwoTeamData; MudTable<EventDefinition> _eventTwoTeamData = null!;
private List<EventDefinition> _eventTwoTeams = []; private List<EventDefinition> _eventTwoTeams = [];
MudTable<EventDefinition> _eventOmittedData; MudTable<EventDefinition> _eventOmittedData = null!;
private List<EventDefinition> _eventOmitted = []; private List<EventDefinition> _eventOmitted = [];
private string _solutionStatus = string.Empty; private string _solutionStatus = string.Empty;
@@ -387,9 +387,9 @@
return new TableData<Team> { Items = _teams }; return new TableData<Team> { Items = _teams };
} }
private async Task<TableData<StudentEventStatistics>> ReloadStatistics(TableState arg1, CancellationToken arg2) private Task<TableData<StudentEventStatistics>> ReloadStatistics(TableState arg1, CancellationToken arg2)
{ {
return new TableData<StudentEventStatistics> {Items = _statistics}; return Task.FromResult(new TableData<StudentEventStatistics> {Items = _statistics});
} }
private void UpdateValidationConfig() private void UpdateValidationConfig()
@@ -403,20 +403,20 @@
return _validationService.ValidateStudentStatistics(stats, ValidationContext.StudentAssignment); return _validationService.ValidateStudentStatistics(stats, ValidationContext.StudentAssignment);
} }
private async Task<TableData<AssignmentRequirement>> ReloadAssignmentRequirements(TableState arg1, CancellationToken arg2) private Task<TableData<AssignmentRequirement>> ReloadAssignmentRequirements(TableState arg1, CancellationToken arg2)
{ {
return new TableData<AssignmentRequirement> { Items = _assignmentRequirements }; return Task.FromResult(new TableData<AssignmentRequirement> { Items = _assignmentRequirements });
} }
private async Task<TableData<EventDefinition>> ReloadEventTwoTeam(TableState arg1, CancellationToken arg2) private Task<TableData<EventDefinition>> ReloadEventTwoTeam(TableState arg1, CancellationToken arg2)
{ {
return new TableData<EventDefinition> { Items = _eventTwoTeams }; return Task.FromResult(new TableData<EventDefinition> { Items = _eventTwoTeams });
} }
private async Task<TableData<EventDefinition>> ReloadOmittedEvents(TableState arg1, CancellationToken arg2) private Task<TableData<EventDefinition>> ReloadOmittedEvents(TableState arg1, CancellationToken arg2)
{ {
return new TableData<EventDefinition> { Items = _eventOmitted }; return Task.FromResult(new TableData<EventDefinition> { Items = _eventOmitted });
} }
private void RequireEvent(EventDefinition evt, Student student, Requirement requirement) private void RequireEvent(EventDefinition evt, Student student, Requirement requirement)
@@ -12,7 +12,7 @@
</MudSelect> </MudSelect>
@code { @code {
[Parameter] public Team[]? Teams { get; set; } [Parameter] public Team[] Teams { get; set; } = null!;
[Parameter] public required IEnumerable<Team> SelectedTeams { get; set; } [Parameter] public required IEnumerable<Team> SelectedTeams { get; set; }
[Parameter] public string Label { get; set; } = "Teams"; [Parameter] public string Label { get; set; } = "Teams";
} }
@@ -23,5 +23,5 @@
@code { @code {
[Parameter] [Parameter]
public Team Team { get; set; } public required Team Team { get; set; }
} }
+7 -9
View File
@@ -25,15 +25,13 @@
@context.Item.ToString() @context.Item.ToString()
</MudLink> </MudLink>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIconButton Icon="@Icons.Material.Filled.Edit" <IconButtonWithTooltip Icon="@Icons.Material.Filled.Edit"
Size="Size.Small" TooltipText="Edit"
Href="@($"/teams/edit?id={context.Item.Id}")" Href="@($"/teams/edit?id={context.Item.Id}")" />
Title="Edit" /> <IconButtonWithTooltip Icon="@Icons.Material.Outlined.Delete"
<MudIconButton Icon="@Icons.Material.Outlined.Delete" TooltipText="Delete"
Size="Size.Small" Color="Color.Error"
Color="Color.Error" OnClick="() => DeleteTeam(context.Item!)" />
OnClick="() => DeleteTeam(context.Item!)"
Title="Delete" />
</MudStack> </MudStack>
</MudStack> </MudStack>
</CellTemplate> </CellTemplate>
@@ -205,7 +205,7 @@ else
private Team[]? _teams; private Team[]? _teams;
private int _maxTeamSize; private int _maxTeamSize;
private Student[]? _students; private Student[]? _students;
private bool _rankColorEnabled; private bool _rankColorEnabled = false;
private string EventRankClass(int rank) private string EventRankClass(int rank)
{ {
@@ -0,0 +1,18 @@
@namespace WebApp.Components.Shared.Components
<MudTooltip Text="@TooltipText">
<MudIconButton Icon="@Icon"
Size="@Size"
Color="@Color"
Href="@Href"
OnClick="@OnClick" />
</MudTooltip>
@code {
[Parameter] public required string Icon { get; set; }
[Parameter] public required string TooltipText { get; set; }
[Parameter] public Size Size { get; set; } = Size.Small;
[Parameter] public Color Color { get; set; } = Color.Default;
[Parameter] public string? Href { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
}