From 093ee7c184c5a89e4fc2d464118559a2ed341a3d Mon Sep 17 00:00:00 2001 From: sveinungf Date: Sun, 18 Feb 2024 12:22:13 +0100 Subject: [PATCH] Src gen: Remove unused code --- .../Extensions/SymbolExtensions.cs | 6 +----- SpreadCheetah.SourceGenerator/Helpers/EquatableArray.cs | 2 ++ SpreadCheetah.SourceGenerator/Helpers/HashCode.cs | 2 ++ SpreadCheetah.SourceGenerator/Helpers/LocationMap.cs | 5 ----- SpreadCheetah.SourceGenerator/Models/RowTypeProperty.cs | 6 ------ 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs b/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs index e48397e7..08fb0f71 100644 --- a/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs +++ b/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs @@ -68,10 +68,6 @@ public static RowTypeProperty ToRowTypeProperty( return new RowTypeProperty( ColumnHeader: columnHeader, - Name: p.Name, - TypeFullName: p.Type.ToDisplayString(), - TypeName: p.Type.Name, - TypeNullableAnnotation: p.NullableAnnotation, - TypeSpecialType: p.Type.SpecialType); + Name: p.Name); } } diff --git a/SpreadCheetah.SourceGenerator/Helpers/EquatableArray.cs b/SpreadCheetah.SourceGenerator/Helpers/EquatableArray.cs index e0a737a8..4efa817a 100644 --- a/SpreadCheetah.SourceGenerator/Helpers/EquatableArray.cs +++ b/SpreadCheetah.SourceGenerator/Helpers/EquatableArray.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Diagnostics.CodeAnalysis; namespace SpreadCheetah.SourceGenerator.Helpers; @@ -6,6 +7,7 @@ namespace SpreadCheetah.SourceGenerator.Helpers; /// Based on the implementation from: /// https://github.com/CommunityToolkit/dotnet/blob/main/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/EquatableArray%7BT%7D.cs /// +[ExcludeFromCodeCoverage] internal readonly struct EquatableArray(T[] underlyingArray) : IEquatable>, IReadOnlyCollection where T : IEquatable diff --git a/SpreadCheetah.SourceGenerator/Helpers/HashCode.cs b/SpreadCheetah.SourceGenerator/Helpers/HashCode.cs index 356fbc60..5435febb 100644 --- a/SpreadCheetah.SourceGenerator/Helpers/HashCode.cs +++ b/SpreadCheetah.SourceGenerator/Helpers/HashCode.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -10,6 +11,7 @@ namespace SpreadCheetah.SourceGenerator.Helpers; /// https://github.com/CommunityToolkit/dotnet/blob/7b53ae23dfc6a7fb12d0fc058b89b6e948f48448/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs /// [StructLayout(LayoutKind.Auto)] +[ExcludeFromCodeCoverage] #pragma warning disable CA1066 // Implement IEquatable when overriding Object.Equals internal struct HashCode #pragma warning restore CA1066 // Implement IEquatable when overriding Object.Equals diff --git a/SpreadCheetah.SourceGenerator/Helpers/LocationMap.cs b/SpreadCheetah.SourceGenerator/Helpers/LocationMap.cs index ad2f4d2e..a0aabce8 100644 --- a/SpreadCheetah.SourceGenerator/Helpers/LocationMap.cs +++ b/SpreadCheetah.SourceGenerator/Helpers/LocationMap.cs @@ -10,11 +10,6 @@ public static Location ToLocation(this LocationInfo info) return Location.Create(info.FilePath, info.TextSpan, info.LineSpan); } - public static LocationInfo? ToLocationInfo(this SyntaxNode node) - { - return node.GetLocation().ToLocationInfo(); - } - public static LocationInfo? ToLocationInfo(this Location location) { if (location.SourceTree is null) diff --git a/SpreadCheetah.SourceGenerator/Models/RowTypeProperty.cs b/SpreadCheetah.SourceGenerator/Models/RowTypeProperty.cs index 9b4321eb..ad54e740 100644 --- a/SpreadCheetah.SourceGenerator/Models/RowTypeProperty.cs +++ b/SpreadCheetah.SourceGenerator/Models/RowTypeProperty.cs @@ -1,11 +1,5 @@ -using Microsoft.CodeAnalysis; - namespace SpreadCheetah.SourceGenerator.Models; internal sealed record RowTypeProperty( string Name, - string TypeName, - string TypeFullName, - NullableAnnotation TypeNullableAnnotation, - SpecialType TypeSpecialType, string ColumnHeader); \ No newline at end of file