File tree 6 files changed +46
-5
lines changed
6 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ public class FileExtractorSettings : IFileExtractorSettings
24
24
{
25
25
// Note: We can't serialize AbsolutePath because it contains more fields than expected. Just hope user sets correct paths and pray for the best.
26
26
private readonly IFileSystem _fileSystem ;
27
+
28
+
29
+ /// <summary>
30
+ /// Default constructor for serialization.
31
+ /// </summary>
32
+ public FileExtractorSettings ( ) : this ( FileSystem . Shared ) { }
27
33
28
34
/// <summary>
29
35
/// Creates a default new instance of <see cref="FileExtractorSettings"/>.
Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ public class LoggingSettings : ILoggingSettings
90
90
91
91
/// <inheritdoc/>
92
92
public int MaxArchivedFiles { get ; set ; }
93
+
94
+ /// <summary>
95
+ /// Default constructor for serialization.
96
+ /// </summary>
97
+ public LoggingSettings ( ) : this ( FileSystem . Shared ) { }
93
98
94
99
/// <summary>
95
100
/// Creates the default logger with logs stored in the entry directory.
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public static async Task<int> Main(string[] args)
53
53
return 0 ;
54
54
}
55
55
56
- private static IHost BuildHost ( )
56
+ public static IHost BuildHost ( )
57
57
{
58
58
// I'm not 100% sure how to wire this up to cleanly pass settings
59
59
// to ConfigureLogging; since the DI container isn't built until the host is.
@@ -67,10 +67,9 @@ private static IHost BuildHost()
67
67
var configJson = File . ReadAllText ( appFolder . CombineUnchecked ( "AppConfig.json" ) . GetFullPath ( ) ) ;
68
68
69
69
// Note: suppressed because invalid config will throw.
70
- // TODO: Fix config serialization and re-add this
71
- // config = JsonSerializer.Deserialize<AppConfig>(configJson)!;
72
- // config.Sanitize();
73
- // services.AddSingleton(config);
70
+ config = JsonSerializer . Deserialize < AppConfig > ( configJson ) ! ;
71
+ config . Sanitize ( ) ;
72
+ services . AddSingleton ( config ) ;
74
73
services . AddApp ( new AppConfig ( ) ) . Validate ( ) ;
75
74
} )
76
75
. ConfigureLogging ( ( _ , builder ) => AddLogging ( builder , config . LoggingSettings ) )
Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ public class DataModelSettings : IDataModelSettings
75
75
76
76
/// <inheritdoc />
77
77
public long MaxHashingThroughputBytesPerSecond { get ; set ; } = 0 ;
78
+
79
+ /// <summary>
80
+ /// Default constructor for serialization.
81
+ /// </summary>
82
+ public DataModelSettings ( ) : this ( FileSystem . Shared ) { }
78
83
79
84
/// <summary>
80
85
/// Creates the default datamodel settings with a given base directory.
Original file line number Diff line number Diff line change @@ -81,6 +81,18 @@ public class ConfigurationPathJsonConverter : JsonConverter<ConfigurationPath>
81
81
{
82
82
private readonly IFileSystem _fileSystem ;
83
83
84
+ /// <summary>
85
+ /// Default constructor.
86
+ /// </summary>
87
+ public ConfigurationPathJsonConverter ( )
88
+ {
89
+ _fileSystem = FileSystem . Shared ;
90
+ }
91
+
92
+ /// <summary>
93
+ /// DI constructor.
94
+ /// </summary>
95
+ /// <param name="fileSystem"></param>
84
96
public ConfigurationPathJsonConverter ( IFileSystem fileSystem )
85
97
{
86
98
_fileSystem = fileSystem ;
Original file line number Diff line number Diff line change
1
+ using FluentAssertions ;
2
+
3
+ namespace NexusMods . UI . Tests ;
4
+
5
+ public class AppStartupTests
6
+ {
7
+
8
+ [ Fact ]
9
+ public void CanBuildHost ( )
10
+ {
11
+ var host = App . Program . BuildHost ( ) ;
12
+ App . UI . Startup . BuildAvaloniaApp ( host . Services ) . Should ( ) . NotBeNull ( ) ;
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments