Added and applied styles for private readonly fields, private fields to Extensions and Common folders.

- Some renamings and code cleanups
- Chained method calls, binary expressions and binary patterns will now break into newlines
- Type param constraints and base constructor calls will be on the new line
This commit is contained in:
Kwoth
2021-12-27 03:46:30 +01:00
parent 9ae030a5c5
commit 1b0392dfab
85 changed files with 1015 additions and 906 deletions

View File

@@ -4,8 +4,11 @@ namespace NadekoBot;
public abstract record SmartText
{
public bool IsEmbed => this is SmartEmbedText;
public bool IsPlainText => this is SmartPlainText;
public bool IsEmbed
=> this is SmartEmbedText;
public bool IsPlainText
=> this is SmartPlainText;
public static SmartText operator +(SmartText text, string input)
=> text switch
@@ -14,7 +17,7 @@ public abstract record SmartText
SmartPlainText spt => new SmartPlainText(spt.Text + input),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static SmartText operator +(string input, SmartText text)
=> text switch
{
@@ -22,10 +25,11 @@ public abstract record SmartText
SmartPlainText spt => new SmartPlainText(input + spt.Text),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static SmartText CreateFrom(string input)
{
if (string.IsNullOrWhiteSpace(input) || !input.TrimStart().StartsWith("{"))
if (string.IsNullOrWhiteSpace(input) ||
!input.TrimStart().StartsWith("{"))
{
return new SmartPlainText(input);
}
@@ -34,6 +38,9 @@ public abstract record SmartText
{
var smartEmbedText = JsonConvert.DeserializeObject<SmartEmbedText>(input);
if (smartEmbedText is null)
throw new();
smartEmbedText.NormalizeFields();
if (!smartEmbedText.IsValid)