Skip to content

Commit

Permalink
Merge pull request #79 from sveinungf/dev/diagnostics
Browse files Browse the repository at this point in the history
Source generator - Improved diagnostics
  • Loading branch information
sveinungf authored Oct 5, 2024
2 parents 6eb25fe + fe1b130 commit 8850c25
Show file tree
Hide file tree
Showing 148 changed files with 2,314 additions and 5,083 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ dotnet_diagnostic.S927.severity = none
# S2094: Classes should not be empty
dotnet_diagnostic.S2094.severity = none

[{*SnapshotTest}/**.cs]
# S2699: Tests should include assertions (false positive for analyzer tests)
dotnet_diagnostic.S2699.severity = none

###############################
# SpreadCheetah Options #
###############################
[{ClassWithNoPropertiesContext.cs,NoPropertiesContext.cs}]
# SPCH1001: Type has no properties with public getters
dotnet_diagnostic.SPCH1001.severity = none

[{CustomTypeContext.cs}]
# SPCH1002: Type with unsupported property type
dotnet_diagnostic.SPCH1002.severity = none

###############################
# Threading.Analyzers Options #
###############################
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Polyfill" Version="6.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SpreadCheetah.SourceGenerator.CSharp8Test.Models
{
[WorksheetRow(typeof(ClassWithNoProperties))]
[WorksheetRowGenerationOptions(SuppressWarnings = true)]
public partial class ClassWithNoPropertiesContext : WorksheetRowContext
{
}
Expand Down
25 changes: 25 additions & 0 deletions SpreadCheetah.SourceGenerator.SnapshotTest/Helpers/AnalyzerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using SpreadCheetah.SourceGeneration;
using SpreadCheetah.SourceGenerators;

namespace SpreadCheetah.SourceGenerator.SnapshotTest.Helpers;

internal static class AnalyzerTest
{
public static CSharpAnalyzerTest<WorksheetRowAnalyzer, DefaultVerifier> CreateContext()
{
return new CSharpAnalyzerTest<WorksheetRowAnalyzer, DefaultVerifier>
{
TestState =
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net80,
AdditionalReferences =
{
MetadataReference.CreateFromFile(typeof(WorksheetRowAttribute).Assembly.Location)
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private static PortableExecutableReference[] GetAssemblyReferences()

public static SettingsTask CompileAndVerify<T>(string source,
bool replaceEscapedLineEndings = false,
bool onlyDiagnostics = false,
params object?[] parameters) where T : IIncrementalGenerator, new()
{
var syntaxTree = CSharpSyntaxTree.ParseText(source);
Expand All @@ -50,9 +49,6 @@ public static SettingsTask CompileAndVerify<T>(string source,

var task = Verify(target, settings);

if (onlyDiagnostics)
task = task.IgnoreGeneratedResult(x => x.SourceText.ToString().Contains("public WorksheetRowTypeInfo<", StringComparison.Ordinal));

return parameters.Length > 0
? task.UseParameters(parameters)
: task;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8850c25

Please sign in to comment.