Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ trim_trailing_whitespace = false
# Disabling this as the project uses English-only strings and doesn't require .resx localization.
dotnet_diagnostic.CA1303.severity = none

# CA1854: Prefer the IDictionary.TryGetValue method.
dotnet_diagnostic.CA1854.severity = warning

# CA1851: Possible multiple enumerations of IEnumerable collection.
dotnet_diagnostic.CA1851.severity = warning

# CA2012: Use ValueTasks correctly.
dotnet_diagnostic.CA2012.severity = warning

# CA2016: Forward the CancellationToken parameter to methods that take one.
dotnet_diagnostic.CA2016.severity = warning

# CA2021: Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types.
dotnet_diagnostic.CA2021.severity = warning

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = warning

Expand Down Expand Up @@ -166,6 +181,8 @@ csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion
# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
dotnet_diagnostic.IDE0019.severity = warning
dotnet_diagnostic.IDE0260.severity = warning
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
Expand Down
2 changes: 2 additions & 0 deletions SonarAnalyzer.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ dotnet_diagnostic.S6966.severity = warning
dotnet_diagnostic.S6618.severity = warning
dotnet_diagnostic.S1905.severity = warning
dotnet_diagnostic.S3358.severity = warning
dotnet_diagnostic.S1118.severity = warning
dotnet_diagnostic.S4136.severity = warning
2 changes: 1 addition & 1 deletion src/Engine/IO/JsonObject/TopLevelScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Refedle.Engine.IO.JsonObject;
/// <summary>
/// Scans a JSON Object file and extracts all top-level key-value pairs in a single pass.
/// </summary>
public sealed class TopLevelScanner
public static class TopLevelScanner
{
private const int InitialBufferSize = 1024 * 1024; // 1 MB
private const int MaxBufferSize = 16 * 1024 * 1024; // 16 MB
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Recipes/MorphActionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Refedle.Engine.Recipes;
/// Constructs <see cref="MorphAction"/> instances from parsed field dictionaries.
/// Field values are expected to be already unquoted.
/// </summary>
internal sealed class MorphActionParser
internal static class MorphActionParser
{
/// <summary>
/// Parses a field dictionary into a <see cref="MorphAction"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Recipes/RecipeYamlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Refedle.Engine.Recipes;
/// Serializes and deserializes <see cref="Recipe"/> objects to and from YAML.
/// AOT-safe: no reflection is used.
/// </summary>
internal sealed class RecipeYamlSerializer
internal static class RecipeYamlSerializer
{
/// <summary>
/// Serializes a recipe to a YAML string.
Expand Down
16 changes: 8 additions & 8 deletions src/Engine/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ public static class Results
/// <returns>A Result representing a successful operation.</returns>
public static Result Success() => new(true, default);

/// <summary>
/// Creates a failed result with an error message.
/// </summary>
/// <param name="error">The error message describing why the operation failed.</param>
/// <returns>A Result representing a failed operation.</returns>
/// <exception cref="ArgumentException">Thrown when error is null, empty, or whitespace.</exception>
public static Result Failure(string error) => new(false, new ErrorMessage(error));

/// <summary>
/// Creates a successful result with a value.
/// </summary>
Expand All @@ -27,6 +19,14 @@ public static class Results
/// <returns>A Result{T} representing a successful operation with a value.</returns>
public static Result<T> Success<T>(T value) => new(true, value);

/// <summary>
/// Creates a failed result with an error message.
/// </summary>
/// <param name="error">The error message describing why the operation failed.</param>
/// <returns>A Result representing a failed operation.</returns>
/// <exception cref="ArgumentException">Thrown when error is null, empty, or whitespace.</exception>
public static Result Failure(string error) => new(false, new ErrorMessage(error));

/// <summary>
/// Creates a failed result with an error message.
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions src/Generators/FormatDispatcherGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

namespace Refedle.Generators;

/// <summary>Generates dispatch code for record readers and writers.</summary>
[Generator]
public class FormatDispatcherGenerator : IIncrementalGenerator
{
/// <summary>Initializes the incremental generation pipeline.</summary>
public void Initialize(IncrementalGeneratorInitializationContext context)
{
// Collect all reader and writer declarations in a single pass
Expand Down Expand Up @@ -95,16 +97,16 @@ out FormatInfo? formatInfo
if (arg is not null)
{
var formatValue = arg; // e.g. "DataFormat.Csv"
if (formatValue.StartsWith("DataFormat."))
if (formatValue.StartsWith("DataFormat.", StringComparison.Ordinal))
{
formatValue = formatValue.Substring("DataFormat.".Length);
}

var createdType = ExtractCreatedType(typeDecl);

var declaredSymbol =
context.SemanticModel.GetDeclaredSymbol(typeDecl) as INamedTypeSymbol;
var typeName = declaredSymbol?.Name ?? string.Empty;
var typeName = context.SemanticModel.GetDeclaredSymbol(typeDecl) is INamedTypeSymbol declaredSymbol
? declaredSymbol.Name
: string.Empty;
var isReader = name.Contains("RecordReader");

if (!string.IsNullOrEmpty(typeName) && !string.IsNullOrEmpty(createdType))
Expand Down
6 changes: 6 additions & 0 deletions src/Generators/Refedle.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<!-- Zero-Warning Policy -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>

<ItemGroup>
Expand Down