Skip to content

Several warnings during building #4

@ApparentlyPlus

Description

@ApparentlyPlus

Problem Description:

Currently, we have a lot of warnings when building the app:

apparentlyplus@cinnabon:~/Desktop/UniNotes/UniNotes$ dotnet build
Restore complete (0.5s)
  UniNotes succeeded with 43 warning(s) (1.3s) → bin/Debug/net9.0/UniNotes.dll
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/AuthStateProvider.cs(61,62): warning CS8601: Possible null reference assignment.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/AuthStateProvider.cs(79,54): warning CS8604: Possible null reference argument for parameter 'value' in 'Claim.Claim(string type, string value)'.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/NoteService.cs(121,18): warning CS8602: Dereference of a possibly null reference.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/NoteService.cs(228,14): warning CS8602: Dereference of a possibly null reference.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Upload.razor(355,21): warning CS8601: Possible null reference assignment.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(497,28): warning CS8618: Non-nullable property 'data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(513,23): warning CS8618: Non-nullable property 'id' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(514,23): warning CS8618: Non-nullable property 'username' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(515,23): warning CS8618: Non-nullable property 'avatar' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(516,23): warning CS8618: Non-nullable property 'discriminator' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(517,23): warning CS8618: Non-nullable property 'display_name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(540,23): warning CS8618: Non-nullable property 'large_image' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(541,23): warning CS8618: Non-nullable property 'large_text' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(542,23): warning CS8618: Non-nullable property 'small_image' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(543,23): warning CS8618: Non-nullable property 'small_text' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(502,23): warning CS8618: Non-nullable property 'discord_status' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(503,28): warning CS8618: Non-nullable property 'discord_user' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(504,27): warning CS8618: Non-nullable property 'activities' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(505,24): warning CS8618: Non-nullable property 'spotify' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(522,23): warning CS8618: Non-nullable property 'id' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(523,23): warning CS8618: Non-nullable property 'name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(525,23): warning CS8618: Non-nullable property 'state' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(526,23): warning CS8618: Non-nullable property 'details' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(527,23): warning CS8618: Non-nullable property 'application_id' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(528,35): warning CS8618: Non-nullable property 'timestamps' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(529,31): warning CS8618: Non-nullable property 'assets' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(548,23): warning CS8618: Non-nullable property 'track_id' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(549,23): warning CS8618: Non-nullable property 'album' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(550,23): warning CS8618: Non-nullable property 'album_art_url' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(551,23): warning CS8618: Non-nullable property 'artist' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(552,23): warning CS8618: Non-nullable property 'song' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Beta.razor(553,34): warning CS8618: Non-nullable property 'timestamps' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Upload.razor(372,24): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/NoteService.cs(269,18): warning CS8602: Dereference of a possibly null reference.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Upload.razor(438,67): warning CS8604: Possible null reference argument for parameter 'file' in 'Task<bool> NoteService.UploadNoteAsync(Note note, IBrowserFile file)'.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Services/NoteService.cs(392,13): warning CS8602: Dereference of a possibly null reference.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Admin.razor(156,117): warning CS8605: Unboxing a possibly null value.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Admin.razor(716,66): warning CS8604: Possible null reference argument for parameter 'userId' in 'Task<bool> UserService.DeleteUserAsync(string userId)'.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Admin.razor(760,66): warning CS8604: Possible null reference argument for parameter 'id' in 'Task<bool> NoteService.DeleteNoteAsync(string id)'.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Admin.razor(889,51): warning CS8604: Possible null reference argument for parameter 'item' in 'int List<string>.IndexOf(string item)'.
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Report.razor(154,18): warning CS0414: The field 'Report.isLoading' is assigned but its value is never used
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Secretary.razor(145,18): warning CS0414: The field 'Secretary.isLoading' is assigned but its value is never used
    /home/apparentlyplus/Desktop/UniNotes/UniNotes/Components/Pages/Upload.razor(210,18): warning CS0414: The field 'Upload.isFileSelected' is assigned but its value is never used

Build succeeded with 43 warning(s) in 1.9s

It's not time sensitive, nor is it necessary, but it would be good practice to eliminate them. This is a good first issue for someone new to contribute.

Steps to reproduce:

Run:

dotnet clean
dotnet build

Any operating system suffices.

Expected behavior:

Ideally, warnings should be absent (Zero warnings during build).

Actual behavior:

The build emits dozens of warnings.

Proposed solution:

Consider refactoring existing code or simply making a code analyzer script that fixes most of them automatically for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersnot urgentA non urgent bug, enhancement or suggestion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions