Skip to content

Commit

Permalink
Deprecate .NET framework 4.6.2 support, sync with samples repo (#2165)
Browse files Browse the repository at this point in the history
- Deprecate support for Nuget package support of .NET Framework 4.6.2
- Bump sample applications to 4.8
- update some copyright headers / supporting files (editorconfig etc.)
- fix a few warnings
- fix an issue with `SessionReconnectHandler`, in certain combination of reconnect period and exponential backoff the .NET sample app never reconnected.
  • Loading branch information
mregen committed May 31, 2023
1 parent 5f54e08 commit 043a56c
Show file tree
Hide file tree
Showing 40 changed files with 138 additions and 223 deletions.
10 changes: 0 additions & 10 deletions .azurepipelines/signlistDebug.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
Stack\Opc.Ua.Core\bin\Debug\netstandard2.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\netstandard2.1\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\net462\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\net48\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\net6.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netcoreapp3.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\net462\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\net48\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\net6.0\Opc.Ua.Bindings.Https.dll
Libraries\Opc.Ua.Server\bin\Debug\netstandard2.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\netstandard2.1\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net462\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net48\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net6.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Client\bin\Debug\netstandard2.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\netstandard2.1\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\net462\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\net48\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\net6.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\netstandard2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\net462\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\net48\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\net6.0\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Configuration\bin\Debug\netstandard2.0\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Debug\netstandard2.1\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Debug\net462\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Debug\net48\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Debug\net6.0\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Debug\netstandard2.0\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Debug\netstandard2.1\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Debug\net462\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Debug\net48\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Debug\net6.0\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Debug\netstandard2.0\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Debug\netstandard2.1\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Debug\net462\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Debug\net48\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Debug\net6.0\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Security.Certificates\bin\Debug\netstandard2.0\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Debug\netstandard2.1\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Debug\net462\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Debug\net48\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Debug\net6.0\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.PubSub\bin\Debug\netstandard2.0\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Debug\netstandard2.1\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Debug\net462\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Debug\net48\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Debug\net6.0\Opc.Ua.PubSub.dll
10 changes: 0 additions & 10 deletions .azurepipelines/signlistRelease.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
Stack\Opc.Ua.Core\bin\Release\netstandard2.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\netstandard2.1\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\net462\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\net48\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\net6.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netcoreapp3.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\net462\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\net48\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\net6.0\Opc.Ua.Bindings.Https.dll
Libraries\Opc.Ua.Server\bin\Release\netstandard2.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Release\netstandard2.1\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Release\net462\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Release\net48\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Release\net6.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Client\bin\Release\netstandard2.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\netstandard2.1\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\net462\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\net48\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\net6.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\netstandard2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\net462\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\net48\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\net6.0\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Configuration\bin\Release\netstandard2.0\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Release\netstandard2.1\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Release\net462\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Release\net48\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Configuration\bin\Release\net6.0\Opc.Ua.Configuration.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Release\netstandard2.0\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Release\netstandard2.1\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Release\net462\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Release\net48\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Client.Common\bin\Release\net6.0\Opc.Ua.Gds.Client.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Release\netstandard2.0\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Release\netstandard2.1\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Release\net462\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Release\net48\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Gds.Server.Common\bin\Release\net6.0\Opc.Ua.Gds.Server.Common.dll
Libraries\Opc.Ua.Security.Certificates\bin\Release\netstandard2.0\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Release\netstandard2.1\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Release\net462\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Release\net48\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.Security.Certificates\bin\Release\net6.0\Opc.Ua.Security.Certificates.dll
Libraries\Opc.Ua.PubSub\bin\Release\netstandard2.0\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Release\netstandard2.1\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Release\net462\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Release\net48\Opc.Ua.PubSub.dll
Libraries\Opc.Ua.PubSub\bin\Release\net6.0\Opc.Ua.PubSub.dll
36 changes: 29 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@ charset = utf-8
trim_trailing_whitespace = true
end_of_line = crlf
insert_final_newline = true
max_line_length = 120

# Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
[*.{xml,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

# YAML files
[*.{yml,yaml}]
indent_size = 2

###############################
# .NET Coding Conventions #
###############################
Expand Down Expand Up @@ -81,6 +86,8 @@ csharp_space_between_square_brackets =

dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
csharp_style_prefer_method_group_conversion = true : silent
csharp_style_prefer_top_level_statements = true : silent

#Formatting - spacing options

Expand All @@ -95,7 +102,6 @@ csharp_space_between_method_declaration_empty_parameter_list_parentheses =
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

Expand Down Expand Up @@ -123,9 +129,9 @@ csharp_style_inlined_variable_declaration =
csharp_prefer_simple_using_statement = false : suggestion

#Style - implicit and explicit types
csharp_style_var_for_built_in_types = false : silent
csharp_style_var_when_type_is_apparent = true : silent
csharp_style_var_elsewhere = false : silent
csharp_style_var_for_built_in_types = false : suggestion
csharp_style_var_when_type_is_apparent = true : suggestion
csharp_style_var_elsewhere = false : suggestion

#Style - language keyword and framework type options

Expand Down Expand Up @@ -164,11 +170,23 @@ dotnet_style_prefer_conditional_expression_over_assignment =
dotnet_style_prefer_conditional_expression_over_return = true : suggestion

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace : silent
csharp_style_namespace_declarations = block_scoped : silent
csharp_using_directive_placement = outside_namespace : suggestion
csharp_style_namespace_declarations = block_scoped : suggestion

# Naming rules

# Async methods should have "Async" suffix
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async

dotnet_naming_symbols.any_async_methods.applicable_kinds = method, interface
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
dotnet_naming_symbols.any_async_methods.required_modifiers = async

dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case

# Private Constants are PascalCase and start with k
dotnet_naming_rule.constants_private_should_start_with_k.severity = suggestion
dotnet_naming_rule.constants_private_should_start_with_k.symbols = constants_with_k
Expand Down Expand Up @@ -297,8 +315,12 @@ dotnet_code_quality.CA1822.api_surface =
dotnet_diagnostic.CA3075.severity = error
dotnet_diagnostic.CA3077.severity = error

# CA2007: Do not directly await a Task
dotnet_diagnostic.CA2007.severity = warning

# IDE0049: Simplify Names
dotnet_diagnostic.IDE0049.severity = silent

# CA1507: Use nameof in place of string
dotnet_diagnostic.CA1507.severity = warning

11 changes: 0 additions & 11 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ jobs:
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.3.1

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

- name: Restore Packages
run: |
Expand Down
6 changes: 3 additions & 3 deletions Applications/ClientControls.Net4/ClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public static ReferenceDescriptionCollection Browse(Session session, ViewDescrip
ClientBase.ValidateResponse(results, continuationPoints);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);

ByteStringCollection revisedContiuationPoints = new ByteStringCollection();
ByteStringCollection revisedContinuationPoints = new ByteStringCollection();
for (int ii = 0; ii < continuationPoints.Count; ii++)
{
// check for error.
Expand All @@ -402,12 +402,12 @@ public static ReferenceDescriptionCollection Browse(Session session, ViewDescrip
// check for continuation point.
if (results[ii].ContinuationPoint != null)
{
revisedContiuationPoints.Add(results[ii].ContinuationPoint);
revisedContinuationPoints.Add(results[ii].ContinuationPoint);
}
}

// check if browsing must continue;
continuationPoints = revisedContiuationPoints;
continuationPoints = revisedContinuationPoints;
}

// check if unprocessed results exist.
Expand Down
38 changes: 22 additions & 16 deletions Applications/ClientControls.Net4/Common/Client/ConnectServerCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public ConnectServerCtrl()
/// </summary>
public static readonly uint DefaultSessionTimeout = 60000;
public static readonly int DefaultDiscoverTimeout = 15000;
public static readonly int DefaultReconnectPeriod = 10;
public static readonly int DefaultReconnectPeriod = 1;
public static readonly int DefaultReconnectPeriodExponentialBackOff = 10;

/// <summary>
/// A strip used to display session status information.
Expand Down Expand Up @@ -211,12 +212,12 @@ public ApplicationConfiguration Configuration
public int ReconnectPeriod { get; set; } = DefaultReconnectPeriod;

/// <summary>
/// The discover timeout.
/// The discover timeout in ms.
/// </summary>
public int DiscoverTimeout { get; set; } = DefaultDiscoverTimeout;

/// <summary>
/// The session timeout.
/// The session timeout in ms.
/// </summary>
public uint SessionTimeout { get; set; } = DefaultSessionTimeout;

Expand Down Expand Up @@ -319,7 +320,10 @@ public void SetAvailableUrls(IList<string> urls)
PreferredLocales);

// set up keep alive callback.
m_session.KeepAlive += new KeepAliveEventHandler(Session_KeepAlive);
m_session.KeepAlive += Session_KeepAlive;

// set up reconnect handler.
m_reconnectHandler = new SessionReconnectHandler(true, DefaultReconnectPeriodExponentialBackOff * 1000);

// raise an event.
DoConnectComplete(null);
Expand Down Expand Up @@ -386,6 +390,9 @@ public Task<Session> Connect()
// set up keep alive callback.
m_session.KeepAlive += new KeepAliveEventHandler(Session_KeepAlive);

// set up reconnect handler.
m_reconnectHandler = new SessionReconnectHandler(true, DefaultReconnectPeriodExponentialBackOff * 1000);

// raise an event.
DoConnectComplete(null);

Expand Down Expand Up @@ -636,15 +643,10 @@ private void Session_KeepAlive(ISession session, KeepAliveEventArgs e)

UpdateStatus(true, e.CurrentTime, "Reconnecting in {0}s", ReconnectPeriod);

if (m_reconnectHandler == null)
var state = m_reconnectHandler.BeginReconnect(m_session, ReconnectPeriod * 1000, Server_ReconnectComplete);
if (state == SessionReconnectHandler.ReconnectState.Triggered)
{
if (m_ReconnectStarting != null)
{
m_ReconnectStarting(this, e);
}

m_reconnectHandler = new SessionReconnectHandler(true);
m_reconnectHandler.BeginReconnect(m_session, ReconnectPeriod * 1000, Server_ReconnectComplete);
m_ReconnectStarting?.Invoke(this, e);
}

return;
Expand Down Expand Up @@ -730,12 +732,16 @@ private void Server_ReconnectComplete(object sender, EventArgs e)
// only apply session if reconnect was required
if (m_reconnectHandler.Session != null)
{
m_session = m_reconnectHandler.Session as Session;
if (!ReferenceEquals(m_session, m_reconnectHandler.Session))
{
var session = m_session;
session.KeepAlive -= Session_KeepAlive;
m_session = m_reconnectHandler.Session as Session;
m_session.KeepAlive += Session_KeepAlive;
Utils.SilentDispose(session);
}
}

m_reconnectHandler.Dispose();
m_reconnectHandler = null;

// raise any additional notifications.
if (m_ReconnectComplete != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ public static bool HandleDomainCheckError(string caption, ServiceResult serviceR
}
buffer.Append("This certificate validation error indicates that the hostname used to connect");
buffer.Append(" is not listed as a valid hostname in the server certificate.");
buffer.Append("\r\n\r\nIgnore error and disable the hostname verification?");
buffer.Append("\r\n\r\nRetry with disabled hostname verification?");

if (MessageBox.Show(buffer.ToString(), caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
if (MessageBox.Show(buffer.ToString(), caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
return true;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ public static void HandleCertificateValidationError(string caption, CertificateV
buffer.Append("to a server or to allow an untrusted client to connect to your server.");
buffer.Append("\r\n\r\nAccept anyway?");

if (MessageBox.Show(buffer.ToString(), caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
if (MessageBox.Show(buffer.ToString(), caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
e.AcceptAll = true;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 043a56c

Please sign in to comment.