mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
- More code cleanup and codestyle updates
- Fixed some possible nullref exceptions - Methods signatures now have up to 3 parameters before breakaing down each parameter in a separate line - Method invocations have the same rule, except the first parameter will be in the same line as the invocation to prevent some ugliness when passing lambas as arguments - Applied many more codestyles - Extensions folder fully reformatted
This commit is contained in:
@@ -5,7 +5,5 @@ public class CommentAttribute : Attribute
|
||||
public string Comment { get; }
|
||||
|
||||
public CommentAttribute(string comment)
|
||||
{
|
||||
Comment = comment;
|
||||
}
|
||||
=> Comment = comment;
|
||||
}
|
@@ -9,16 +9,12 @@ public class CommentGatheringTypeInspector : TypeInspectorSkeleton
|
||||
private readonly ITypeInspector innerTypeDescriptor;
|
||||
|
||||
public CommentGatheringTypeInspector(ITypeInspector innerTypeDescriptor)
|
||||
{
|
||||
this.innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException("innerTypeDescriptor");
|
||||
}
|
||||
=> this.innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException("innerTypeDescriptor");
|
||||
|
||||
public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object container)
|
||||
{
|
||||
return innerTypeDescriptor
|
||||
=> innerTypeDescriptor
|
||||
.GetProperties(type, container)
|
||||
.Select(d => new CommentsPropertyDescriptor(d));
|
||||
}
|
||||
|
||||
private sealed class CommentsPropertyDescriptor : IPropertyDescriptor
|
||||
{
|
||||
@@ -32,31 +28,29 @@ public class CommentGatheringTypeInspector : TypeInspectorSkeleton
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public Type Type { get { return baseDescriptor.Type; } }
|
||||
public Type Type
|
||||
=> baseDescriptor.Type;
|
||||
|
||||
public Type TypeOverride {
|
||||
get { return baseDescriptor.TypeOverride; }
|
||||
set { baseDescriptor.TypeOverride = value; }
|
||||
get => baseDescriptor.TypeOverride;
|
||||
set => baseDescriptor.TypeOverride = value;
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
public ScalarStyle ScalarStyle {
|
||||
get { return baseDescriptor.ScalarStyle; }
|
||||
set { baseDescriptor.ScalarStyle = value; }
|
||||
get => baseDescriptor.ScalarStyle;
|
||||
set => baseDescriptor.ScalarStyle = value;
|
||||
}
|
||||
|
||||
public bool CanWrite { get { return baseDescriptor.CanWrite; } }
|
||||
public bool CanWrite
|
||||
=> baseDescriptor.CanWrite;
|
||||
|
||||
public void Write(object target, object value)
|
||||
{
|
||||
baseDescriptor.Write(target, value);
|
||||
}
|
||||
=> baseDescriptor.Write(target, value);
|
||||
|
||||
public T GetCustomAttribute<T>() where T : Attribute
|
||||
{
|
||||
return baseDescriptor.GetCustomAttribute<T>();
|
||||
}
|
||||
=> baseDescriptor.GetCustomAttribute<T>();
|
||||
|
||||
public IObjectDescriptor Read(object target)
|
||||
{
|
||||
|
@@ -15,8 +15,15 @@ public sealed class CommentsObjectDescriptor : IObjectDescriptor
|
||||
|
||||
public string Comment { get; private set; }
|
||||
|
||||
public object Value { get { return innerDescriptor.Value; } }
|
||||
public Type Type { get { return innerDescriptor.Type; } }
|
||||
public Type StaticType { get { return innerDescriptor.StaticType; } }
|
||||
public ScalarStyle ScalarStyle { get { return innerDescriptor.ScalarStyle; } }
|
||||
public object Value
|
||||
=> innerDescriptor.Value;
|
||||
|
||||
public Type Type
|
||||
=> innerDescriptor.Type;
|
||||
|
||||
public Type StaticType
|
||||
=> innerDescriptor.StaticType;
|
||||
|
||||
public ScalarStyle ScalarStyle
|
||||
=> innerDescriptor.ScalarStyle;
|
||||
}
|
@@ -9,9 +9,7 @@ namespace NadekoBot.Common.Yml;
|
||||
public class Rgba32Converter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(Rgba32);
|
||||
}
|
||||
=> type == typeof(Rgba32);
|
||||
|
||||
public object ReadYaml(IParser parser, Type type)
|
||||
{
|
||||
@@ -31,9 +29,7 @@ public class Rgba32Converter : IYamlTypeConverter
|
||||
public class CultureInfoConverter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(CultureInfo);
|
||||
}
|
||||
=> type == typeof(CultureInfo);
|
||||
|
||||
public object ReadYaml(IParser parser, Type type)
|
||||
{
|
||||
|
@@ -7,9 +7,7 @@ namespace NadekoBot.Common.Yml;
|
||||
public class UriConverter : IYamlTypeConverter
|
||||
{
|
||||
public bool Accepts(Type type)
|
||||
{
|
||||
return type == typeof(Uri);
|
||||
}
|
||||
=> type == typeof(Uri);
|
||||
|
||||
public object ReadYaml(IParser parser, Type type)
|
||||
{
|
||||
|
@@ -26,7 +26,7 @@ public class YamlHelper
|
||||
|
||||
// Check the value and write the character.
|
||||
|
||||
if (character is >= 0xD800 and <= 0xDFFF || character > 0x10FFFF)
|
||||
if (character is >= 0xD800 and <= 0xDFFF or > 0x10FFFF)
|
||||
{
|
||||
return point;
|
||||
}
|
||||
@@ -35,13 +35,8 @@ public class YamlHelper
|
||||
}
|
||||
|
||||
public static bool IsHex(char c)
|
||||
{
|
||||
return
|
||||
c is >= '0' and <= '9' ||
|
||||
c is >= 'A' and <= 'F' ||
|
||||
c is >= 'a' and <= 'f';
|
||||
}
|
||||
|
||||
=> c is >= '0' and <= '9' or >= 'A' and <= 'F' or >= 'a' and <= 'f';
|
||||
|
||||
public static int AsHex(char c)
|
||||
{
|
||||
if (c <= '9')
|
||||
|
Reference in New Issue
Block a user