Skip to content

Commit

Permalink
Upgrade to dotnet50 (#11)
Browse files Browse the repository at this point in the history
* Upgrade to .NET 5.0

* Upgrade Visualizer

* Get Visualizer running

* Fix compiler warnings
  • Loading branch information
ThomasSeidenbecher authored Mar 2, 2021
1 parent 159d996 commit 7e8ae2a
Show file tree
Hide file tree
Showing 24 changed files with 794 additions and 629 deletions.
2 changes: 1 addition & 1 deletion src/Binary/Binary.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
<PackageId>opc.ua.pubsub.dotnet.binary</PackageId>
<AssemblyName>opc.ua.pubsub.dotnet.binary</AssemblyName>
Expand Down
4 changes: 2 additions & 2 deletions src/Binary/DataPoints/DataPointValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class DataPointValue : IEquatable<DataPointValue>
public int Index { get; set; }
public string Name { get; set; }
public virtual NodeID NodeID { get; }
public List<KeyValuePair> Properties { get; set; }
public List<Messages.Meta.KeyValuePair> Properties { get; set; }
public virtual StructureDescription StructureDescription { get; }

public bool Equals( DataPointValue other )
Expand Down Expand Up @@ -66,7 +66,7 @@ public override int GetHashCode()
{
int hashCode = Index;
hashCode = ( hashCode * 397 ) ^ FieldID.GetHashCode();
hashCode = ( hashCode * 397 ) ^ ( Name != null ? Name.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( Name != null ? Name.GetHashCode(StringComparison.Ordinal) : 0 );
hashCode = ( hashCode * 397 ) ^ ( Properties != null ? Properties.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( StructureDescription != null ? StructureDescription.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( EnumDescription != null ? EnumDescription.GetHashCode() : 0 );
Expand Down
14 changes: 7 additions & 7 deletions src/Binary/DataPoints/ProcessDataPointValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ProcessDataPointValue( string qualityPropertyName, string timeStampProper
m_QualityPropertyName = qualityPropertyName;
m_TimeStampPropertyName = timeStampPropertyName;
FieldID = new Guid();
Properties = new List<KeyValuePair>();
Properties = new List<Messages.Meta.KeyValuePair>();
Prefix = "";
Unit = "";
ArraySize = 0;
Expand Down Expand Up @@ -93,7 +93,7 @@ public string Prefix
get
{
// find a key/value pair in Properties list with key equal to "Prefix"
foreach ( KeyValuePair keyValuePair in Properties )
foreach ( Messages.Meta.KeyValuePair keyValuePair in Properties )
{
if ( keyValuePair.Name.Name.Value.Equals( "Prefix", StringComparison.InvariantCulture ) )
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public string Prefix
// create a new "Prefix" key/value pair if still not exists
// and add it to the Properties list;
// note that the Value must have the type UADP.String
KeyValuePair prefix = new KeyValuePair( "Prefix", new String( value ) );
Messages.Meta.KeyValuePair prefix = new Messages.Meta.KeyValuePair( "Prefix", new String( value ) );
Properties.Add( prefix );
}
else
Expand Down Expand Up @@ -202,7 +202,7 @@ public string Unit
get
{
// find a key/value pair in Properties list with key equal to "Unit"
foreach ( KeyValuePair keyValuePair in Properties )
foreach ( Messages.Meta.KeyValuePair keyValuePair in Properties )
{
if ( keyValuePair.Name.Name.Value.Equals( "Unit", StringComparison.InvariantCulture ) )
{
Expand Down Expand Up @@ -231,7 +231,7 @@ public string Unit
// create a new "Unit" key/value pair if still not exists
// and add it to the Properties list;
// note that the Value must have the type UADP.String
KeyValuePair unit = new KeyValuePair( "Unit", new String( value ) );
Messages.Meta.KeyValuePair unit = new Messages.Meta.KeyValuePair( "Unit", new String( value ) );
Properties.Add( unit );
}
else
Expand Down Expand Up @@ -378,8 +378,8 @@ public override int GetHashCode()
{
int hashCode = base.GetHashCode();
hashCode = ( hashCode * 397 ) ^ ( m_AttributeValues != null ? m_AttributeValues.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( m_TimeStampPropertyName != null ? m_TimeStampPropertyName.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( m_QualityPropertyName != null ? m_QualityPropertyName.GetHashCode() : 0 );
hashCode = ( hashCode * 397 ) ^ ( m_TimeStampPropertyName != null ? m_TimeStampPropertyName.GetHashCode(StringComparison.Ordinal) : 0 );
hashCode = ( hashCode * 397 ) ^ ( m_QualityPropertyName != null ? m_QualityPropertyName.GetHashCode(StringComparison.Ordinal) : 0 );
hashCode = ( hashCode * 397 ) ^ ArraySize;
hashCode = ( hashCode * 397 ) ^ (int)NodeIDType;
hashCode = ( hashCode * 397 ) ^ ( UserData != null ? UserData.GetHashCode() : 0 );
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Messages/DataFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected static DataPointValue ParseDataPoint( Stream inputStream, MetaFrame me
{
if ( meta.EnumDataTypes != null
&& desc.Name.Name.ToString()
.Contains( "EnumValue" ) )
.Contains( "EnumValue", StringComparison.InvariantCultureIgnoreCase ) )
{
string enumName = desc.Name.Name.Value
.Substring( 10 );
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override bool Equals( object obj )

public override int GetHashCode()
{
return Value != null ? Value.GetHashCode() : 0;
return Value != null ? Value.GetHashCode(StringComparison.Ordinal) : 0;
}

public static bool operator ==( String left, String right )
Expand Down
51 changes: 9 additions & 42 deletions src/Binary/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
".NETStandard,Version=v2.0": {
".NETCoreApp,Version=v5.0": {
"GitVersionTask": {
"type": "Direct",
"requested": "[5.5.1, )",
Expand Down Expand Up @@ -33,15 +33,6 @@
"Microsoft.SourceLink.Common": "1.0.0"
}
},
"NETStandard.Library": {
"type": "Direct",
"requested": "[2.0.3, )",
"resolved": "2.0.3",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[12.0.3, )",
Expand All @@ -55,19 +46,14 @@
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "1.1.0",
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
"resolved": "2.0.0",
"contentHash": "VdLJOCXhZaEMY7Hm2GKiULmn7IEPFE4XC5LPSfBVCUIA8YLZVh846gtfBJalsPQF2PlzdD7ecX7DZEulJ402ZQ=="
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "1.0.0",
"contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
},
"System.Buffers": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw=="
},
"System.Configuration.ConfigurationManager": {
"type": "Transitive",
"resolved": "4.5.0",
Expand All @@ -77,41 +63,19 @@
"System.Security.Permissions": "4.5.0"
}
},
"System.Memory": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "m0psCSpUxTGfvwyO0i03ajXVhgBqyXlibXz0Mo1dtKGjaHrXFLnuQ8rNBTmWRqbfRjr4eC6Wah4X5FfuFDu5og==",
"dependencies": {
"System.Buffers": "4.4.0",
"System.Numerics.Vectors": "4.4.0",
"System.Runtime.CompilerServices.Unsafe": "4.5.0"
}
},
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ=="
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "YrzNWduCDHhUaSRBxHxL11UkM2fD6y8hITHis4/LbQZ6vj3vdRjoH3IoPWWC9uDXK2wHIqn+b5gv1Np/VKyM1g=="
},
"System.Security.AccessControl": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0",
"System.Security.Principal.Windows": "4.5.0"
}
},
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "wLBKzFnDCxP12VL9ANydSYhk59fC4cvOr9ypYQLPnAj48NQIhqnjdD2yhP8yEKyBJEjERWS9DisKL7rX5eU25Q==",
"dependencies": {
"System.Memory": "4.5.0"
}
"contentHash": "wLBKzFnDCxP12VL9ANydSYhk59fC4cvOr9ypYQLPnAj48NQIhqnjdD2yhP8yEKyBJEjERWS9DisKL7rX5eU25Q=="
},
"System.Security.Permissions": {
"type": "Transitive",
Expand All @@ -124,7 +88,10 @@
"System.Security.Principal.Windows": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "U77HfRXlZlOeIXd//Yoj6Jnk8AXlbeisf1oq1os+hxOGVnuG+lGSfGqTwTZBoORFF6j/0q7HXIl8cqwQ9aUGqQ=="
"contentHash": "U77HfRXlZlOeIXd//Yoj6Jnk8AXlbeisf1oq1os+hxOGVnuG+lGSfGqTwTZBoORFF6j/0q7HXIl8cqwQ9aUGqQ==",
"dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Broker/Broker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>opc.ua.pubsub.dotnet.broker</RootNamespace>
<AssemblyName>broker</AssemblyName>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion src/Broker/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
".NETCoreApp,Version=v3.1": {
".NETCoreApp,Version=v5.0": {
"GitVersionTask": {
"type": "Direct",
"requested": "[5.5.1, )",
Expand Down
27 changes: 15 additions & 12 deletions src/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ private static void OnLogMessagePublished( object sender, MqttNetLogMessagePubli

#region Fields

internal static ushort SequenceNumber;
internal static ushort m_SequenceNumber;
private IMqttClient m_MqttClient;
private IMqttNetLogger m_MqttLogger;
private static readonly ILog Logger = LogManager.GetLogger( typeof(Client) );
private ConcurrentQueue<DecodeMessage.MqttMessage> m_MessageQueue;
private Task m_DecoderTask;
Expand Down Expand Up @@ -376,7 +377,9 @@ public void Connect( ClientCredentials credentials = null )
Logger.Error( "No certificates imported" );
}
MqttClientOptionsBuilder optionsBuilder = CreateOptionsBuilder( credentials );
m_MqttClient = new MqttFactory().CreateMqttClient();
m_MqttLogger = new MqttNetLogger();

m_MqttClient = new MqttFactory().CreateMqttClient(m_MqttLogger);
m_MqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate( e => MqttClientOnApplicationMessageReceived( e ) );
m_MqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate( e => MqttClientOnDisconnected( e ) );
IMqttClientOptions options = optionsBuilder.Build();
Expand Down Expand Up @@ -552,7 +555,7 @@ public void SendKeepAlive( ProcessDataSet dataSet, string topicPrefix )
}
else
{
byte[] keepAliveChunk = dataSet.GetEncodedKeepAliveMessage( SequenceNumber++ );
byte[] keepAliveChunk = dataSet.GetEncodedKeepAliveMessage( m_SequenceNumber++ );
Publish( keepAliveChunk, topicPrefix, dataSet.GetWriterId(), "Meas", dataSet.GetDataSetType(), false );
}
}
Expand Down Expand Up @@ -583,21 +586,21 @@ public bool SendDataSet( ProcessDataSet dataSet, string topicPrefix, bool delta
{
if ( sendDelta )
{
byte[] deltaChunk = dataSet.GetEncodedDeltaFrame( SequenceNumber++ );
byte[] deltaChunk = dataSet.GetEncodedDeltaFrame( m_SequenceNumber++ );
Publish( deltaChunk, topicPrefix, dataSet.GetWriterId(), "Meas", dataSet.GetDataSetType(), false );
}
else //meta + key
{
if ( sendMeta )
{
List<byte[]> metaChunks = dataSet.GetChunkedMetaFrame( ChunkSize, Options, SequenceNumber++ );
List<byte[]> metaChunks = dataSet.GetChunkedMetaFrame( ChunkSize, Options, m_SequenceNumber++ );
foreach ( byte[] chunk in metaChunks )
{
Publish( chunk, topicPrefix, dataSet.GetWriterId(), "Meta", dataSet.GetDataSetType(), metaChunks.Count == 1 );
UpdateLastKeyAndMetaSentTime( dataSet.GetWriterId() );
}
}
List<byte[]> keyChunks = dataSet.GetChunkedKeyFrame( ChunkSize, SequenceNumber++ );
List<byte[]> keyChunks = dataSet.GetChunkedKeyFrame( ChunkSize, m_SequenceNumber++ );
foreach ( byte[] chunk in keyChunks )
{
Publish( chunk, topicPrefix, dataSet.GetWriterId(), "Meas", dataSet.GetDataSetType(), false );
Expand Down Expand Up @@ -635,7 +638,7 @@ private MetaFrame CreateFileMetaFrame( OPCUAFile file, ushort writerId )
ExtendedFlags2 = extendedFlags2,
PublisherID = new String( ClientId )
};
metaFrame.SequenceNumber = SequenceNumber++;
metaFrame.SequenceNumber = m_SequenceNumber++;
DateTime time = DateTime.UtcNow;
metaFrame.ConfigurationVersion.Minor = (uint)( time.Ticks & uint.MaxValue );
metaFrame.ConfigurationVersion.Major = (uint)( time.Ticks >> 32 );
Expand Down Expand Up @@ -673,7 +676,7 @@ private KeyFrame CreateFileKeyFrame( MetaFrame metaFrame, OPCUAFile file )
RawValue = 0x04
}
};
key.DataSetMessageSequenceNumber = SequenceNumber++;
key.DataSetMessageSequenceNumber = m_SequenceNumber++;
key.Flags1.RawValue = 0xEB; // EBh = 1110 1011b

// Bit 0 = 1: Data set is valid
Expand Down Expand Up @@ -874,14 +877,14 @@ DataSetType dataSetType
string newTopicName = string.Empty;

// for backward compatibility we wont manipulate the topic name if i didn't find {ClientID} in it
if ( topicName.IndexOf( "{", StringComparison.InvariantCulture ) == -1 )
if ( !topicName.Contains( "{", StringComparison.InvariantCulture ) )
{
// default topic name : /siemens/uapubsub
//topicName = $"{topicPrefix}/{publisherID}/{dataSetWriterID}";
return topicName;
}
topicName = topicName.Replace( "{ClientID}", publisherID );
topicName = topicName.Replace( "{VersionMS}", "v3" );
topicName = topicName.Replace( "{ClientID}", publisherID, StringComparison.InvariantCultureIgnoreCase );
topicName = topicName.Replace( "{VersionMS}", "v3", StringComparison.InvariantCultureIgnoreCase );
TopicWildCardCharacterDto wildCardCharDto = null;
int startIndex = 0;
while ( true )
Expand Down Expand Up @@ -919,7 +922,7 @@ DataSetType dataSetType
}
if ( wildCardCharDto != null )
{
newTopicName = newTopicName.Replace( stringToReplace, wildCardCharDto.Value );
newTopicName = newTopicName.Replace( stringToReplace, wildCardCharDto.Value, StringComparison.InvariantCulture );
}
startIndex = curlyBraceEnd + 2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
<PackageId>opc.ua.pubsub.dotnet.client</PackageId>
Expand Down
12 changes: 6 additions & 6 deletions src/Client/ProcessDataSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,27 +446,27 @@ private static void CreateFieldMetaDataList( DataPointEntry entry, MetaFrame m_M
// create Properties object and add key/value pair for "Prefix"
if ( entry.DataPoint.Prefix == null )
{
fieldMetaData.Properties = new List<KeyValuePair>
fieldMetaData.Properties = new List<binary.Messages.Meta.KeyValuePair>
{
new KeyValuePair( "Prefix", new String( "" ) )
new binary.Messages.Meta.KeyValuePair( "Prefix", new String( "" ) )
};
}
else
{
fieldMetaData.Properties = new List<KeyValuePair>
fieldMetaData.Properties = new List<binary.Messages.Meta.KeyValuePair>
{
new KeyValuePair( "Prefix", new String( entry.DataPoint.Prefix ) )
new binary.Messages.Meta.KeyValuePair( "Prefix", new String( entry.DataPoint.Prefix ) )
};
}

// add key/value pair for "Unit"
if ( entry.DataPoint.Prefix == null )
{
fieldMetaData.Properties.Add( new KeyValuePair( "Unit", new String( "" ) ) );
fieldMetaData.Properties.Add( new binary.Messages.Meta.KeyValuePair( "Unit", new String( "" ) ) );
}
else
{
fieldMetaData.Properties.Add( new KeyValuePair( "Unit", new String( entry.DataPoint.Unit ) ) );
fieldMetaData.Properties.Add( new binary.Messages.Meta.KeyValuePair( "Unit", new String( entry.DataPoint.Unit ) ) );
}

// add the FieldMetaData for the given data object to the list of all FieldMetaData
Expand Down
Loading

0 comments on commit 7e8ae2a

Please sign in to comment.