Skip to content

Fix #1501: Generate WhenStateIs/WillSetStateTo correctly in ToCSharpCode - #1502

Merged
StefH merged 4 commits into
wiremock:masterfrom
Bafyn:fix/mappings-code-scenario-state
Aug 19, 2026
Merged

StefH merged 4 commits into
wiremock:masterfrom
Bafyn:fix/mappings-code-scenario-state

Conversation

@Bafyn

@Bafyn Bafyn commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MappingConverter.ToCSharpCode generated broken code for stateful (Scenario) mappings: it emitted .WhenStateIs(NextState, TimesInSameState), which has no matching overload (does not compile), used NextState under WhenStateIs, and never emitted the actual ExecutionConditionState.

References

Fixes #1501

Submitter checklist

  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected

Tests

  • Added two MappingConverterTests.ToCSharpCode cases;
  • Corrected two MappingBuilderTests.ToCSharpCode verified snapshots.

@StefH

StefH commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

I just started also on this....

@StefH

StefH commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

@Bafyn
Can you also update the Wildcardmatcher code to:

public override string GetCSharpCodeArguments()
{
    return
        $"new {Name}" +
        $"(" +
        $"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
        $"new AnyOf<string, StringPattern>[] {{ {MappingConverterUtils.ToCSharpCodeArguments(_patterns)} }}, " +
        $"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}, " +
        $"{MatchOperator.GetFullyQualifiedEnumValue()}" +
        $")";
}

@Bafyn

Bafyn commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@StefH I realized you did when I noticed you assigned the issue to yourself 🙃
I can also look into this thing you mentioned #1501 (comment)

UPD: yes, checking

Comment thread src/WireMock.Net.Minimal/Serialization/MappingConverter.cs
Comment thread src/WireMock.Net.Minimal/Serialization/MappingConverter.cs Outdated
@Bafyn

Bafyn commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

FYI @StefH the other matchers had the same issues. Fixed them in scope of the latest update

@Bafyn
Bafyn force-pushed the fix/mappings-code-scenario-state branch from c804ec4 to 5cc3d42 Compare August 18, 2026 14:53
@Bafyn
Bafyn force-pushed the fix/mappings-code-scenario-state branch from 5cc3d42 to e9deb0b Compare August 18, 2026 15:16
Comment thread src/WireMock.Net.Minimal/Matchers/ContentTypeMatcher.cs Outdated
@StefH

StefH commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Added comment.

And if you have fixed an issue, you can "resolve conversation" here in the github.

@Bafyn
Bafyn marked this pull request as draft August 18, 2026 20:28
@Bafyn
Bafyn marked this pull request as ready for review August 18, 2026 20:28
This was referenced Sep 21, 2026
alexeyzimarev pushed a commit to kurrent-io/kcap-cli that referenced this pull request Sep 30, 2026
Updated [DotNext](https://github.com/dotnet/dotNext) from 6.7.1 to
6.8.0.

<details>
<summary>Release notes</summary>

_Sourced from [DotNext's
releases](https://github.com/dotnet/dotNext/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotNext/commits).
</details>

Updated
[Eventuous.SignalR.Client](https://github.com/eventuous/Eventuous) from
0.16.5-alpha.0.22 to 0.16.5-alpha.0.33.

<details>
<summary>Release notes</summary>

_Sourced from [Eventuous.SignalR.Client's
releases](https://github.com/eventuous/Eventuous/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/eventuous/Eventuous/commits).
</details>

Updated [Markdig](https://github.com/xoofx/markdig) from 1.3.2 to 1.4.0.

<details>
<summary>Release notes</summary>

_Sourced from [Markdig's
releases](https://github.com/xoofx/markdig/releases)._

## 1.4.0

# Changes

## ✨ New Features

- Add strict GFM pipe table parsing mode (14cd25c7)

## 🐛 Bug Fixes

- Fix heading auto-link hijacking nested link labels (#​668) (PR #​949)
by @​dualfroz
- Fix: keep trailing content out of an unmatched emphasis closer (#​743)
(PR #​950) by @​dualfroz
- Fix indent on first list item (#​482) (PR #​953) by @​boxofyellow
- Add Normalization Support for PipeTables (GFM) (PR #​954) by
@​boxofyellow
- Fix partially empty pipe table separator regression (PR #​955) by
@​vicancy
- Reject emoji-parsing if the slice ends with `**` (PR #​947) by
@​bstordrup
- Fix strict GFM tables against native cmark-gfm (86866b91)

## 🚀 Enhancements

- Update 3rd party extensions (PR #​945) by @​Kryptos-FR

## 🏭 Tests

- Fix tests warnings (96b024c2)

## 📦 Dependencies

- Bump deps (c6b186b4)

## 🧰 Misc

- Use NuGet Trusted Publishing via dotnet-releaser (56e9c238)

**Full Changelog**:
[1.3.2...1.4.0](xoofx/markdig@1.3.2...1.4.0)

<sub>Published with
[dotnet-releaser](https://github.com/xoofx/dotnet-releaser/)</sub>


Commits viewable in [compare
view](xoofx/markdig@1.3.2...1.4.0).
</details>

Updated
[Microsoft.Testing.Extensions.GitHubActionsReport](https://github.com/microsoft/testfx)
from 2.4.0 to 2.4.1.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Testing.Extensions.GitHubActionsReport's
releases](https://github.com/microsoft/testfx/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/microsoft/testfx/commits).
</details>

Updated
[Svg.Controls.Skia.Avalonia](https://github.com/wieslawsoltes/Svg.Skia)
from 12.0.0.15 to 12.0.0.17.

<details>
<summary>Release notes</summary>

_Sourced from [Svg.Controls.Skia.Avalonia's
releases](https://github.com/wieslawsoltes/Svg.Skia/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/wieslawsoltes/Svg.Skia/commits).
</details>

Updated [Velopack](https://github.com/velopack/velopack) from 1.2.0 to
1.2.158.

<details>
<summary>Release notes</summary>

_Sourced from [Velopack's
releases](https://github.com/velopack/velopack/releases)._

## 1.2.158

## What's Changed
* Fix NodeJSElectron sample for TypeScript 6.0 compatibility by @​caesay
in velopack/velopack#931
* Localize setup disk-space error and use byte units by @​chinaszzt-erio
in velopack/velopack#932
* Ignore pyo3 RUSTSEC-2026-0176/0177 advisories in cargo deny by
@​caesay in velopack/velopack#942
* Move argument validation to command layer, add JSON support, refactor
deployment commands by @​caesay in
velopack/velopack#934
* Fix supply-chain CI: bump vite to 8.0.16 to resolve npm audit failure
by @​caesay in velopack/velopack#952
* Allow S3 region to be specified at the same time as endpoint by
@​caesay in velopack/velopack#957
* Ship 64-bit Windows bootstrapper binaries from vpk pack by
@​roysyahputra in velopack/velopack#944
* Renovate/dotnet packages deny cleanup by @​caesay in
velopack/velopack#968
* Add NodeJS pre-built sources & add HttpOptions class by @​caesay in
velopack/velopack#969
* Fix MSI quiet-install default location and bracket escaping in
packTitle by @​caesay in velopack/velopack#970
* Use atomic rename on macos by @​caesay in
velopack/velopack#972
* Add timing logs to diagnose slow update apply on EDR machines (#​947)
by @​caesay in velopack/velopack#974
* Fix supply-chain CI: address new RUSTSEC advisories by @​caesay in
velopack/velopack#984
* Add new deployment and sources tests by @​caesay in
velopack/velopack#973
* Fix portable/MSI launcher renamed after update (packTitle vs mainExe)
by @​caesay in velopack/velopack#985
* Windows installer channel-override tag readers (Setup.exe + MSI) by
@​caesay in velopack/velopack#987
* Make Velopack Flow a first-class update source across all client
libraries by @​caesay in velopack/velopack#999
* Fix swapped MSI banner/dialog images, rename to --msiTopBanner and
--msiDialogBackground by @​caesay in
velopack/velopack#1009
* Remove bsdiff fallback; zstd is the only delta patch format by
@​caesay in velopack/velopack#1010
* Show progress dialog during Windows uninstall by @​caesay in
velopack/velopack#1011
* Windows signing: pass /d (content description) for Azure Trusted
Signing by @​SamHartleyFixes in
velopack/velopack#1047
* Write EstimatedSize as a REG_DWORD so Windows shows the app size by
@​timkonieczny in velopack/velopack#1051
* fix(vpk): safely handle non-JSON error responses in FlowApiExtensions
by @​Keboo in velopack/velopack#1055
* Lock file maintenance by @​caesay in
velopack/velopack#1063
* Update all dependencies to latest by @​caesay in
velopack/velopack#1064

## New Contributors
* @​chinaszzt-erio made their first contribution in
velopack/velopack#932
* @​roysyahputra made their first contribution in
velopack/velopack#944
* @​SamHartleyFixes made their first contribution in
velopack/velopack#1047
* @​timkonieczny made their first contribution in
velopack/velopack#1051
## Dependency Updates

<details>

<summary>Expand to see all changed dependencies</summary>

* Pin dependencies by @​renovate[bot] in
velopack/velopack#925
* Pin dependencies by @​renovate[bot] in
velopack/velopack#926
* Lock file maintenance by @​renovate[bot] in
velopack/velopack#930
* Update npm packages by @​renovate[bot] in
velopack/velopack#927
* Update sample dotnet packages by @​renovate[bot] in
velopack/velopack#940
* Update npm packages by @​renovate[bot] in
velopack/velopack#937
* Update sample js packages by @​renovate[bot] in
velopack/velopack#951
* Update dotnet test packages to 18.6.0 by @​renovate[bot] in
velopack/velopack#938
* Update dotnet packages by @​renovate[bot] in
velopack/velopack#949
* Update sample dotnet packages to 1.2.0 by @​renovate[bot] in
velopack/velopack#950
* Lock file maintenance by @​renovate[bot] in
velopack/velopack#943
* Update dependency WixToolset.Dtf.WindowsInstaller to v7 by
@​renovate[bot] in velopack/velopack#939
 ... (truncated)

## 1.2.110-ge826545

## What's Changed
* Fix NodeJSElectron sample for TypeScript 6.0 compatibility by @​caesay
in velopack/velopack#931
* Localize setup disk-space error and use byte units by @​chinaszzt-erio
in velopack/velopack#932
* Ignore pyo3 RUSTSEC-2026-0176/0177 advisories in cargo deny by
@​caesay in velopack/velopack#942
* Move argument validation to command layer, add JSON support, refactor
deployment commands by @​caesay in
velopack/velopack#934
* Fix supply-chain CI: bump vite to 8.0.16 to resolve npm audit failure
by @​caesay in velopack/velopack#952
* Allow S3 region to be specified at the same time as endpoint by
@​caesay in velopack/velopack#957
* Ship 64-bit Windows bootstrapper binaries from vpk pack by
@​roysyahputra in velopack/velopack#944
* Renovate/dotnet packages deny cleanup by @​caesay in
velopack/velopack#968
* Add NodeJS pre-built sources & add HttpOptions class by @​caesay in
velopack/velopack#969
* Fix MSI quiet-install default location and bracket escaping in
packTitle by @​caesay in velopack/velopack#970
* Use atomic rename on macos by @​caesay in
velopack/velopack#972
* Add timing logs to diagnose slow update apply on EDR machines (#​947)
by @​caesay in velopack/velopack#974
* Fix supply-chain CI: address new RUSTSEC advisories by @​caesay in
velopack/velopack#984
* Add new deployment and sources tests by @​caesay in
velopack/velopack#973
* Fix portable/MSI launcher renamed after update (packTitle vs mainExe)
by @​caesay in velopack/velopack#985
* Windows installer channel-override tag readers (Setup.exe + MSI) by
@​caesay in velopack/velopack#987
* Make Velopack Flow a first-class update source across all client
libraries by @​caesay in velopack/velopack#999

## New Contributors
* @​chinaszzt-erio made their first contribution in
velopack/velopack#932
* @​roysyahputra made their first contribution in
velopack/velopack#944
## Dependency Updates

<details>

<summary>Expand to see all changed dependencies</summary>

* Pin dependencies by @​renovate[bot] in
velopack/velopack#925
* Pin dependencies by @​renovate[bot] in
velopack/velopack#926
* Lock file maintenance by @​renovate[bot] in
velopack/velopack#930
* Update npm packages by @​renovate[bot] in
velopack/velopack#927
* Update sample dotnet packages by @​renovate[bot] in
velopack/velopack#940
* Update npm packages by @​renovate[bot] in
velopack/velopack#937
* Update sample js packages by @​renovate[bot] in
velopack/velopack#951
* Update dotnet test packages to 18.6.0 by @​renovate[bot] in
velopack/velopack#938
* Update dotnet packages by @​renovate[bot] in
velopack/velopack#949
* Update sample dotnet packages to 1.2.0 by @​renovate[bot] in
velopack/velopack#950
* Lock file maintenance by @​renovate[bot] in
velopack/velopack#943
* Update dependency WixToolset.Dtf.WindowsInstaller to v7 by
@​renovate[bot] in velopack/velopack#939
* Update sample js packages by @​renovate[bot] in
velopack/velopack#961
* Update dependency System.IO.Packaging to 10.0.9 by @​renovate[bot] in
velopack/velopack#959
* Update dependency @​types/node to v25.9.4 - autoclosed by
@​renovate[bot] in velopack/velopack#958
* Update codecov/codecov-action action to v7 by @​renovate[bot] in
velopack/velopack#963
* Lock file maintenance by @​renovate[bot] in
velopack/velopack#965
* Update rust crates to 0.29 by @​renovate[bot] in
velopack/velopack#962
* Update dotnet packages by @​renovate[bot] in
velopack/velopack#960
* Update actions/checkout action to v7 by @​renovate[bot] in
velopack/velopack#980
* Update dotnet packages by @​renovate[bot] in
velopack/velopack#976
* Update dependency electron to v43 by @​renovate[bot] in
velopack/velopack#977
 ... (truncated)

Commits viewable in [compare
view](velopack/velopack@1.2.0...1.2.158).
</details>

Updated [WireMock.Net](https://github.com/wiremock/WireMock.Net) from
2.15.0 to 2.18.0.

<details>
<summary>Release notes</summary>

_Sourced from [WireMock.Net's
releases](https://github.com/wiremock/WireMock.Net/releases)._

## 2.18.0

## What's Changed
* WireMock.Net.OpenApiParser: fix depencency on
RamlToOpenApiConverter.SourceOnly by @​StefH in
wiremock/WireMock.Net#1510


**Full Changelog**:
wiremock/WireMock.Net@2.17.0...2.18.0

## 2.17.0

## What's Changed
* Revert to RamlToOpenApiConverter.SourceOnly by @​StefH in
wiremock/WireMock.Net#1509


**Full Changelog**:
wiremock/WireMock.Net@2.16.0...2.17.0

## 2.16.0

## What's Changed
* Fix #​1501: Generate WhenStateIs/WillSetStateTo correctly in
ToCSharpCode by @​Bafyn in
wiremock/WireMock.Net#1502
* Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) by
@​StefH in wiremock/WireMock.Net#1503
* Update SharpYaml package to version 2.5.1 by @​johnthcall in
wiremock/WireMock.Net#1504
* Upgrade dependency RamlToOpenApiConverter to version 0.40.0 by @​StefH
in wiremock/WireMock.Net#1505


**Full Changelog**:
wiremock/WireMock.Net@2.15.0...2.16.0

Commits viewable in [compare
view](wiremock/WireMock.Net@2.15.0...2.18.0).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to 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.

Generated C# code for stateful (Scenario) mappings does not compile and drops the WhenStateIs condition

2 participants