Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Updated version numbers to 9.0.0-pre02. + net 10 - #826

Closed
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02
Closed

Updated version numbers to 9.0.0-pre02. + net 10#826
DocSvartz wants to merge 2 commits into
MapsterMapper:developmentfrom
DocSvartz:Updated-version-numbers-to-9.0.0-pre02

Conversation

@DocSvartz

Copy link
Copy Markdown
Contributor

No description provided.

@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02.Updated version numbers to 9.0.0-pre02. + net 10.xNov 17, 2025
@DocSvartzDocSvartz changed the title Updated version numbers to 9.0.0-pre02. + net 10.xUpdated version numbers to 9.0.0-pre02. + net 10Nov 17, 2025
@DevTKSS

Copy link
Copy Markdown
Collaborator

@andrerav I can not use Mapster because its requiring net7:

Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)

would you maybe check if you are able to merge this (hopefully fixing) PR ?

@stagep

Copy link
Copy Markdown

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01.
Include Breaking changes after 9.0.0-pre01 to the Mapster library are not planned.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@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.
As there is no simple source generator package available as replacement alternative seems like I will have to search a different NuGet or dotnet tool for mapping or keep writing Dtos 🤷

@stagep

Copy link
Copy Markdown

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this?
Just in case you might want to improve the User Expirience, feel free to share this setup in your docs with your other users 👍

A part of the problem was also that, while you "just" used the &quote; for " I would have prefered a small Note box to not get an headache by not seeing this small difference 😅

I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄
dotnet-tools.json:

{
"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.Build.targets alongside with minimal csproj and Directory.Packages.props usage as my Solution uses CPM:

Directory.Packages.props

 <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>

Directory.Build.targets

<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.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="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). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a &quot;$(TargetPath)&quot; -o &quot;$(BaseIntermediateOutputPath)mapster&quot; -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>

the Project file .csproj:

<ProjectSdk="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>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

By the way, refering to your Mapster.Tool Wiki Page this -r should generate Record types but you are not mentioning that only the dotnet-mapster model command actually supports it reading the Options in the src! Maybe this should be told and not generalized listed for all of the commands.

image

The actual src/Mapster.Tool/MapperOptions.cs and ExtensionOptions.csdoesn't contain this Option either and resulting from that, its unknown to the compiled dotnet tool we are getting and produces this Error:

Mapster.Tool 9.0.0-pre01+998402908cdc59d2bbdbab5fbc1d5062153494e8
1> Copyright (c) 2025 Chaowlert Chaisrichalermpol, Eric Swann, Andreas Ravnestad
1>
1> ERROR(S):
1> Option 'r' is unknown.
1> USAGE:
1> Generate extensions:
1> dotnet mapster extension mapper --assembly /Path/To/YourAssembly.dll --output
1> Models
1>
1> -a, --assembly Required. Assembly to scan
1>
1> -o, --output (Default: Models) Output directory.
1>
1> -n, --namespace Namespace for extensions
1>
1> -p, --printFullTypeName Set true to print full type name
1>
1> -b, --baseNamespace Provide base namespace to generate nested output &
1> namespace
1>
1> -s, --skipExisting Set true to skip generating already existing files
1>
1> -N, --nullableDirective Set true to add "#nullable enable" to the top of
1> generated extension files
1>
1> --help Display this help screen.
1>
1> --version Display version information.

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:
image

are generating this:
image

while expected would be the summary to actually optional (missing = null or = "") and the TemperatureF ... not sure is this a case for your IgnoreAttribute? but then I would also not get this to be readable. I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷
This here would be a possible expectation:

/// <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>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}

Maybe you could check on this and add it to any kind of back log?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

I'm very glad that you managed to solve this 🤩
Don't be shy about opening an issue on topics that interest you.

If i understand correctly, it is Business logic:

public double TemperatureF => 32 + (TemperatureC * 9 / 5);

Dtos shouldn't contain Business logic, but simply serve to transfer data.

I dont see a way to exclude some from the ctor but still include them as { get; } while it should be keeping the code that is setting the property🤷

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.

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz 🤔😅 assumed they are the same!
Will look again into this.
Can you tell how someone could contribute to such wiki ? I always used to contribute to md files produced by docfx for example also set one up for my own samples repo🤔
I just seen your much issues load and thought you would just only want to stay where you are and keep it stable as possible but not proceeding, which would be quite sad because I would see your NuGet as great and most maintained alternative to AutoMapper which seems to require payment and I prefer staying on OSS or similar projects and if I see problems with something I tend to checkig if I can help with it and (if yes) contribute with a PR because I know that beyond every good Dev potentially is also 👀 (hope so at least 😜) a life or/and a family to care for beside creating great stuff 😁

@DevTKSS

Copy link
Copy Markdown
Collaborator

@DocSvartz and one question to the PR here:
What is the reason for your don't want to upgrade or add the new tfm's? Is it just for the review time you maybe not have, or what is blocking you from sending even the net9 into stable version release?
Reasons I could imagine...

  • specific issues
  • test coverage
  • ?

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

@DevTKSS
about Wiki - I haven't edited the wiki yet either, so I can't offer any advice. 😔

I and @stagep recently joined the Mapster.
I am adding new features from issue or fix bugs, but i am not by publishing new versions.

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 :).

@DocSvartz

Copy link
Copy Markdown
ContributorAuthor

update to #841

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@DocSvartz@DevTKSS@stagep