Commit 6b259eb9 authored by Jesse McGrew's avatar Jesse McGrew
Browse files

Clean up IDE0090 lint messages by simplifying "new" expressions.

parent 2e0f8cc2884d
......@@ -18,7 +18,7 @@ namespace ZilfAnalyzers
const string MessageFormat = "This exception should use a diagnostic code instead";
const string Category = "Error Reporting";
static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule = new(
DiagnosticIds.ExceptionShouldUseDiagnosticCode, Title, MessageFormat,
Category, DiagnosticSeverity.Warning, isEnabledByDefault: true);
......
......@@ -12,7 +12,7 @@ namespace ZilfAnalyzers
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class MessageConstantAnalyzer : DiagnosticAnalyzer
{
static readonly DiagnosticDescriptor Rule_DuplicateMessageCode = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule_DuplicateMessageCode = new(
DiagnosticIds.DuplicateMessageCode,
"Duplicate message code",
"The code '{0}' is used more than once in message set '{1}'",
......@@ -20,7 +20,7 @@ namespace ZilfAnalyzers
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
static readonly DiagnosticDescriptor Rule_DuplicateMessageFormat = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule_DuplicateMessageFormat = new(
DiagnosticIds.DuplicateMessageFormat,
"Duplicate message format",
"This format string is used more than once in message set '{0}'",
......@@ -28,7 +28,7 @@ namespace ZilfAnalyzers
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
static readonly DiagnosticDescriptor Rule_PrefixedMessageFormat = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule_PrefixedMessageFormat = new(
DiagnosticIds.PrefixedMessageFormat,
"Message has hardcoded prefix",
"This format string has the prefix '{0}', which should be moved to the call site",
......@@ -36,9 +36,9 @@ namespace ZilfAnalyzers
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public static readonly Regex PrefixedMessageFormatRegex = new Regex(
public static readonly Regex PrefixedMessageFormatRegex = new(
@"^(?<prefix>[^a-z .,;:()\[\]{}]+)(?<rest>: .*)$");
public static readonly Regex FormatTokenRegex = new Regex(
public static readonly Regex FormatTokenRegex = new(
@"\{(?<number>\d+)(?<suffix>:[^}]*)?\}");
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
......
......@@ -13,7 +13,7 @@ namespace ZilfAnalyzers
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ZilObjectAnalyzer : DiagnosticAnalyzer
{
static readonly DiagnosticDescriptor Rule_ComparingZilObjectsWithEquals = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule_ComparingZilObjectsWithEquals = new(
DiagnosticIds.ComparingZilObjectsWithEquals,
"Comparing ZilObjects with Equals",
"'{0}' is for hash-safe comparisons: prefer methods with explicit MDL comparison behavior",
......@@ -21,7 +21,7 @@ namespace ZilfAnalyzers
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
static readonly DiagnosticDescriptor Rule_PartiallyOverriddenZilObjectComparison = new DiagnosticDescriptor(
static readonly DiagnosticDescriptor Rule_PartiallyOverriddenZilObjectComparison = new(
DiagnosticIds.PartiallyOverriddenZilObjectComparison,
"Partially overridden ZilObject comparison",
"'{0}' overrides {1} but does not override {2}",
......
......@@ -72,7 +72,7 @@ namespace Dezapf
class CompoundChunk : Chunk
{
protected readonly List<Chunk> contents = new List<Chunk>();
protected readonly List<Chunk> contents = new();
/*
public static CompoundChunk Combine(Chunk first, Chunk second)
......
......@@ -28,7 +28,7 @@ namespace Dezapf
{
int zversion;
readonly Dictionary<ushort, ZOpAttribute> opcodes = new Dictionary<ushort, ZOpAttribute>();
readonly Dictionary<ushort, ZOpAttribute> opcodes = new();
public Context()
{
......
......@@ -67,7 +67,7 @@ namespace Dezapf
}
}
readonly List<Range> list = new List<Range>();
readonly List<Range> list = new();
public void Add(Range range)
{
......
......@@ -27,7 +27,7 @@ namespace Zapf.Parsing
{
class Tokenizer : IDisposable
{
static readonly Dictionary<char, TokenType> CharTokens = new Dictionary<char, TokenType>
static readonly Dictionary<char, TokenType> CharTokens = new()
{
{ '=', TokenType.Equals },
{ ',', TokenType.Comma },
......
......@@ -66,7 +66,7 @@ namespace Zapf
Context = context;
}
public static readonly AssemblyResult Failed = new AssemblyResult(false, null);
public static readonly AssemblyResult Failed = new(false, null);
[MemberNotNullWhen(true, nameof(Context))]
public bool Success { get; }
......
......@@ -38,8 +38,8 @@ namespace Zilf.Common.StringEncoding
}
}
readonly List<string> allTexts = new List<string>();
readonly StringEncoder encoder = new StringEncoder();
readonly List<string> allTexts = new();
readonly StringEncoder encoder = new();
/// <summary>
/// Adds some text to the accumulator.
......
......@@ -59,8 +59,8 @@ namespace Zilf.Common.StringEncoding
};
readonly byte[][] charset;
readonly List<AbbrevEntry> abbrevs = new List<AbbrevEntry>();
static readonly AbbrevComparer abbrevLengthComparer = new AbbrevComparer();
readonly List<AbbrevEntry> abbrevs = new();
static readonly AbbrevComparer abbrevLengthComparer = new();
public StringEncoder()
{
......
......@@ -79,9 +79,9 @@ namespace Zilf.Common.StringEncoding.SuffixTrees
}
}
public KeyCollection Keys => new KeyCollection(dict);
public KeyCollection Keys => new(dict);
public ValueCollection Values => new ValueCollection(dict);
public ValueCollection Values => new(dict);
public IEnumerator<KeyValuePair<char, Edge<T>>> GetEnumerator()
{
......
......@@ -31,7 +31,7 @@ namespace Zilf.Common.StringEncoding.SuffixTrees
private int depth = -1;
private int leafCount = -1;
private int resultCount = -1;
private EdgeMap<T> edges = new EdgeMap<T>();
private EdgeMap<T> edges = new();
public Node<T>? Suffix { get; set; } = null;
public ref EdgeMap<T> Edges => ref edges;
......
......@@ -66,9 +66,9 @@ namespace Zilf.Common.StringEncoding.SuffixTrees
}
}
public KeyCollection Keys => new KeyCollection(dict);
public KeyCollection Keys => new(dict);
public ValueCollection Values => new ValueCollection(dict);
public ValueCollection Values => new(dict);
public IEnumerator<KeyValuePair<char, IEdge<T>>> GetEnumerator()
{
......
......@@ -278,8 +278,8 @@ namespace Zilf.Emit
}
ILabel? pendingLabel;
readonly Dictionary<ILabel, ILabel> aliases = new Dictionary<ILabel, ILabel>();
readonly LinkedList<Line> lines = new LinkedList<Line>();
readonly Dictionary<ILabel, ILabel> aliases = new();
readonly LinkedList<Line> lines = new();
/// <summary>
/// Gets or sets the delegate that will be used to combine adjacent instructions.
......
......@@ -22,8 +22,8 @@ namespace Zilf.Emit.Zap
{
class DebugFileBuilder : IDebugFileBuilder
{
readonly Dictionary<string, int> files = new Dictionary<string, int>();
readonly List<string> storedLines = new List<string>();
readonly Dictionary<string, int> files = new();
readonly List<string> storedLines = new();
public int GetFileNumber(string? filename)
{
......
......@@ -30,26 +30,26 @@ namespace Zilf.Emit.Zap
{
const string INDENT = "\t";
internal static readonly NumericOperand ZERO = new NumericOperand(0);
internal static readonly NumericOperand ZERO = new(0);
internal static readonly NumericOperand ONE = new NumericOperand(1);
internal static readonly NumericOperand ONE = new(1);
static readonly ConstantLiteralOperand VOCAB = new ConstantLiteralOperand("VOCAB");
static readonly ConstantLiteralOperand VOCAB = new("VOCAB");
// all global names go in here
readonly Dictionary<string, string> symbols = new Dictionary<string, string>(250);
readonly List<ObjectBuilder> objects = new List<ObjectBuilder>(100);
readonly Dictionary<string, PropertyBuilder> props = new Dictionary<string, PropertyBuilder>(32);
readonly Dictionary<string, FlagBuilder> flags = new Dictionary<string, FlagBuilder>(32);
readonly Dictionary<string, IOperand> constants = new Dictionary<string, IOperand>(100);
readonly List<GlobalBuilder> globals = new List<GlobalBuilder>(100);
readonly List<TableBuilder> impureTables = new List<TableBuilder>(10);
readonly List<TableBuilder> pureTables = new List<TableBuilder>(10);
readonly List<WordBuilder> vocabulary = new List<WordBuilder>(100);
readonly HashSet<char> siBreaks = new HashSet<char>();
readonly Dictionary<string, IOperand> stringPool = new Dictionary<string, IOperand>(100);
readonly Dictionary<int, NumericOperand> numberPool = new Dictionary<int, NumericOperand>(50);
readonly Dictionary<string, string> symbols = new(250);
readonly List<ObjectBuilder> objects = new(100);
readonly Dictionary<string, PropertyBuilder> props = new(32);
readonly Dictionary<string, FlagBuilder> flags = new(32);
readonly Dictionary<string, IOperand> constants = new(100);
readonly List<GlobalBuilder> globals = new(100);
readonly List<TableBuilder> impureTables = new(10);
readonly List<TableBuilder> pureTables = new(10);
readonly List<WordBuilder> vocabulary = new(100);
readonly HashSet<char> siBreaks = new();
readonly Dictionary<string, IOperand> stringPool = new(100);
readonly Dictionary<int, NumericOperand> numberPool = new(50);
readonly IZapStreamFactory streamFactory;
internal readonly int zversion;
......
......@@ -44,8 +44,8 @@ namespace Zilf.Emit.Zap
}
}
readonly List<PropertyEntry> props = new List<PropertyEntry>();
readonly List<FlagBuilder> flags = new List<FlagBuilder>();
readonly List<PropertyEntry> props = new();
readonly List<FlagBuilder> flags = new();
public ObjectBuilder(string name)
{
......
......@@ -30,9 +30,9 @@ namespace Zilf.Emit.Zap
{
class RoutineBuilder : ConstantOperandBase, IRoutineBuilder
{
internal static readonly Label RTRUE = new Label("TRUE");
internal static readonly Label RFALSE = new Label("FALSE");
internal static readonly VariableOperand STACK = new VariableOperand("STACK");
internal static readonly Label RTRUE = new("TRUE");
internal static readonly Label RFALSE = new("FALSE");
internal static readonly VariableOperand STACK = new("STACK");
const char INDENT = '\t';
readonly GameBuilder game;
......@@ -45,9 +45,9 @@ namespace Zilf.Emit.Zap
int nextLabelNum;
string? pendingDebugText;
readonly List<LocalBuilder> requiredParams = new List<LocalBuilder>();
readonly List<LocalBuilder> optionalParams = new List<LocalBuilder>();
readonly List<LocalBuilder> locals = new List<LocalBuilder>();
readonly List<LocalBuilder> requiredParams = new();
readonly List<LocalBuilder> optionalParams = new();
readonly List<LocalBuilder> locals = new();
public RoutineBuilder(GameBuilder game, string name, bool entryPoint, bool cleanStack)
{
......
......@@ -23,9 +23,9 @@ namespace Zilf.Emit.Zap
{
class TableBuilder : ConstantOperandBase, ITableBuilder
{
readonly List<short> numericValues = new List<short>();
readonly List<IOperand> operandValues = new List<IOperand>();
readonly List<byte> types = new List<byte>();
readonly List<short> numericValues = new();
readonly List<IOperand> operandValues = new();
readonly List<byte> types = new();
int size;
const byte WORD_FLAG = 1;
......
......@@ -136,7 +136,7 @@ namespace Zilf.Playground.Services.Builds
this.jsInterop = jsInterop;
}
private static readonly Regex StoryFileRegExp = new Regex(@"\.z\d$", RegexOptions.IgnoreCase);
private static readonly Regex StoryFileRegExp = new(@"\.z\d$", RegexOptions.IgnoreCase);
public async Task CompileWorkspaceAsync()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment