Enforce new() constraint on ConfigFile<TSettings>

This commit is contained in:
Chris 2020-12-03 17:50:44 +10:30
parent 96d7d2c54a
commit 50c1b757be
3 changed files with 2 additions and 12 deletions

View file

@ -8,12 +8,12 @@ namespace TShockAPI.Configuration
/// Implements <see cref="IConfigFile{TSettings}"/> to provide a generic config file containing some settings /// Implements <see cref="IConfigFile{TSettings}"/> to provide a generic config file containing some settings
/// </summary> /// </summary>
/// <typeparam name="TSettings"></typeparam> /// <typeparam name="TSettings"></typeparam>
public class ConfigFile<TSettings> : IConfigFile<TSettings> public class ConfigFile<TSettings> : IConfigFile<TSettings> where TSettings : new()
{ {
/// <summary> /// <summary>
/// Settings managed by this config file /// Settings managed by this config file
/// </summary> /// </summary>
public virtual TSettings Settings { get; set; } public virtual TSettings Settings { get; set; } = new TSettings();
/// <summary> /// <summary>
/// Action invoked when the config file is read /// Action invoked when the config file is read

View file

@ -73,11 +73,6 @@ namespace TShockAPI.Configuration
/// </summary> /// </summary>
public class ServerSideConfig : ConfigFile<SscSettings> public class ServerSideConfig : ConfigFile<SscSettings>
{ {
/// <summary>
/// Settings managed by this configuration object
/// </summary>
public override SscSettings Settings { get; set; } = new SscSettings();
/// <summary> /// <summary>
/// Dumps all configuration options to a text file in Markdown format /// Dumps all configuration options to a text file in Markdown format
/// </summary> /// </summary>

View file

@ -592,11 +592,6 @@ namespace TShockAPI.Configuration
/// </summary> /// </summary>
public class TShockConfig : ConfigFile<TShockSettings> public class TShockConfig : ConfigFile<TShockSettings>
{ {
/// <summary>
/// TShock settings managed by this configuration object
/// </summary>
public override TShockSettings Settings { get; set; } = new TShockSettings();
/// <summary> /// <summary>
/// Upgrades the configuration file from the old format if required, then reads and returns the currently configured <see cref="TShockSettings"/> /// Upgrades the configuration file from the old format if required, then reads and returns the currently configured <see cref="TShockSettings"/>
/// </summary> /// </summary>