From 19ca0272466374128ee20b2ae49f2b0f70601d14 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Wed, 17 Apr 2024 03:49:31 -0500 Subject: [PATCH] Fixed monumentally stupid bug. --- Schema Tests/readOnly/MemberTests.cs | 28 ++++++++++++++++++++ Schema/Schema.csproj | 2 +- Schema/src/readOnly/ReadOnlyTypeGenerator.cs | 3 +-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Schema Tests/readOnly/MemberTests.cs b/Schema Tests/readOnly/MemberTests.cs index 52f03b9..9499445 100644 --- a/Schema Tests/readOnly/MemberTests.cs +++ b/Schema Tests/readOnly/MemberTests.cs @@ -127,6 +127,34 @@ public interface IReadOnlyWrapper { """); } + [Test] + public void TestMultiIndexer() { + ReadOnlyGeneratorTestUtil.AssertGenerated( + """ + using schema.readOnly; + using System.Collections.Generic; + + namespace foo.bar { + [GenerateReadOnly] + public partial interface IWrapper { + public bool this[int x, int y] { get; set; } + } + } + """, + """ + namespace foo.bar { + public partial interface IWrapper : IReadOnlyWrapper { + bool IReadOnlyWrapper.this[int x, int y] => this[x, y]; + } + + public interface IReadOnlyWrapper { + public bool this[int x, int y] { get; } + } + } + + """); + } + [Test] public void TestNamelessTuple() { ReadOnlyGeneratorTestUtil.AssertGenerated( diff --git a/Schema/Schema.csproj b/Schema/Schema.csproj index f1026c4..146a384 100644 --- a/Schema/Schema.csproj +++ b/Schema/Schema.csproj @@ -14,7 +14,7 @@ Library for converting classes to and from binary. Provides a C# Roslyn generator that automatically implements conversion logic for simple classes. schema schema - 0.4.4 + 0.4.5 MeltyPlayer diff --git a/Schema/src/readOnly/ReadOnlyTypeGenerator.cs b/Schema/src/readOnly/ReadOnlyTypeGenerator.cs index a240cde..32a4d4a 100644 --- a/Schema/src/readOnly/ReadOnlyTypeGenerator.cs +++ b/Schema/src/readOnly/ReadOnlyTypeGenerator.cs @@ -245,9 +245,8 @@ private static void WriteMembers_( if (!isIndexer) { cbsb.Write(memberSymbol.Name.Substring(4).EscapeKeyword()); } else { + cbsb.Write("this["); for (var i = 0; i < methodSymbol.Parameters.Length; ++i) { - cbsb.Write("this["); - if (i > 0) { cbsb.Write(", "); }