Skip to content

Commit 96b3a93

Browse files
committed
- Internal Improvement: Preparing for future support for result pattern in mapping system.
1 parent e47943c commit 96b3a93

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

Modules/Intent.Modules.Application.DomainInteractions/Intent.Application.DomainInteractions.imodspec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>Intent.Application.DomainInteractions</id>
4-
<version>1.1.7</version>
4+
<version>1.1.8-pre.0</version>
55
<supportedClientVersions>[4.5.15-a,5.0.0)</supportedClientVersions>
66
<summary>Provides interaction strategies to generate domain interaction implementations.</summary>
77
<description>Provides interaction strategies to generate domain interaction implementations.</description>
@@ -16,16 +16,16 @@
1616
<moduleSettings></moduleSettings>
1717
<dependencies>
1818
<dependency id="Intent.Common" version="3.7.2" />
19-
<dependency id="Intent.Common.CSharp" version="3.9.6" />
19+
<dependency id="Intent.Common.CSharp" version="3.9.10-pre.0" />
2020
<dependency id="Intent.Common.Types" version="4.0.0" />
21-
<dependency id="Intent.Modelers.Domain" version="3.9.0" />
21+
<dependency id="Intent.Modelers.Domain" version="3.12.10-pre.0" />
2222
<dependency id="Intent.Modelers.Services" version="4.0.3" />
23-
<dependency id="Intent.Modelers.Services.DomainInteractions" version="2.3.0" />
23+
<dependency id="Intent.Modelers.Services.DomainInteractions" version="2.3.9-pre.0" />
2424
</dependencies>
2525
<interoperability>
2626
<detect id="Intent.Modelers.Services.DomainInteractions">
2727
<install>
28-
<package id="Intent.Modelers.Services.DomainInteractions" version="2.2.0" />
28+
<package id="Intent.Modelers.Services.DomainInteractions" version="2.3.9-pre.0" />
2929
</install>
3030
</detect>
3131
<detect id="Intent.Modelers.Services.EventInteractions">

Modules/Intent.Modules.Application.DomainInteractions/Intent.Metadata/Module Builder/Intent.Application.DomainInteractions/Intent.Application.DomainInteractions.pkg.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<definitionPackageName>Intent.ModuleBuilder</definitionPackageName>
3434
<definitionPackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</definitionPackageId>
3535
<properties>
36-
<property name="4bb9695b-6004-46e1-acea-c48c60c5f8ce" display="Version" value="1.1.7" isActive="true" />
36+
<property name="4bb9695b-6004-46e1-acea-c48c60c5f8ce" display="Version" value="1.1.8-pre.0" isActive="true" />
3737
<property name="177a2415-e749-46e7-8257-440e19ecfb5e" display="API Namespace" value="Intent.Modules.Application.Contracts.Api" isActive="true" />
3838
<property name="0d2ae582-090e-42d6-a7d6-689144433254" display="NuGet Package Id" isActive="true" />
3939
<property name="27cf6544-a9a2-4992-9fef-51d0ed49e66e" display="NuGet Package Version" value="" isActive="true" />

Modules/Intent.Modules.Application.DomainInteractions/Intent.Modules.Application.DomainInteractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Version>1.1.7</Version>
5+
<Version>1.1.8-pre.0</Version>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>

Modules/Intent.Modules.Application.DomainInteractions/Mapping/Resolvers/EntityCreationMappingTypeResolver.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Intent.Metadata.Models;
1+
using System;
2+
using System.Linq;
3+
using Intent.Metadata.Models;
24
using Intent.Modelers.Domain.Api;
35
using Intent.Modules.Common.CSharp.Mapping;
46
using Intent.Modules.Common.CSharp.Templates;
@@ -39,7 +41,7 @@ public EntityCreationMappingTypeResolver(ICSharpFileBuilderTemplate sourceTempla
3941
return mapping;
4042
}
4143

42-
if (model.AsOperationModel()?.IsStatic == true && model.TypeReference.ElementId == ((IElement)model).ParentId)
44+
if (IsStaticConstructor(model))
4345
{
4446
return new StaticMethodInvocationMapping(mappingModel, _sourceTemplate);
4547
}
@@ -61,4 +63,25 @@ public EntityCreationMappingTypeResolver(ICSharpFileBuilderTemplate sourceTempla
6163

6264
return next?.Invoke(mappingModel);
6365
}
66+
67+
private static bool IsStaticConstructor(ICanBeReferencedType model)
68+
{
69+
if (model.AsOperationModel()?.IsStatic != true)
70+
{
71+
return false;
72+
}
73+
74+
var entityId = ((IElement)model).ParentId;
75+
var operationReturnTypeRef = model.TypeReference;
76+
77+
// Check for generics
78+
var genericParams = operationReturnTypeRef.GenericTypeParameters.ToList();
79+
if (genericParams.Count == 1 && genericParams[0].ElementId == entityId)
80+
{
81+
// return true if we want to support this result-pattern scenario in the future
82+
throw new NotSupportedException("Wrapping the entity in a generic type is not supported for static constructor creation mappings.");
83+
}
84+
85+
return operationReturnTypeRef?.ElementId == entityId;
86+
}
6487
}

Modules/Intent.Modules.Application.DomainInteractions/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Version 1.1.8
2+
3+
- Internal Improvement: Preparing for future support for result pattern in mapping system.
4+
15
### Version 1.1.7
26

37
- Improvement: Checking for installed mappers are more flexible.

0 commit comments

Comments
 (0)