Add nullability directive and make variant non-nullable

This commit is contained in:
Dean Herbert 2021-09-15 17:09:02 +09:00
parent 15e3f95c87
commit a150fb2996
3 changed files with 9 additions and 6 deletions

View File

@ -5,6 +5,8 @@
using osu.Game.Database;
using Realms;
#nullable enable
namespace osu.Game.Configuration
{
[MapTo(@"RulesetSetting")]
@ -16,12 +18,13 @@ public class RealmRulesetSetting : RealmObject, IHasGuidPrimaryKey
[Indexed]
public int RulesetID { get; set; }
public int? Variant { get; set; }
[Indexed]
public int Variant { get; set; }
public string Key { get; set; }
public string Key { get; set; } = string.Empty;
[MapTo(nameof(Value))]
public string ValueString { get; set; }
public string ValueString { get; set; } = string.Empty;
public object Value
{

View File

@ -465,7 +465,7 @@ private void migrateDataToRealm()
ValueString = dkb.StringValue,
Key = dkb.Key,
RulesetID = dkb.RulesetID.Value,
Variant = dkb.Variant
Variant = dkb.Variant ?? 0,
});
}
}

View File

@ -16,7 +16,7 @@ public abstract class RulesetConfigManager<TLookup> : ConfigManager<TLookup>, IR
{
private readonly RealmContextFactory realmFactory;
private readonly int? variant;
private readonly int variant;
private List<RealmRulesetSetting> databasedSettings = new List<RealmRulesetSetting>();
@ -31,7 +31,7 @@ protected RulesetConfigManager(SettingsStore store, RulesetInfo ruleset, int? va
rulesetId = ruleset.ID ?? -1;
this.variant = variant;
this.variant = variant ?? 0;
Load();