diff --git a/Source/AppScaffolding/LibationScaffolding.cs b/Source/AppScaffolding/LibationScaffolding.cs index 64a6f9fc..5a86d7b3 100644 --- a/Source/AppScaffolding/LibationScaffolding.cs +++ b/Source/AppScaffolding/LibationScaffolding.cs @@ -408,10 +408,6 @@ namespace AppScaffolding public static void migrate_to_v11_5_0(Configuration config) { - var writeToPath = "Serilog.WriteTo"; - - //QuickFilters.FilterState? inMemoryState; - // Read file, but convert old format to new (with Name field) as necessary. if (!File.Exists(QuickFilters.JsonFile)) { @@ -448,7 +444,7 @@ namespace AppScaffolding } Debug.Assert(false, "Should not get here, QuickFilters.json deserialization issue"); } - catch (Exception ex) + catch { // Eat } diff --git a/Source/LibationFileManager/QuickFilters.cs b/Source/LibationFileManager/QuickFilters.cs index 1964c602..97500c25 100644 --- a/Source/LibationFileManager/QuickFilters.cs +++ b/Source/LibationFileManager/QuickFilters.cs @@ -29,8 +29,8 @@ namespace LibationFileManager public static string JsonFile => Path.Combine(Configuration.Instance.LibationFiles, "QuickFilters.json"); - // load json into memory. if file doesn't exist, nothing to do. save() will create if needed - public static FilterState InMemoryState { get; set; } + // load json into memory. if file doesn't exist, nothing to do. save() will create if needed + public static FilterState InMemoryState { get; set; } = null!; public static bool UseDefault { @@ -55,16 +55,19 @@ namespace LibationFileManager public record NamedFilter(string Filter, string Name) { public string Filter { get; set; } = Filter; - public string Name { get; set; } = Name; + public string? Name { get; set; } = Name; } public static IEnumerable Filters => InMemoryState.Filters.AsReadOnly(); public static void Add(NamedFilter namedFilter) { + if (namedFilter == null) + throw new ArgumentNullException(nameof(namedFilter)); + if (string.IsNullOrWhiteSpace(namedFilter.Filter)) return; - namedFilter.Filter = namedFilter.Filter?.Trim() ?? null; + namedFilter.Filter = namedFilter.Filter?.Trim() ?? string.Empty; namedFilter.Name = namedFilter.Name?.Trim() ?? null; lock (locker)