Skip to content

Commit e40d66d

Browse files
committed
Merge remote-tracking branch 'origin/master' into copilot/publisher3-upstream-parity-session-cleanup
# Conflicts: # Libraries/Opc.Ua.Client/Session/ManagedSession.cs # Tests/Opc.Ua.Server.Tests/QuickstartsServerUtilitiesTests.cs
2 parents 066260a + 7d0e587 commit e40d66d

498 files changed

Lines changed: 51624 additions & 6129 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.

.editorconfig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,11 @@ dotnet_diagnostic.CA1724.severity =
481481

482482
# CA1848: Use the LoggerMessage delegates
483483
dotnet_diagnostic.CA1848.severity = none
484-
# CA1873: Avoid potentially expensive logging
485-
dotnet_diagnostic.CA1873.severity = none
484+
# CA1873: Avoid potentially expensive logging. Enabled solution-wide (issue
485+
# #3908) now that the entire code base uses source-generated [LoggerMessage]
486+
# logging; any regression back to direct ILogger.Log* calls with expensive
487+
# arguments is flagged.
488+
dotnet_diagnostic.CA1873.severity = warning
486489
# CA1000: Do not declare static members on generic types
487490
dotnet_diagnostic.CA1000.severity = none
488491
# CA1031: Do not catch general exception types

.github/copilot-instructions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This is the official OPC UA .NET Standard Stack from the OPC Foundation. It prov
2020
- **Build**: Use Visual Studio 2026 or `dotnet build`
2121
- **Key solutions**:
2222
- `UA.slnx` - Contains all projects
23+
- **Contributor guide**: see [`Docs/DeveloperGuide.md`](../Docs/DeveloperGuide.md) for prerequisites, building (including per-TFM), testing, coding standards, and how-to recipes.
2324

2425
### Project Structure
2526
- `Libraries/` - Core OPC UA libraries (Client, Server, Configuration, etc.)
@@ -76,7 +77,7 @@ This is the official OPC UA .NET Standard Stack from the OPC Foundation. It prov
7677
- All source generated code, in particular ObjectType proxies should be used over manually calling service calls inside new clients.
7778
- Consider using the source generators to implement emitting "boilerplate", especially if it is related to the OPC UA standard (e.g. information model).
7879
- Base services: File System, Certificate manager, Secret store, State machine, Alarms and conditions Streaming subscription, Sessions, etc. in new code. (Documented in docs/*).
79-
- Observability is plumbed through via `ITelemetryContext`. Use it to create a `ILogger` for logging.
80+
- Observability is plumbed through via `ITelemetryContext`. Use it to create an `ILogger` for logging; follow the source-generated logging conventions in [`Docs/DeveloperGuide.md`](../Docs/DeveloperGuide.md#add-a-log-message-source-generated).
8081
- If reuse is not possible, ASK whether to extend an existing feature so it becomes reuseable.
8182

8283
### Code Style
@@ -102,6 +103,7 @@ This is the official OPC UA .NET Standard Stack from the OPC Foundation. It prov
102103
- Assembly prefix: `Opc.Ua` (Except applications, or if otherwise requested)
103104
- Package prefix: `OPCFoundation.NetStandard`
104105
- Always use a line break after `<summary>` and before `</summary>` for all members (except for documentation of fields). This applies to **every** XML-doc summary, including in sample/application code — never write a single-line `/// <summary> ... </summary>`; always put the text on its own line between the opening and closing tags.
106+
- Use source-generated `[LoggerMessage]` logging; never call `ILogger.LogInformation/LogError/...` directly. Follow the per-file `<Class>Log` and per-assembly `<AssemblyToken>EventIds` conventions in [`Docs/DeveloperGuide.md`](../Docs/DeveloperGuide.md#add-a-log-message-source-generated).
105107

106108
### Security Requirements
107109
- **Never hardcode credentials, certificates, or secrets** in source code
@@ -139,6 +141,7 @@ This is the official OPC UA .NET Standard Stack from the OPC Foundation. It prov
139141
- Update `/README.md` for significant changes
140142
- Keep `NugetREADME.md` updated for package-related changes
141143
- Document breaking changes prominently
144+
- Keep [`Docs/DeveloperGuide.md`](../Docs/DeveloperGuide.md) (the contributor onboarding guide) current when build, test, or coding-convention changes affect contributors.
142145

143146
#### Documentation Style
144147
- Use clear, technical language

.github/workflows/preview-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
dotnet tool install --version 3.0.45 --tool-path "$env:TOOLS_DIR" NuGetKeyVaultSignTool
9090
9191
- name: Setup NuGet
92-
uses: NuGet/setup-nuget@v2
92+
uses: NuGet/setup-nuget@v4
9393
with:
9494
nuget-version: '>=7.0.0'
9595

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* ========================================================================
2+
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
3+
*
4+
* OPC Foundation MIT License 1.00
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without
9+
* restriction, including without limitation the rights to use,
10+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the
12+
* Software is furnished to do so, subject to the following
13+
* conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be
16+
* included in all copies or substantial portions of the Software.
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
* OTHER DEALINGS IN THE SOFTWARE.
25+
*
26+
* The complete license agreement can be found here:
27+
* http://opcfoundation.org/License/MIT/1.00/
28+
* ======================================================================*/
29+
30+
namespace Opc.Ua.Lds.Server.Console
31+
{
32+
/// <summary>
33+
/// Centrally managed event id offsets for source-generated log messages in this assembly.
34+
/// </summary>
35+
/// <remarks>
36+
/// Each per-file <c>&lt;ClassName&gt;Log</c> class allocates its event ids relative to the
37+
/// offset constant below, using <c>offset + &lt;zero-based message index&gt;</c>. Every block
38+
/// reserves at least five spare slots for future messages and is rounded up to the next
39+
/// multiple of ten so that ids can be documented and managed from this single location.
40+
/// </remarks>
41+
internal static class ConsoleLdsServerEventIds
42+
{
43+
public const int Program = 0;
44+
}
45+
}

Applications/ConsoleLdsServer/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ await application
181181
}
182182
catch (Exception ex)
183183
{
184-
logger?.LogError(ex, "Fatal error starting LDS.");
184+
logger?.FatalErrorStartingLds(ex);
185185
System.Console.Error.WriteLine(ex);
186186
return 2;
187187
}
@@ -194,4 +194,12 @@ await application
194194
return rootCommand.Parse(args).InvokeAsync();
195195
}
196196
}
197+
198+
internal static partial class ProgramLog
199+
{
200+
[LoggerMessage(EventId = ConsoleLdsServerEventIds.Program + 0, Level = LogLevel.Error,
201+
Message = "Fatal error starting LDS.")]
202+
public static partial void FatalErrorStartingLds(
203+
this Microsoft.Extensions.Logging.ILogger logger, Exception exception);
204+
}
197205
}

Applications/ConsoleReferenceClient/AlarmClientSample.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using Opc.Ua.Client;
3636
using Opc.Ua.Client.Alarms;
3737
using Opc.Ua.Client.Subscriptions.Streaming;
38+
using Quickstarts.ConsoleReferenceClient;
3839

3940
namespace Quickstarts
4041
{
@@ -141,7 +142,7 @@ await alarms.AcknowledgeAsync(
141142
}
142143
catch (Exception ex)
143144
{
144-
m_logger.LogError(ex, "Acknowledge failed");
145+
m_logger.AcknowledgeFailed(ex);
145146
}
146147
}
147148
}
@@ -195,4 +196,12 @@ private static void PrintAlarm(ConditionTypeRecord record)
195196
}
196197
}
197198
}
199+
200+
internal static partial class AlarmClientSampleLog
201+
{
202+
[LoggerMessage(EventId = ConsoleReferenceClientEventIds.AlarmClientSample + 0, Level = LogLevel.Error,
203+
Message = "Acknowledge failed")]
204+
public static partial void AcknowledgeFailed(this ILogger logger, Exception ex);
205+
}
206+
198207
}

0 commit comments

Comments
 (0)