Fixes bug with configurations (#236)
- [X] Changes brace style to enforced - [X] Fixes null source with assemblies.json - [X] Fixes bad path for missing json files Bumps release version
This commit is contained in:
parent
96465c8530
commit
c3d2740983
5 changed files with 88 additions and 27 deletions
|
|
@ -12,6 +12,7 @@ max_line_length=125
|
|||
# Microsoft .NET properties
|
||||
csharp_new_line_before_members_in_object_initializers=false
|
||||
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
|
||||
csharp_prefer_braces=true:suggestion
|
||||
csharp_space_after_cast=false
|
||||
dotnet_diagnostic.bc42024.severity=suggestion
|
||||
dotnet_diagnostic.cs0078.severity=none
|
||||
|
|
@ -137,6 +138,7 @@ dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestio
|
|||
|
||||
# ReSharper properties
|
||||
resharper_apply_auto_detected_rules=false
|
||||
resharper_braces_redundant=true
|
||||
resharper_case_block_braces=next_line_shifted_2
|
||||
resharper_constructor_or_destructor_body=expression_body
|
||||
resharper_csharp_int_align_comments=true
|
||||
|
|
@ -238,6 +240,16 @@ resharper_web_config_type_not_resolved_highlighting=warning
|
|||
resharper_web_config_wrong_module_highlighting=warning
|
||||
resharper_wrong_indent_size_highlighting=warning
|
||||
|
||||
# ReSharper inspection severities
|
||||
resharper_enforce_do_while_statement_braces_highlighting=hint
|
||||
resharper_enforce_fixed_statement_braces_highlighting=hint
|
||||
resharper_enforce_foreach_statement_braces_highlighting=hint
|
||||
resharper_enforce_for_statement_braces_highlighting=hint
|
||||
resharper_enforce_if_statement_braces_highlighting=hint
|
||||
resharper_enforce_lock_statement_braces_highlighting=hint
|
||||
resharper_enforce_using_statement_braces_highlighting=hint
|
||||
resharper_enforce_while_statement_braces_highlighting=hint
|
||||
|
||||
[*.{sln,csproj,bat}]
|
||||
end_of_line=crlf
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
[
|
||||
"Argon2.Bindings.dll",
|
||||
"BouncyCastle.Crypto.dll",
|
||||
"MailKit.dll",
|
||||
"Microsoft.AspNetCore.Connections.Abstractions.dll",
|
||||
"Microsoft.AspNetCore.Http.Features.dll",
|
||||
"Microsoft.Extensions.Configuration.Abstractions.dll",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions.dll",
|
||||
"Microsoft.Extensions.Hosting.Abstractions.dll",
|
||||
"Microsoft.Extensions.Logging.Abstractions.dll",
|
||||
"Microsoft.Extensions.Primitives.dll",
|
||||
"MimeKit.dll",
|
||||
"System.IO.Pipelines.dll",
|
||||
"Zlib.Bindings.dll",
|
||||
"UOContent.dll"
|
||||
]
|
||||
[
|
||||
"Argon2.Bindings.dll",
|
||||
"BouncyCastle.Crypto.dll",
|
||||
"MailKit.dll",
|
||||
"Microsoft.AspNetCore.Connections.Abstractions.dll",
|
||||
"Microsoft.AspNetCore.Http.Features.dll",
|
||||
"Microsoft.Extensions.Configuration.Abstractions.dll",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions.dll",
|
||||
"Microsoft.Extensions.Hosting.Abstractions.dll",
|
||||
"Microsoft.Extensions.Logging.Abstractions.dll",
|
||||
"Microsoft.Extensions.Primitives.dll",
|
||||
"MimeKit.dll",
|
||||
"System.IO.Pipelines.dll",
|
||||
"Zlib.Bindings.dll",
|
||||
"UOContent.dll"
|
||||
]
|
||||
|
|
@ -60,7 +60,9 @@ namespace Server
|
|||
public static string GetOrUpdateSetting(string key, string defaultValue)
|
||||
{
|
||||
if (m_Settings.settings.TryGetValue(key, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
SetSetting(key, value = defaultValue);
|
||||
return value;
|
||||
|
|
@ -71,9 +73,13 @@ namespace Server
|
|||
int value;
|
||||
|
||||
if (m_Settings.settings.TryGetValue(key, out var strValue))
|
||||
{
|
||||
value = int.TryParse(strValue, out value) ? value : defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSetting(key, (value = defaultValue).ToString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -83,9 +89,13 @@ namespace Server
|
|||
bool value;
|
||||
|
||||
if (m_Settings.settings.TryGetValue(key, out var strValue))
|
||||
{
|
||||
value = bool.TryParse(strValue, out value) ? value : defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSetting(key, (value = defaultValue).ToString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -95,9 +105,13 @@ namespace Server
|
|||
TimeSpan value;
|
||||
|
||||
if (m_Settings.settings.TryGetValue(key, out var strValue))
|
||||
{
|
||||
value = TimeSpan.TryParse(strValue, out value) ? value : defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSetting(key, (value = defaultValue).ToString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -107,9 +121,13 @@ namespace Server
|
|||
T value;
|
||||
|
||||
if (m_Settings.settings.TryGetValue(key, out var strValue))
|
||||
{
|
||||
value = Enum.TryParse(strValue, out value) ? value : defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSetting(key, (value = defaultValue).ToString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -159,7 +177,9 @@ namespace Server
|
|||
}
|
||||
|
||||
if (mocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Settings.dataDirectories.Count == 0)
|
||||
{
|
||||
|
|
@ -198,7 +218,10 @@ namespace Server
|
|||
{
|
||||
Console.Write("{0}> ", directories.Count > 0 ? "[finish] " : " ");
|
||||
var directory = Console.ReadLine();
|
||||
if (string.IsNullOrWhiteSpace(directory)) break;
|
||||
if (string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (Directory.Exists(directory))
|
||||
{
|
||||
|
|
@ -227,10 +250,15 @@ namespace Server
|
|||
// IP:Port?
|
||||
Console.Write("[{0}]> ", ips.Count > 0 ? "finish" : "0.0.0.0:2593");
|
||||
var ipStr = Console.ReadLine();
|
||||
if (string.IsNullOrWhiteSpace(ipStr)) break;
|
||||
if (string.IsNullOrWhiteSpace(ipStr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (ipStr.IndexOf(":", StringComparison.Ordinal) == -1)
|
||||
{
|
||||
ipStr += ":2593";
|
||||
}
|
||||
|
||||
if (IPEndPoint.TryParse(ipStr, out var ip))
|
||||
{
|
||||
|
|
@ -244,14 +272,19 @@ namespace Server
|
|||
} while (true);
|
||||
|
||||
if (ips.Count == 0)
|
||||
{
|
||||
ips.Add(new IPEndPoint(IPAddress.Any, 2593));
|
||||
}
|
||||
|
||||
return ips;
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
if (m_Mocked) return;
|
||||
if (m_Mocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JsonConfig.Serialize(m_FilePath, m_Settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,21 +44,33 @@ namespace Server.Json
|
|||
options.Converters.Add(new NullableStructSerializerFactory());
|
||||
options.Converters.Add(new TypeConverterFactory());
|
||||
|
||||
for (var i = 0; i < converters.Length; i++) options.Converters.Add(converters[i]);
|
||||
for (var i = 0; i < converters.Length; i++)
|
||||
{
|
||||
options.Converters.Add(converters[i]);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(string filePath, JsonSerializerOptions options = null)
|
||||
{
|
||||
if (!File.Exists(filePath)) return default;
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
var text = File.ReadAllText(filePath, Utility.UTF8);
|
||||
return JsonSerializer.Deserialize<T>(text, options ?? DefaultOptions);
|
||||
}
|
||||
|
||||
public static void Serialize(string filePath, object value, JsonSerializerOptions options = null)
|
||||
{
|
||||
if (File.Exists(filePath)) File.Delete(filePath);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
|
||||
File.WriteAllText(filePath, JsonSerializer.Serialize(value, options ?? DefaultOptions));
|
||||
}
|
||||
|
|
@ -80,7 +92,10 @@ namespace Server.Json
|
|||
public static T ToObject<T>(this JsonDocument document, JsonSerializerOptions options = null)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(document));
|
||||
}
|
||||
|
||||
return document.RootElement.ToObject<T>(options);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ namespace Server
|
|||
public static readonly bool IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || IsFreeBSD;
|
||||
public static readonly bool Unix = IsDarwin || IsFreeBSD || IsLinux;
|
||||
|
||||
private static readonly string assembliesConfiguration = "Configuration/assemblies.json";
|
||||
private const string assembliesConfiguration = "Data/assemblies.json";
|
||||
|
||||
public static bool IsRunningFromXUnit =>
|
||||
m_IsRunningFromXUnit ??= AppDomain.CurrentDomain.GetAssemblies()
|
||||
|
|
@ -444,12 +444,13 @@ namespace Server
|
|||
|
||||
ServerConfiguration.Load();
|
||||
|
||||
var assemblyPath = Path.Join(BaseDirectory, assembliesConfiguration);
|
||||
|
||||
// Load UOContent.dll
|
||||
var assemblyFiles = JsonConfig.Deserialize<List<string>>(
|
||||
Path.Join(BaseDirectory, assembliesConfiguration)
|
||||
)
|
||||
var assemblyFiles = JsonConfig.Deserialize<List<string>>(assemblyPath)
|
||||
.Select(t => Path.Join(BaseDirectory, "Assemblies", t))
|
||||
.ToArray();
|
||||
|
||||
AssemblyHandler.LoadScripts(assemblyFiles);
|
||||
|
||||
VerifySerialization();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue