-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(generator): add constructor-based mapping support #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
a1ad079
eb7ec6c
c3f88f0
55a992a
a6694f6
5bf0db4
0c15be8
582570d
b49237b
134ba73
7fe03ae
4ce67d3
6846d95
6a5bc1b
53154f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using System.Collections.Generic; | ||
| using Amazon.DynamoDBv2.Model; | ||
| using DynamoMapper.Runtime; | ||
|
|
||
| namespace DynamoMapper.MapperConstructor; | ||
|
|
||
| [DynamoMapper] | ||
| public static partial class PersonClassMapper | ||
| { | ||
| public static partial Dictionary<string, AttributeValue> ToItem(PersonClass personClass); | ||
|
|
||
| public static partial PersonClass FromItem(Dictionary<string, AttributeValue> item); | ||
| } | ||
|
|
||
| public class PersonClass | ||
| { | ||
| [DynamoMapperConstructor] | ||
| public PersonClass(string firstName, string lastName, int age) | ||
| { | ||
| FirstName = firstName; | ||
| LastName = lastName; | ||
| Age = age; | ||
| } | ||
|
|
||
| public string FirstName { get; } | ||
| public string LastName { get; } | ||
| public int Age { get; } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ο»Ώ<Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <LangVersion>14</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <NoWarn>$(NoWarn);CS1591</NoWarn> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="AWSSDK.DynamoDBv2" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference | ||
| Include="..\..\src\LayeredCraft.DynamoMapper.Generators\LayeredCraft.DynamoMapper.Generators.csproj" | ||
| ReferenceOutputAssembly="false" | ||
| OutputItemType="Analyzer" | ||
| /> | ||
| <ProjectReference | ||
| Include="..\..\src\LayeredCraft.DynamoMapper.Runtime\LayeredCraft.DynamoMapper.Runtime.csproj" | ||
| ReferenceOutputAssembly="true" | ||
| OutputItemType="Analyzer" | ||
| /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ο»Ώ// See https://aka.ms/new-console-template for more information | ||
|
|
||
| using System; | ||
|
|
||
| Console.WriteLine("Hello, World!"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using System.Collections.Generic; | ||
| using Amazon.DynamoDBv2.Model; | ||
| using DynamoMapper.Runtime; | ||
|
|
||
| namespace DynamoMapper.MapperConstructor; | ||
|
|
||
| [DynamoMapper] | ||
| public static partial class PersonRecordMapper | ||
| { | ||
| public static partial Dictionary<string, AttributeValue> ToItem(PersonRecord personRecord); | ||
|
|
||
| public static partial PersonRecord FromItem(Dictionary<string, AttributeValue> item); | ||
|
|
||
| // public static void Do() | ||
| // { | ||
| // var person = new PersonRecord | ||
| // { | ||
| // FirstName = "John", | ||
| // LastName = "Doe", | ||
| // Age = 30, | ||
| // }; | ||
| // } | ||
| } | ||
|
|
||
| public record PersonRecord(string FirstName, string LastName, int Age); |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. β Why did you add this?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was needed to make MTP tests work when run through the CLI. I added this along with the agent commands so that coding agents could better run tests without burning tokens.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This how you made it work with dotnet test?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "sdk": { | ||
| "rollForward": "latestMinor", | ||
| "version": "10.0.101" | ||
j-d-ha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| "test": { | ||
| "runner": "Microsoft.Testing.Platform" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.