Clean up some warnings (#6088)
* Clean up some warnings * Remove nullable enable Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
@@ -42,26 +42,27 @@ namespace Content.Server.Database
|
||||
}
|
||||
|
||||
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
|
||||
=> new NpgsqlInetWithMaskTypeMapping(parameters);
|
||||
{
|
||||
return new NpgsqlInetWithMaskTypeMapping(parameters);
|
||||
}
|
||||
|
||||
protected override string GenerateNonNullSqlLiteral(object value)
|
||||
{
|
||||
var cidr = ((IPAddress Address, int Subnet)) value;
|
||||
return $"INET '{cidr.Address}/{cidr.Subnet}'";
|
||||
var (address, subnet) = ((IPAddress, int)) value;
|
||||
return $"INET '{address}/{subnet}'";
|
||||
}
|
||||
|
||||
public override Expression GenerateCodeLiteral(object value)
|
||||
{
|
||||
var cidr = ((IPAddress Address, int Subnet)) value;
|
||||
var (address, subnet) = ((IPAddress, int)) value;
|
||||
return Expression.New(
|
||||
Constructor,
|
||||
Expression.Call(ParseMethod, Expression.Constant(cidr.Address.ToString())),
|
||||
Expression.Constant(cidr.Subnet));
|
||||
Expression.Call(ParseMethod, Expression.Constant(address.ToString())),
|
||||
Expression.Constant(subnet));
|
||||
}
|
||||
|
||||
static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] {typeof(string)})!;
|
||||
|
||||
static readonly ConstructorInfo Constructor =
|
||||
private static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] {typeof(string)})!;
|
||||
private static readonly ConstructorInfo Constructor =
|
||||
typeof((IPAddress, int)).GetConstructor(new[] {typeof(IPAddress), typeof(int)})!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ namespace Content.Server.Database
|
||||
}
|
||||
|
||||
public void ApplyServices(IServiceCollection services)
|
||||
=> services.AddSnakeCase();
|
||||
{
|
||||
services.AddSnakeCase();
|
||||
}
|
||||
|
||||
public void Validate(IDbContextOptions options) {}
|
||||
|
||||
@@ -33,7 +35,10 @@ namespace Content.Server.Database
|
||||
|
||||
public override string LogFragment => "Snake Case Extension";
|
||||
|
||||
public override int GetServiceProviderHashCode() => 0;
|
||||
public override int GetServiceProviderHashCode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
|
||||
{
|
||||
@@ -154,7 +159,9 @@ namespace Content.Server.Database
|
||||
public virtual void ProcessPropertyAdded(
|
||||
IConventionPropertyBuilder propertyBuilder,
|
||||
IConventionContext<IConventionPropertyBuilder> context)
|
||||
=> RewriteColumnName(propertyBuilder);
|
||||
{
|
||||
RewriteColumnName(propertyBuilder);
|
||||
}
|
||||
|
||||
public void ProcessForeignKeyOwnershipChanged(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)
|
||||
{
|
||||
@@ -237,7 +244,9 @@ namespace Content.Server.Database
|
||||
public void ProcessForeignKeyAdded(
|
||||
IConventionForeignKeyBuilder relationshipBuilder,
|
||||
IConventionContext<IConventionForeignKeyBuilder> context)
|
||||
=> relationshipBuilder.HasConstraintName(RewriteName(relationshipBuilder.Metadata.GetDefaultName()));
|
||||
{
|
||||
relationshipBuilder.HasConstraintName(RewriteName(relationshipBuilder.Metadata.GetDefaultName()));
|
||||
}
|
||||
|
||||
public void ProcessKeyAdded(IConventionKeyBuilder keyBuilder, IConventionContext<IConventionKeyBuilder> context)
|
||||
{
|
||||
@@ -289,7 +298,7 @@ namespace Content.Server.Database
|
||||
}
|
||||
}
|
||||
|
||||
private void RewriteColumnName(IConventionPropertyBuilder propertyBuilder)
|
||||
private static void RewriteColumnName(IConventionPropertyBuilder propertyBuilder)
|
||||
{
|
||||
var property = propertyBuilder.Metadata;
|
||||
var entityType = property.DeclaringEntityType;
|
||||
|
||||
Reference in New Issue
Block a user