From dee98434e83e91bcfe5d0d77144c3efade7b04d3 Mon Sep 17 00:00:00 2001 From: MrKWatkins Date: Sun, 17 Nov 2024 14:50:02 +0000 Subject: [PATCH] Use some .NET 9 features. --- src/MrKWatkins.Ast/Node.Messages.cs | 2 +- src/MrKWatkins.Ast/Node.cs | 2 +- src/MrKWatkins.Ast/Position/BinaryFile.cs | 2 +- src/MrKWatkins.Ast/Processing/PipelineBuilder.cs | 13 ++++++------- .../Processing/PipelineStageBuilder.cs | 2 +- src/MrKWatkins.Ast/PropertyNode.cs | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/MrKWatkins.Ast/Node.Messages.cs b/src/MrKWatkins.Ast/Node.Messages.cs index fc90bfd..3a7bd33 100644 --- a/src/MrKWatkins.Ast/Node.Messages.cs +++ b/src/MrKWatkins.Ast/Node.Messages.cs @@ -5,7 +5,7 @@ namespace MrKWatkins.Ast; public abstract partial class Node where TNode : Node { - private readonly object messagesLock = new(); + private readonly Lock messagesLock = new(); private ImmutableList messages = ImmutableList.Empty; /// diff --git a/src/MrKWatkins.Ast/Node.cs b/src/MrKWatkins.Ast/Node.cs index d974482..a78bdbd 100644 --- a/src/MrKWatkins.Ast/Node.cs +++ b/src/MrKWatkins.Ast/Node.cs @@ -22,7 +22,7 @@ protected Node() /// /// The children to add. /// If any of already have a . - protected Node([InstantHandle] IEnumerable children) + protected Node([InstantHandle] params IEnumerable children) { Children = new Children(This, children); } diff --git a/src/MrKWatkins.Ast/Position/BinaryFile.cs b/src/MrKWatkins.Ast/Position/BinaryFile.cs index 9a6b537..bb5d92c 100644 --- a/src/MrKWatkins.Ast/Position/BinaryFile.cs +++ b/src/MrKWatkins.Ast/Position/BinaryFile.cs @@ -61,7 +61,7 @@ public BinaryFilePosition CreatePosition(int startIndex, int length) => public BinaryFilePosition CreateEntireFilePosition() => new(this, 0, Length); [Pure] - private static IReadOnlyList ReadStream(Stream stream) + private static byte[] ReadStream(Stream stream) { using var memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); diff --git a/src/MrKWatkins.Ast/Processing/PipelineBuilder.cs b/src/MrKWatkins.Ast/Processing/PipelineBuilder.cs index 3abc295..20d8585 100644 --- a/src/MrKWatkins.Ast/Processing/PipelineBuilder.cs +++ b/src/MrKWatkins.Ast/Processing/PipelineBuilder.cs @@ -50,7 +50,7 @@ public PipelineBuilder AddStage(string name) /// The first processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddStage(Processor processor, params Processor[] others) => + public PipelineBuilder AddStage(Processor processor, [InstantHandle] params IEnumerable> others) => AddStage(b => b.Add(processor, others)); /// @@ -60,7 +60,7 @@ public PipelineBuilder AddStage(Processor processor, params Proces /// The first processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddStage(string name, Processor processor, params Processor[] others) => + public PipelineBuilder AddStage(string name, Processor processor, [InstantHandle] params IEnumerable> others) => AddStage(b => b.WithName(name).Add(processor, others)); /// @@ -85,7 +85,7 @@ public PipelineBuilder AddParallelStage(ActionThe second processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddParallelStage(UnorderedProcessor processor1, UnorderedProcessor processor2, params UnorderedProcessor[] others) => + public PipelineBuilder AddParallelStage(UnorderedProcessor processor1, UnorderedProcessor processor2, [InstantHandle] params IEnumerable> others) => AddParallelStage(b => b.Add(processor1).Add(processor2, others)); /// @@ -97,7 +97,7 @@ public PipelineBuilder AddParallelStage(UnorderedProcessor process /// The second processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddParallelStage(string name, UnorderedProcessor processor1, UnorderedProcessor processor2, params UnorderedProcessor[] others) => + public PipelineBuilder AddParallelStage(string name, UnorderedProcessor processor1, UnorderedProcessor processor2, [InstantHandle] params IEnumerable> others) => AddParallelStage(b => b.WithName(name).Add(processor1).Add(processor2, others)); /// @@ -112,7 +112,7 @@ public PipelineBuilder AddParallelStage(string name, UnorderedProcessorThe second processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddParallelStage(int maxDegreeOfParallelism, UnorderedProcessor processor1, UnorderedProcessor processor2, params UnorderedProcessor[] others) => + public PipelineBuilder AddParallelStage(int maxDegreeOfParallelism, UnorderedProcessor processor1, UnorderedProcessor processor2, [InstantHandle] params IEnumerable> others) => AddParallelStage(b => b.Add(processor1).Add(processor2, others).WithMaxDegreeOfParallelism(maxDegreeOfParallelism)); /// @@ -128,7 +128,6 @@ public PipelineBuilder AddParallelStage(int maxDegreeOfParallelism, Unord /// The second processor to add. /// Other processors to add. /// The fluent builder. - public PipelineBuilder AddParallelStage(string name, int maxDegreeOfParallelism, UnorderedProcessor processor1, UnorderedProcessor processor2, - params UnorderedProcessor[] others) => + public PipelineBuilder AddParallelStage(string name, int maxDegreeOfParallelism, UnorderedProcessor processor1, UnorderedProcessor processor2, [InstantHandle] params IEnumerable> others) => AddParallelStage(b => b.WithName(name).Add(processor1).Add(processor2, others).WithMaxDegreeOfParallelism(maxDegreeOfParallelism)); } \ No newline at end of file diff --git a/src/MrKWatkins.Ast/Processing/PipelineStageBuilder.cs b/src/MrKWatkins.Ast/Processing/PipelineStageBuilder.cs index 2f857a7..b96cbce 100644 --- a/src/MrKWatkins.Ast/Processing/PipelineStageBuilder.cs +++ b/src/MrKWatkins.Ast/Processing/PipelineStageBuilder.cs @@ -42,7 +42,7 @@ public TSelf Add() /// The first processor to add. /// Other processors to add. /// The fluent builder. - public TSelf Add(TProcessor processor, params TProcessor[] others) + public TSelf Add(TProcessor processor, [InstantHandle] params IEnumerable others) { Processors.Add(processor); Processors.AddRange(others); diff --git a/src/MrKWatkins.Ast/PropertyNode.cs b/src/MrKWatkins.Ast/PropertyNode.cs index e426c36..b4089e3 100644 --- a/src/MrKWatkins.Ast/PropertyNode.cs +++ b/src/MrKWatkins.Ast/PropertyNode.cs @@ -21,7 +21,7 @@ protected PropertyNode() /// /// The children to add. /// If any of already have a . - protected PropertyNode([InstantHandle] IEnumerable children) + protected PropertyNode([InstantHandle] params IEnumerable children) : base(children) { }