-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hierarchical record creation from generated factories
We now invoke factories automatically whenever they are found. A new diagnostic is reported if a `Create(dynamic value)` factory method is found in the record but it's not accessible to the generated factory in the current assembly. The diagnostic is nevertheless a warning since in that case we still generate our custom factory, but users will not get the benefit of invoking their custom factory (although this might be by design if it's just a coincidence in the method name and signature they chose for an entirely unrelated purpose). Closes #47
- Loading branch information
Showing
8 changed files
with
157 additions
and
40 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 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,20 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Merq.Records; | ||
|
||
public partial record Point(int X, int Y); | ||
|
||
public partial record Line(Point Start, Point End); | ||
|
||
public record Buffer(List<Line> Lines) | ||
{ | ||
public static Buffer Create(dynamic value) | ||
{ | ||
var lines = new List<Line>(); | ||
foreach (var line in value.Lines) | ||
{ | ||
//lines.Add(Line.Create(line)); | ||
} | ||
return new Buffer(lines); | ||
} | ||
} |
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