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 EventDefinition Event { get; set; }
public EventDefinition Event { get; set; } = null!;
public int TeamCount { get; set; }
public int LowerBound { get; set; }
public int UpperBound { get; set; }
+4 -4
View File
@@ -10,22 +10,22 @@ public class TeamScheduleTimeSlot
/// <summary>
/// Gets or sets the name of this time slot.
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// Gets or sets the teams scheduled in this time slot.
/// </summary>
public Team[] Teams;
public Team[] Teams = null!;
/// <summary>
/// Gets or sets the students who are not scheduled in any team during this time slot.
/// </summary>
public Student[] UnscheduledStudents;
public Student[] UnscheduledStudents = null!;
/// <summary>
/// Gets or sets the students who have overlapping team meetings in this time slot.
/// </summary>
public IEnumerable<(Student student, IEnumerable<Team> teams)> StudentOverlaps;
public IEnumerable<(Student student, IEnumerable<Team> teams)> StudentOverlaps = null!;
/// <summary>
/// Checks if a student has overlapping team meetings in this time slot.
+2 -2
View File
@@ -9,7 +9,7 @@ public class EventDefinition
[Required]
[StringLength(100, MinimumLength = 2)]
[Display(Name = "Event Name")]
public string Name { get; set; }
public string Name { get; set; } = null!;
[Required]
[StringLength(40, MinimumLength = 2)]
@@ -72,7 +72,7 @@ public class EventDefinition
[Required]
[StringLength(256)]
public string Eligibility { get; set; }
public string Eligibility { get; set; } = null!;
[StringLength(4096)]
public string? Theme { get; set; }
[StringLength(1024)]
+4 -4
View File
@@ -3,12 +3,12 @@ namespace Core.Entities
{
public class EventOccurrence
{
public string Name { get; set; }
public string Time { get; set; }
public string Date { get; set; }
public string Name { get; set; } = null!;
public string Time { get; set; } = null!;
public string Date { get; set; } = null!;
public DateTime StartTime { get; set; }
public DateTime? EndTime { get; set; }
public string Location { get; set; }
public string Location { get; set; } = null!;
public bool SignupSubmitPickup =>
Name.Contains("Sign-up") ||
+1 -1
View File
@@ -2,7 +2,7 @@
public class PartialTeam : Team
{
public IList<Student> OmittedStudents { get; set; }
public IList<Student> OmittedStudents { get; set; } = null!;
public override Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit)
{
+3 -3
View File
@@ -10,12 +10,12 @@ public class Student : IEquatable<Student>
[Required]
[StringLength(50,MinimumLength = 2)]
[Display(Name = "First Name")]
public string FirstName { get; set; }
public string FirstName { get; set; } = null!;
[Required]
[StringLength(50, MinimumLength = 2)]
[Display(Name = "Last Name")]
public string LastName { get; set; }
public string LastName { get; set; } = null!;
[Range(5,12)]
[Display(Name = "Grade")]
@@ -44,7 +44,7 @@ public class Student : IEquatable<Student>
[Display(Name = "Officer Role")]
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<StudentEventRanking> EventRankings { get; } = [];
+1 -1
View File
@@ -2,7 +2,7 @@
public class StudentEventStatistics
{
public Student Student { get; set; }
public Student Student { get; set; } = null!;
public List<EventDefinition> Events { get; set; } = [];
public int? TotalLevelOfEffort => Events.Sum(e => e.LevelOfEffort);
+1 -1
View File
@@ -6,7 +6,7 @@ public class Team
public int Id { get; set; }
[Required]
public EventDefinition Event { get; set; }
public EventDefinition Event { get; set; } = null!;
public List<Student> Students { get; set; } = [];
+8 -4
View File
@@ -15,7 +15,7 @@ public class AssignmentRequirementParser : CsvParserBase
CsvReader.Read();
CsvReader.ReadHeader();
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 =
studentColumns
@@ -30,21 +30,25 @@ public class AssignmentRequirementParser : CsvParserBase
throw new Exception($"Could not find eventDefinition named {eventShortName}");
for (int i = 0; i <= studentArray.Length; i++)
{
var student = studentArray[i];
if (student == null)
continue;
var field = CsvReader.GetField(i + 1);
switch (field)
{
case "x":
case "X":
assumptions.Add(new AssignmentRequirement(evt, studentArray[i], Requirement.Exclude));
assumptions.Add(new AssignmentRequirement(evt, student, Requirement.Exclude));
break;
case "i":
case "I":
assumptions.Add(new AssignmentRequirement(evt, studentArray[i], Requirement.Include));
assumptions.Add(new AssignmentRequirement(evt, student, Requirement.Include));
break;
default:
break;
}
}
}
+4 -4
View File
@@ -53,8 +53,8 @@ public class EventDefinitionParser : CsvParserBase
var competitiveEvent = new EventDefinition
{
Name = name.Trim(),
ShortName = shortName.Trim(),
Name = name.Trim(),
ShortName = shortName?.Trim() ?? string.Empty,
EventFormat = format,
ChapterEligibilityCountState = stateTeams,
MinTeamSize = min,
@@ -64,10 +64,10 @@ public class EventDefinitionParser : CsvParserBase
//RegionalPresubmit = regionalPresubmit.Trim() == "TRUE",
Notes = regionalNotes,
Documentation= documentation,
Presubmission = statePresubmission.Trim() == "TRUE",
Presubmission = statePresubmission?.Trim() == "TRUE",
//StatePretesting = statePretesting.Trim() == "TRUE",
//StatePreliminaryRound = statePreliminary.Trim() == "TRUE",
Eligibility = eligibility,
Eligibility = eligibility ?? string.Empty,
Theme = theme,
Description = description,
LevelOfEffort = levelOfEffort
+1 -1
View File
@@ -31,7 +31,7 @@ public class EventOccurrenceParser
public IDictionary<EventDefinition, List<EventOccurrence>> Parse()
{
var occurrences = new Dictionary<EventDefinition, List<EventOccurrence>>();
EventDefinition currentEventDefinition = null;
EventDefinition? currentEventDefinition = null;
var lines = File.ReadLines(_txtFile.FullName);
foreach (var line in lines)