Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source generator - Improved diagnostics #79

Merged
merged 38 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1d6607f
Add PropertyAnalyzer to prepare for separating diagnostics to an anal…
sveinungf Sep 21, 2024
e1e221f
WIP for analyzer separated from source generator
sveinungf Sep 22, 2024
f2099bb
Move classes from Models to Helpers in source generator project
sveinungf Sep 22, 2024
475db2e
WIP for improving diagnostics
sveinungf Sep 22, 2024
a669168
WIP for updated location of diagnostics
sveinungf Sep 26, 2024
0dd3646
Improve diagnostic for AttributeCombinationNotSupported
sveinungf Sep 26, 2024
35d4a9c
Improve diagnostic for DuplicateColumnOrder
sveinungf Sep 27, 2024
ca1f957
WIP for analyzers on the context type
sveinungf Sep 28, 2024
493c92a
Improved diagnostic for UnsupportedPropertyType
sveinungf Sep 28, 2024
cc23888
Handle SuppressWarnings option in analyzer
sveinungf Sep 28, 2024
ad60808
Remove diagnostics code from source generator
sveinungf Sep 28, 2024
9893e4b
Update test for diagnostic
sveinungf Sep 29, 2024
67599bc
Fix for incorrect diagnostic when using CellValueConverter on a custo…
sveinungf Sep 29, 2024
af7be8e
Update CellValueConverter diagnostic tests
sveinungf Sep 29, 2024
754868d
Update diagnostic tests for CellValueTruncate
sveinungf Sep 29, 2024
8e5a015
Update snapshot tests for ColumnHeader
sveinungf Sep 29, 2024
5ef2162
Update snapshot tests for ColumnWidth
sveinungf Sep 29, 2024
743bc13
Update snapshot tests for ColumnOrder
sveinungf Sep 29, 2024
7300ae3
Remove onlyDiagnostics parameter for source generator test helper
sveinungf Sep 29, 2024
b792451
Fix diagnostic message
sveinungf Oct 4, 2024
122d8af
Set diagnostic severity in editorconfig instead of using the Workshee…
sveinungf Oct 4, 2024
942345b
Obsolete WorksheetRowGenerationOptions.SuppressWarnings
sveinungf Oct 4, 2024
1b44c01
Merge main into dev/diagnostics
sveinungf Oct 4, 2024
9e148a3
Update tests for diagnostics on the context type parameter
sveinungf Oct 4, 2024
993c745
Embed classes into test source
sveinungf Oct 4, 2024
539a302
Fix cause for xUnit warning
sveinungf Oct 4, 2024
06d5da1
Update public API snapshots with obsolete attribute parameter
sveinungf Oct 4, 2024
ce2a9f1
Replace some snapshot tests for InheritColumns with regular tests
sveinungf Oct 5, 2024
3d9f3dd
Replace remaining snapshot tests for InheritColumns with a regular test
sveinungf Oct 5, 2024
d302331
Move snapshot tests for accessibility to a separate test class
sveinungf Oct 5, 2024
4787a75
Simplify context snapshot tests
sveinungf Oct 5, 2024
726ad45
Snapshot test class for property types
sveinungf Oct 5, 2024
0f52d40
Test class for incremental source generator caching
sveinungf Oct 5, 2024
bda3e1f
Simplify remaining snapshot tests
sveinungf Oct 5, 2024
731af77
Include property name in message for diagnostic SPCH1002
sveinungf Oct 5, 2024
360e686
Ignore indexers from row types in source generator
sveinungf Oct 5, 2024
573f723
Improve coverage for diagnostics reporter
sveinungf Oct 5, 2024
fe1b130
Remove redundant checks for attributes which have AllowMultiple = false
sveinungf Oct 5, 2024
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
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
Loading