MaeFire
MaeFire
CC#
Created by MaeFire on 8/26/2023 in #help
❔ JSON serialization nullable warnings (best approach?)
Kind of have a "best approach" question for the following:
using System.Text.Json;

class FileVerification
{
private readonly string quackenFilePath = @"C:\Users\maske\Documents\dev\CSharp\TelegramBots\quacken.json";

private readonly JsonSerializerOptions _options = new()
{
PropertyNameCaseInsensitive = true
};
public List<QuackenJson> JsonReadWithSystemText()
{
using FileStream json = File.OpenRead(quackenFilePath);
List<QuackenJson> token = JsonSerializer.Deserialize<List<QuackenJson>>(json, _options)!;
return token;
}
}
using System.Text.Json;

class FileVerification
{
private readonly string quackenFilePath = @"C:\Users\maske\Documents\dev\CSharp\TelegramBots\quacken.json";

private readonly JsonSerializerOptions _options = new()
{
PropertyNameCaseInsensitive = true
};
public List<QuackenJson> JsonReadWithSystemText()
{
using FileStream json = File.OpenRead(quackenFilePath);
List<QuackenJson> token = JsonSerializer.Deserialize<List<QuackenJson>>(json, _options)!;
return token;
}
}
Would you make it nullable using ? or ?? in the appropriate spots, or (in this particular case) since I know the value will never be null, would you do as I have and use ! to suppress the warning?
16 replies
CC#
Created by MaeFire on 8/25/2023 in #help
❔ csc command not recognized?
I recently started setting up my environment for C# and dotnet for a new laptop. I am using VS Code, and downloaded the C# Dev Kit extension, which includes everything my home PC has. The dotnet command now works, but for some reason csc is not being recognized as a valid cmdlet, so I am unable to compile my .cs files into their executables. I've never had this problem, so I'm not sure where to start to fix this. Feel free to ask for more information, so I can provide screenshots and whatnot.
34 replies