diff --git a/SpreadCheetah.SourceGenerator.SnapshotTest/Snapshots/G.PropertyType_ClassWithIndexer#MyNamespace.MyContext.g.verified.cs b/SpreadCheetah.SourceGenerator.SnapshotTest/Snapshots/G.PropertyType_ClassWithIndexer#MyNamespace.MyContext.g.verified.cs
new file mode 100644
index 00000000..5779297d
--- /dev/null
+++ b/SpreadCheetah.SourceGenerator.SnapshotTest/Snapshots/G.PropertyType_ClassWithIndexer#MyNamespace.MyContext.g.verified.cs
@@ -0,0 +1,35 @@
+//HintName: MyNamespace.MyContext.g.cs
+//
+#nullable enable
+using SpreadCheetah;
+using SpreadCheetah.SourceGeneration;
+using SpreadCheetah.Styling;
+using System;
+using System.Buffers;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MyNamespace
+{
+ public partial class MyContext
+ {
+ private static MyContext? _default;
+ public static MyContext Default => _default ??= new MyContext();
+
+ public MyContext()
+ {
+ }
+
+ private WorksheetRowTypeInfo? _MyClass;
+ public WorksheetRowTypeInfo MyClass => _MyClass
+ ??= EmptyWorksheetRowContext.CreateTypeInfo();
+
+ private static DataCell ConstructTruncatedDataCell(string? value, int truncateLength)
+ {
+ return value is null || value.Length <= truncateLength
+ ? new DataCell(value)
+ : new DataCell(value.AsMemory(0, truncateLength));
+ }
+ }
+}
diff --git a/SpreadCheetah.SourceGenerator.SnapshotTest/Tests/PropertyTypeTests.cs b/SpreadCheetah.SourceGenerator.SnapshotTest/Tests/PropertyTypeTests.cs
index f607d8d1..ecde1ce3 100644
--- a/SpreadCheetah.SourceGenerator.SnapshotTest/Tests/PropertyTypeTests.cs
+++ b/SpreadCheetah.SourceGenerator.SnapshotTest/Tests/PropertyTypeTests.cs
@@ -85,4 +85,27 @@ public partial class MyContext : WorksheetRowContext;
// Act & Assert
return TestHelper.CompileAndVerify(source);
}
+
+ [Fact]
+ public Task PropertyType_ClassWithIndexer()
+ {
+ // Arrange
+ const string source = """
+ using SpreadCheetah.SourceGeneration;
+ using System;
+
+ namespace MyNamespace;
+
+ public class MyClass
+ {
+ public int this[int index] => index;
+ }
+
+ [WorksheetRow(typeof(MyClass))]
+ public partial class MyContext : WorksheetRowContext;
+ """;
+
+ // Act & Assert
+ return TestHelper.CompileAndVerify(source);
+ }
}
diff --git a/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs b/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs
index f797e374..af8a2b50 100644
--- a/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs
+++ b/SpreadCheetah.SourceGenerator/Extensions/SymbolExtensions.cs
@@ -48,6 +48,7 @@ public static bool IsInstancePropertyWithPublicGetter(
{
DeclaredAccessibility: Accessibility.Public,
IsStatic: false,
+ IsIndexer: false,
IsWriteOnly: false
};
}