-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #77 Add support for structs and records
- Loading branch information
Showing
16 changed files
with
164 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Zomp.SyncMethodGenerator; | ||
|
||
internal enum MethodParent | ||
{ | ||
Class, | ||
Struct, | ||
Record, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Zomp.SyncMethodGenerator; | ||
|
||
/// <summary> | ||
/// Represents a class a <see cref="MethodToGenerate"/> belongs to. | ||
/// </summary> | ||
/// <param name="MethodParent">Type of container.</param> | ||
/// <param name="ClassOrStructKeyword">Indicates whether struct or class are explicitly specified for a record.</param> | ||
/// <param name="ParentName">Class name.</param> | ||
/// <param name="Modifiers">A list of modifiers.</param> | ||
/// <param name="TypeParameterListSyntax">A list of type parameters.</param> | ||
internal sealed record MethodParentDeclaration(MethodParent MethodParent, SyntaxToken ClassOrStructKeyword, string ParentName, EquatableArray<ushort> Modifiers, EquatableArray<string> TypeParameterListSyntax); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace Generator.Tests; | ||
|
||
public class ParentTests | ||
{ | ||
[Fact] | ||
public Task Struct() => """ | ||
namespace Test; | ||
public partial struct Struct | ||
{ | ||
[CreateSyncVersion] | ||
public readonly async Task MethodAsync() => await Task.Delay(1000); | ||
} | ||
""".Verify(sourceType: SourceType.Full); | ||
|
||
[Fact] | ||
public Task Record() => """ | ||
namespace Test; | ||
public partial record Record | ||
{ | ||
[CreateSyncVersion] | ||
public async Task MethodAsync() => await Task.Delay(1000); | ||
} | ||
""".Verify(sourceType: SourceType.Full); | ||
|
||
[Fact] | ||
public Task RecordStruct() => """ | ||
namespace Test; | ||
public partial record struct RecordStruct | ||
{ | ||
[CreateSyncVersion] | ||
public readonly async Task MethodAsync() => await Task.Delay(1000); | ||
} | ||
""".Verify(sourceType: SourceType.Full); | ||
|
||
[Fact] | ||
public Task RecordClass() => """ | ||
namespace Test; | ||
public partial record class Record | ||
{ | ||
[CreateSyncVersion] | ||
public async Task MethodAsync() => await Task.Delay(1000); | ||
} | ||
""".Verify(sourceType: SourceType.Full); | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/Generator.Tests/Snapshots/ParentTests.Record#Test.Record.MethodAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.Record.MethodAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
public partial record Record | ||
{ | ||
public void Method() => global::System.Threading.Thread.Sleep(1000); | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/Generator.Tests/Snapshots/ParentTests.RecordClass#Test.Record.MethodAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.Record.MethodAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
public partial record class Record | ||
{ | ||
public void Method() => global::System.Threading.Thread.Sleep(1000); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ator.Tests/Snapshots/ParentTests.RecordStruct#Test.RecordStruct.MethodAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.RecordStruct.MethodAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
public partial record struct RecordStruct | ||
{ | ||
public readonly void Method() => global::System.Threading.Thread.Sleep(1000); | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/Generator.Tests/Snapshots/ParentTests.Struct#Test.Struct.MethodAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.Struct.MethodAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
public partial struct Struct | ||
{ | ||
public readonly void Method() => global::System.Threading.Thread.Sleep(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters