Fixed AOT Warnings

This commit is contained in:
Mike Phares 2024-10-03 12:35:31 -07:00
parent b8ebd7cfe1
commit ac5f1caa23
2 changed files with 15 additions and 3 deletions

View File

@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
namespace File_Folder_Helper.Day.Q32024;
@ -20,6 +21,12 @@ internal static partial class Helper20240828
string? Recipe,
string? Zone);
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(HeaderCommon))]
internal partial class HeaderCommonSourceGenerationContext : JsonSerializerContext
{
}
public record Record(string? CassetteId,
ReadOnlyCollection<string>? CassetteSegments,
DateTime? Date,
@ -167,7 +174,6 @@ internal static partial class Helper20240828
string logDirectory = Path.GetFullPath(args[0]);
string sourceDirectory = Path.GetFullPath(args[4]);
string archiveDirectory = Path.GetFullPath(args[6]);
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
FileInfo[] collection = Directory.GetFiles(sourceDirectory, wcSearchPattern, SearchOption.AllDirectories).Select(l => new FileInfo(l)).ToArray();
logger.LogInformation("Found {collection}(s)", collection.Length);
foreach (FileInfo fileInfo in collection)
@ -192,7 +198,7 @@ internal static partial class Helper20240828
if (File.Exists(checkFile))
continue;
headerCommon = new(fileInfo.LastWriteTime, null, null, null, null, quantity, runDataSheet, null, recipe, null);
json = JsonSerializer.Serialize(headerCommon, jsonSerializerOptions);
json = JsonSerializer.Serialize(headerCommon, HeaderCommonSourceGenerationContext.Default.HeaderCommon);
File.Move(fileInfo.FullName, checkFile);
File.Delete(keyFile);
checkFile = Path.Combine(checkDirectory, $"{fileInfo.Name}.json");

View File

@ -16,6 +16,12 @@ internal static partial class Helper20240911
public record Record(WorkItem WorkItem, ReadOnlyDictionary<int, Record> Children);
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Record))]
internal partial class RecordCommonSourceGenerationContext : JsonSerializerContext
{
}
public record WorkItem(string AreaPath,
string? AssignedTo,
int? BusinessValue,
@ -222,7 +228,7 @@ internal static partial class Helper20240911
logger.LogInformation("With search pattern '{SearchPattern}' found {files} workItemAndChildren", searchPattern, workItemAndChildren.Count);
if (workItemAndChildren.Count == -1)
{
string json = JsonSerializer.Serialize(workItemAndChildren, new JsonSerializerOptions() { WriteIndented = true });
string json = JsonSerializer.Serialize(workItemAndChildren, RecordCommonSourceGenerationContext.Default.ReadOnlyDictionaryInt32Record);
File.WriteAllText(".json", json);
}
foreach (string workItemType in workItemTypes)