-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from SteveDunn/575-fix-for-when-project-conta…
…ins-a-generic-attribute-of-array-type Fix for when project contains a generic attribute of array type
- Loading branch information
Showing
10 changed files
with
3,149 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace ConsumerTests.BugFixTests; | ||
|
||
// There are no particular tests for this. The fact that it compiles without an issue | ||
public class Test<T> : Attribute { } | ||
|
||
[Test<byte[]>] | ||
public class Foo { } | ||
|
||
[ValueObject] | ||
public partial struct Vo { } | ||
|
||
public class Bar | ||
{ | ||
public Bar() | ||
{ | ||
Vo.From(123); | ||
} | ||
} | ||
|
||
|
48 changes: 48 additions & 0 deletions
48
tests/SnapshotTests/BugFixes/Bug575_AttributesWithArraysBreaksGenerator.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,48 @@ | ||
using System.Threading.Tasks; | ||
using Shared; | ||
using VerifyXunit; | ||
using Vogen; | ||
|
||
namespace SnapshotTests.BugFixes; | ||
|
||
// See https://github.com/SteveDunn/Vogen/issues/575 | ||
[UsesVerify] | ||
public class Bug575_AttributesWithArraysBreaksGenerator | ||
{ | ||
// Previously, any attribute found with an array as a parameter caused an | ||
// InvalidCastException in Vogen and stopped the generator. | ||
[Fact] | ||
public async Task Test() | ||
{ | ||
var source = """ | ||
|
||
using System; | ||
using Vogen; | ||
|
||
public class Test<T> : Attribute { } | ||
|
||
[Test<byte[]>] | ||
public class Test | ||
{ | ||
Test() => Vo.From(123); | ||
} | ||
|
||
[ValueObject] | ||
public partial struct Vo | ||
{ | ||
} | ||
|
||
|
||
"""; | ||
|
||
await RunTest(source); | ||
} | ||
|
||
|
||
private static Task RunTest(string source) => | ||
new SnapshotRunner<ValueObjectGenerator>() | ||
.WithSource(source) | ||
.IgnoreInitialCompilationErrors() | ||
.RunOnAllFrameworks(); | ||
|
||
} |
Oops, something went wrong.