-
Notifications
You must be signed in to change notification settings - Fork 341
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
Why not .net build-in code generator? #451
Comments
I think in the case of the mapper, the user should be able to save the generated models in source control. And dotnet generator has a problem with that. You can specify |
@devbased not actually. Auto-gen files are step-able and visible. The only reason can be customizing Auto-gen code and I thing it's not good thing to do. |
@devbased , the rule of thumb is to NOT commit generated files to SCM. <Target Name="Mapster" BeforeTargets="BeforeBuild;BeforeRebuild" Condition="'$(EnableMapsterCodeGen)' == 'true' And '$(ONCE)' != 'TRUE'">
<PropertyGroup>
<MapsterGeneratedFiles>$(MapsterCodeGenDirectory)\*.g.cs</MapsterGeneratedFiles>
</PropertyGroup>
<ItemGroup>
<Compile Remove="$(MapsterGeneratedFiles)" />
</ItemGroup>
<RemoveDir Directories="$(MapsterCodeGenDirectory)"/>
<Exec Command="dotnet msbuild $(ProjectPath) -p:Configuration=$(Configuration)"
EnvironmentVariables="ONCE=TRUE" />
<Exec Command="dotnet tool update Mapster.Tool --global --version=8.3.0" />
<Exec WorkingDirectory="$(ProjectDir)"
Command="dotnet mapster mapper -o $(MapsterCodeGenDirectory) -a $(TargetDir)$(ProjectName).dll " />
<ItemGroup>
<Compile Include="$(MapsterGeneratedFiles)" />
</ItemGroup>
</Target> This target removes the generated files and spawns another Pseudo-Code: allAsseblies.AllTypes.Select(type =>{
var i = type.Interfaces.FirstOrDefault(i->i.HasAttribute<MapperAttribute>());
return null==i ? null : new (i,type)
})
.WhereNotNull()
.ForEach(pair=>container.Register(pair.type).As(pair.i) Usage : <PropertyGroup>
<EnableMapsterCodeGen>true</EnableMapsterCodeGen>
<MapsterCodeGenDirectory>GeneratedMappings</MapsterCodeGenDirectory>
</PropertyGroup> |
In order to identify issues that are still active, we are closing issues that we believe are either resolved or are dormant. If your issue is still active then please reopen. Thanks. |
This wonderful package use a cli tool for code generation. but why not using build-in .net code gen?
It won't add files in project and doing it auto in build process.
The text was updated successfully, but these errors were encountered: