From 2479d6b3fc141c627a3a0a400eaf952ce0703383 Mon Sep 17 00:00:00 2001 From: Cristian Pogacean Date: Mon, 18 Oct 2021 11:32:20 +0200 Subject: [PATCH] Fix issue with long name issue for publisher (#1385) (#1430) * When publisher CLI arguments are provided as long names, they with config settings ending up being ignored. The issue is fixed now by changing the order of processing the arguments. * Correction of the default value of `fullfeaturedmessage` argument --- .../src/Program.cs | 2 +- .../src/Runtime/LegacyCliOptions.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Program.cs b/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Program.cs index 8d33adc35b..ba359073d1 100644 --- a/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Program.cs +++ b/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Program.cs @@ -28,8 +28,8 @@ public static void Main(string[] args) { .AddJsonFile("appsettings.json", true) .AddEnvironmentVariables() .AddEnvironmentVariables(EnvironmentVariableTarget.User) - .AddLegacyPublisherCommandLine(args) .AddCommandLine(args) + .AddLegacyPublisherCommandLine(args) // making sure the Legacy arguments are processed at last so they are not overriden .Build(); #if DEBUG diff --git a/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Runtime/LegacyCliOptions.cs b/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Runtime/LegacyCliOptions.cs index 29d332ea32..e6a79fb4b0 100644 --- a/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Runtime/LegacyCliOptions.cs +++ b/modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/Runtime/LegacyCliOptions.cs @@ -81,7 +81,7 @@ public LegacyCliOptions(string[] args) { (bool b) => this[LegacyCliConfigKeys.SkipFirstDefault] = b.ToString() }, { "fm|fullfeaturedmessage=", "The full featured mode for messages (all fields filled in)." + - "Default is 'true', for legacy compatibility use 'false'", + "Default is 'false' for legacy compatibility.", (bool b) => this[LegacyCliConfigKeys.FullFeaturedMessage] = b.ToString() }, // Client settings @@ -190,6 +190,7 @@ public LegacyCliOptions(string[] args) { { "vc|verboseconsole=", "Legacy - do not use.", _ => {} }, { "as|autotrustservercerts=", "Legacy - do not use.", _ => {} } }; + options.Parse(args); Config = ToAgentConfigModel(); @@ -309,7 +310,7 @@ private LegacyCliModel ToLegacyCliModel() { }; } - private AgentConfigModel ToAgentConfigModel() { + private static AgentConfigModel ToAgentConfigModel() { return new AgentConfigModel { AgentId = "StandalonePublisher", Capabilities = new Dictionary(), @@ -328,6 +329,6 @@ private T GetValueOrDefault(string key, T defaultValue) { return (T)converter.ConvertFrom(this[key]); } - private LegacyCliModel _legacyCliModel = null; + private LegacyCliModel _legacyCliModel; } }