-
Notifications
You must be signed in to change notification settings - Fork 384
Updated version numbers to 9.0.0-pre02. + net 10 #826
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
base: development
Are you sure you want to change the base?
Updated version numbers to 9.0.0-pre02. + net 10 #826
Conversation
|
@andrerav I can not use Mapster because its requiring net7: would you maybe check if you are able to merge this (hopefully fixing) PR ? |
|
@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01. |
|
@DocSvartz I am using the latest pre release that's available for all nugets and tool too, but the tool keeps failing with telling me I would need to install the net7 runtime workload which shouldn't be required. |
|
Are you using Mapster and/or Mapster.Tool? As @DocSvartz mentioned, older versions supported .Net 7. The worse case scenario is forking and adding back in .Net 7. We are here to help you find a solution / workaround. |
|
@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this? A part of the problem was also that, while you "just" used the I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄 {
"version": 1,
"isRoot": true,
"tools": {
"mapster.tool": {
"version": "9.0.0-pre01",
"commands": [
"dotnet-mapster"
],
"rollForward": true,
"allowPrerelease": true
}
}
}This is what I came up with using Directory.Packages.props <ItemGroup Label="Mapping">
<PackageVersion Include="Mapster" Version="9.0.0-pre01" />
<PackageVersion Include="Mapster.DependencyInjection" Version="9.0.0-pre01" />
<PackageVersion Include="Mapster.Async" Version="9.0.0-pre01" />
<PackageVersion Include="Mapster.Immutable" Version="9.0.0-pre01" />
<PackageVersion Include="Mapster.EFCore" Version="9.0.0-pre01" />
</ItemGroup>
<Project>
<!--
Mapster integration targets.
Mapster integration targets.
Usage:
1) Run one-time setup (executes dotnet tool restore in repo root):
msbuild -t:MapsterSetup
2) Enable per-project automatic Mapster generation by adding to the project's .csproj:
<PropertyGroup>
<MapsterEnabled>true</MapsterEnabled>
</PropertyGroup>
3) Optionally, specify the Mapster generated files path pattern e.g. if you want to see the files in the project directory:
<ProjectProperties>
<MapsterPath>$(ProjectDir)**\mapster\**\*.g.cs</MapsterPath>
</ProjectProperties>
And include the following ItemGroup to expose the generated files in the project:
<ItemGroup Label="Include Mapster Generated Files" Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<Compile Remove="$(MapsterPath)" />
<None Include="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
4) Build the project. If MapsterEnabled is true and the project includes a net9.0 target framework, Mapster code generation will run after build.
as the code generated is not runtime-specific, it will be generated once per project, not per TFM.
This way you can also use the generated files in multiple TFMs e.g. net10.0 while dotnet-mapster only supports up to net9.0 currently.
-->
<Target Name="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<Exec WorkingDirectory="$(MSBuildThisFileDirectory).." Command="dotnet tool restore" Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="MapsterSetupExitCode" />
</Exec>
<Error Text="MapsterSetup: dotnet tool restore failed (exit code $(MapsterSetupExitCode))."
Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json') and '$(MapsterSetupExitCode)' != '' and '$(MapsterSetupExitCode)' != '0'" />
</Target>
<!-- Run Mapster only when project targets net9.0 (either current TFM or TargetFrameworks contains net9.0). -->
<Target Name="Mapster" AfterTargets="AfterBuild"
Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<Message Importance="high" Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<Exec WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet mapster model -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -r -N"
ContinueOnError="false" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet mapster extension -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -N"
ContinueOnError="false" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet mapster mapper -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -N"
ContinueOnError="false" />
<Message Importance="high" Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappings Include="**\\mapster\\*.g.cs" />
</ItemGroup>
<Target Name="CleanGenerated" BeforeTargets="Clean">
<Message Importance="low" Text="CleanGenerated: removing mapster generated files..." Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<Delete Files="@(GeneratedMappings)" ContinueOnError="false" Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>the Project file .csproj: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>DevTKSS.MyProject.DataContracts</RootNamespace>
<AssemblyName>DevTKSS.MyProject.DataContracts</AssemblyName>
<!-- The Dependending Projects are already migrated to .net10.0 so the net9.0 is only to enable dotnet-mapster -->
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<MapsterEnabled>true</MapsterEnabled>
<MapsterPath>$(ProjectDir)**\mapster\**\*.g.cs</MapsterPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mapster" />
<PackageReference Include="Mapster.DependencyInjection" />
<PackageReference Include="Mapster.Async" />
<PackageReference Include="Mapster.Immutable" />
<PackageReference Include="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroup Label="Include Mapster Generated Files" Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<Compile Remove="$(MapsterPath)" />
<None Include="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>By the way, refering to your
The actual but I am not sure from the Attribute docs of mapster, if there might be one of the arguments that I am missing but cases like this: while expected would be the summary to actually optional (missing /// <summary>
/// A Weather Forecast for a specific date
/// </summary>
/// <param name="Date">Gets the Date of the Forecast.</param>
/// <param name="TemperatureC">Gets the Forecast Temperature in Celsius.</param>
/// <param name="Summary">Get a description of how the weather will feel.</param>
public record WeatherForecastQuery(DateOnly Date, double TemperatureC, string? Summary = null)
{
/// <summary>
/// Gets the Forecast Temperature in Fahrenheit
/// </summary>
public double TemperatureF => 32 + (TemperatureC * 9 / 5);
}Maybe you could check on this and add it to any kind of back log? |
|
I'm very glad that you managed to solve this 🤩 If i understand correctly, it is Business logic:
Dtos shouldn't contain Business logic, but simply serve to transfer data.
Yes, there is a problem with that. Also keep in mind that the record types in the Mapster Wiki are not actually equal Records in C# . Records mapping has already been added in Mapster, but there is no generation with MapsterTool yet. |
|
@DocSvartz 🤔😅 assumed they are the same! |
|
@DocSvartz and one question to the PR here:
|
|
@DevTKSS I and @stagep recently joined the Mapster. See this discussion and contact @andrerav if you want to become one of maintainers Mapster. In fact, quite a lot of changes have accumulated since version 7.4.0, There was one big problem and a lot of changes associated with it :). |



No description provided.