Skip to content

Commit 9f4a179

Browse files
committed
Merge PR TrakHound#233 feat/dry-generator-phase1-consolidation into integration/up-to-pr-233
# Conflicts: # tests/MTConnect.NET-Common-Tests/V2_6_V2_7/V2_7DataItemTypeTests.cs
2 parents 582bdd6 + 7008734 commit 9f4a179

127 files changed

Lines changed: 5372 additions & 891 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/dotnet-tools.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"commands": [
88
"reportgenerator"
99
]
10+
},
11+
"dotnet-stryker": {
12+
"version": "4.16.0",
13+
"commands": [
14+
"stryker"
15+
]
1016
}
1117
}
1218
}

MTConnect.NET.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-Tests-Agents"
141141
EndProject
142142
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-HTTP-Tests", "tests\MTConnect.NET-HTTP-Tests\MTConnect.NET-HTTP-Tests.csproj", "{3E89B860-A428-470C-8E48-0DDABC4027F0}"
143143
EndProject
144+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-Generator-Tests", "tests\MTConnect.NET-Generator-Tests\MTConnect.NET-Generator-Tests.csproj", "{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}"
145+
EndProject
144146
Global
145147
GlobalSection(SolutionConfigurationPlatforms) = preSolution
146148
Debug|Any CPU = Debug|Any CPU
@@ -509,6 +511,14 @@ Global
509511
{3E89B860-A428-470C-8E48-0DDABC4027F0}.Package|Any CPU.Build.0 = Debug|Any CPU
510512
{3E89B860-A428-470C-8E48-0DDABC4027F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
511513
{3E89B860-A428-470C-8E48-0DDABC4027F0}.Release|Any CPU.Build.0 = Release|Any CPU
514+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
515+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
516+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
517+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Docker|Any CPU.Build.0 = Debug|Any CPU
518+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Package|Any CPU.ActiveCfg = Debug|Any CPU
519+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Package|Any CPU.Build.0 = Debug|Any CPU
520+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
521+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57}.Release|Any CPU.Build.0 = Release|Any CPU
512522
EndGlobalSection
513523
GlobalSection(SolutionProperties) = preSolution
514524
HideSolutionNode = FALSE
@@ -565,6 +575,7 @@ Global
565575
{17E64F59-0E62-4FCE-BEC4-EABBCF95B9A2} = {BBF53739-168D-4635-8595-083AC0C65E4C}
566576
{AE09D1CA-5572-40BF-B984-74230E8634E1} = {14375E03-6BF8-45E6-B868-D2399368992B}
567577
{3E89B860-A428-470C-8E48-0DDABC4027F0} = {14375E03-6BF8-45E6-B868-D2399368992B}
578+
{8B61CE3B-DC8A-47CE-A34B-38BC57DFFD57} = {14375E03-6BF8-45E6-B868-D2399368992B}
568579
EndGlobalSection
569580
GlobalSection(ExtensibilityGlobals) = postSolution
570581
SolutionGuid = {CC13D3AD-18BF-4695-AB2A-087EF0885B20}

build/MTConnect.NET-DocsGen/CliInventory.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,15 @@ private static CliInfo CollectDotNetTool(string name, string file, string repoRo
342342
if (headerDescs.TryGetValue(flagName, out var headerDesc)) desc = headerDesc;
343343
desc ??= ExtractDotnetFlagDescription(text, flagName);
344344

345-
// Detect whether the case body calls `RequireValue` — if it
346-
// does, the flag takes a value.
345+
// Detect whether the case body calls `RequireValue` — if it does,
346+
// the flag takes a value. The scan is bounded to the CURRENT case
347+
// block only: it stops at the next `case "…":` label, a `default:`
348+
// label, or a `break;` terminator, so a boolean flag whose case
349+
// body sits above a value-taking case (like `--full-tree` above
350+
// `case "--output": … RequireValue(…)`) does not falsely inherit
351+
// the neighbour's value shape.
347352
bool takesValue = Regex.IsMatch(text,
348-
$@"case\s+""{Regex.Escape(flagName)}""\s*:[\s\S]{{0,200}}?RequireValue");
353+
$@"case\s+""{Regex.Escape(flagName)}""\s*:(?:(?!\s*case\s+""|\s*default\s*:|\bbreak\s*;)[\s\S])*?RequireValue");
349354
flags.Add(new CliFlag(
350355
Name: flagName,
351356
Short: null,

build/MTConnect.NET-SysML-Import/CSharp/EnumModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public string RenderModel()
9393
public string RenderDescriptions()
9494
{
9595
if (Values == null || Values.Count == 0) return null;
96-
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumDescriptions.scriban");
96+
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumOrStringDescriptions.scriban");
9797
return template.Render(this);
9898
}
9999
}

build/MTConnect.NET-SysML-Import/CSharp/EnumStringModel.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ internal class EnumStringModel : MTConnectEnumModel, ITemplateModel
1414

1515
public bool IsPartial { get; set; }
1616

17+
// Consumed by the Shape-B consolidated EnumOrStringDescriptions.scriban
18+
// template: gates the class-doc wording, the Get(...) overload's
19+
// parameter type (string vs. enum-typed), and the Get(...) doc summary.
20+
// EnumModel and ObservationModel do NOT expose this — Scriban resolves
21+
// a missing member as null (falsy), producing the enum-shape emission
22+
// for those two callers.
23+
public bool IsString => true;
24+
1725

1826
public EnumStringModel() { }
1927

@@ -88,7 +96,7 @@ public string RenderModel()
8896

8997
public string RenderDescriptions()
9098
{
91-
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumStringDescriptions.scriban");
99+
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumOrStringDescriptions.scriban");
92100
return template.Render(this);
93101
}
94102
}

build/MTConnect.NET-SysML-Import/CSharp/MeasurementModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public string RenderModel()
6666
}
6767

6868
/// <inheritdoc />
69-
public string RenderInterface() => null;
69+
public string RenderInterface()
70+
{
71+
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "Pallets.MeasurementInterface.scriban");
72+
return template.Render(this);
73+
}
7074

7175
/// <inheritdoc />
7276
public string RenderDescriptions() => null;

build/MTConnect.NET-SysML-Import/CSharp/ObservationModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public string RenderModel()
7272
/// <inheritdoc />
7373
public string RenderDescriptions()
7474
{
75-
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumDescriptions.scriban");
75+
var template = TemplateLoader.LoadOrThrow("CSharp", "Templates", "EnumOrStringDescriptions.scriban");
7676
return template.Render(this);
7777
}
7878
}

build/MTConnect.NET-SysML-Import/CSharp/TemplateRenderer.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -643,20 +643,19 @@ private static void MarkInheritedProperties(
643643
break;
644644

645645
case "Assets.CuttingTools.ToolingMeasurement":
646-
// ToolingMeasurement extends `Measurement` (the
647-
// CuttingTools abstract Measurement base, NOT
648-
// Assets.Pallet.Measurement). The CuttingTools
649-
// Measurement.g.cs is hand-maintained / frozen —
650-
// not produced by any current renderer flow — so
651-
// it never enters the export-side ClassModel
652-
// graph the inheritance walk traverses, and a
653-
// Name-only lookup of "Measurement" resolves to
654-
// Pallet.Measurement (which lacks Code). Class
655-
// side only — IMeasurement.g.cs has `Code`
656-
// commented out, so the interface child does NOT
657-
// hide anything and emitting `new` there would
658-
// produce CS0109 instead.
659-
classOnlyNames.Add("Code");
646+
// No hand-stitched inheritance seed needed. The
647+
// Assets.CuttingTools.Measurement base IS produced
648+
// by the current renderer flow (via
649+
// MTConnectAssetInformationModel.ParseAssetInformationModel's
650+
// sharedMeasurement injection which imports the
651+
// Pallet Measurement class under Assets.CuttingTools),
652+
// so the export-side ClassModel graph already carries
653+
// its property list. The Pallet Measurement lacks
654+
// Code, and the interface IMeasurement.g.cs likewise
655+
// has Code commented out — hence emitting `new` on
656+
// ToolingMeasurement.Code would raise CS0109 on both
657+
// the class and interface sides. Fall through to the
658+
// default inheritance walk with no override.
660659
break;
661660
}
662661

build/MTConnect.NET-SysML-Import/CSharp/Templates/EnumDescriptions.scriban renamed to build/MTConnect.NET-SysML-Import/CSharp/Templates/EnumOrStringDescriptions.scriban

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
3+
{{-# Shape-B consolidated Descriptions template. Valid for every MTConnect version. #}}
4+
{{-# Covers both the enum-descriptions and the string-constant-descriptions callers. #}}
5+
{{-# When is_string is truthy, the Get(...) overload takes a `string value` and the #}}
6+
{{-# class doc reads "string constant" instead of "value"; when falsy, the Get(...) #}}
7+
{{-# overload takes an enum-typed value and the class doc reads "value". #}}
38

49
namespace {{namespace}}
510
{
611
/// <summary>
7-
/// Description text for each <see cref="{{name}}"/> value as defined by the MTConnect Standard.
12+
/// Description text for each <see cref="{{name}}"/> {{ if is_string }}string constant{{ else }}value{{ end }} as defined by the MTConnect Standard.
813
/// </summary>
914
public static class {{name}}Descriptions
1015
{
@@ -21,9 +26,9 @@ namespace {{namespace}}
2126

2227

2328
/// <summary>
24-
/// Returns the MTConnect Standard description text for the specified <see cref="{{name}}"/> value, or <c>null</c> when none is defined.
29+
/// Returns the MTConnect Standard description text for the specified{{ if is_string }}{{ else }} <see cref="{{name}}"/>{{ end }} value, or <c>null</c> when none is defined.
2530
/// </summary>
26-
public static string Get({{name}} value)
31+
public static string Get({{ if is_string }}string{{ else }}{{name}}{{ end }} value)
2732
{
2833
switch (value)
2934
{

build/MTConnect.NET-SysML-Import/CSharp/Templates/EnumStringDescriptions.scriban

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)