Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc9ecb9

Browse files
authored
Merge pull request ZEISS-PiWeb#18 from ZEISS-PiWeb/hotfix/PropertySerialization
fix: faulty serialization of point property ranges.
2 parents 39038cf + cc19e17 commit bc9ecb9

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

src/Formplot/FileFormat/FormplotWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ private static void CollectPointProperties( Point point, IDictionary<Property, R
313313
if( lastPoint == null )
314314
continue;
315315

316-
if( lastPoint.Properties.Contains( property ) )
316+
if( Equals( lastPoint.Properties[ property.Name ], property ) )
317317
propertyLists[ property ].Last().End = index;
318318
else
319319
propertyLists[ property ].Add( new Range( index ) );

src/Formplot/FileFormat/Property.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ private static bool Equals( Property? m1, Property? m2 )
287287
{
288288
return m1.Name == m2.Name &&
289289
m1.DataType == m2.DataType &&
290-
Equals( m1.Value, m2.Value );
290+
Equals( m1.Value, m2.Value ) &&
291+
Equals( m1.Unit, m2.Unit );
291292
}
292293

293294
return false;

src/Formplot/Formplot.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) Carl Zeiss Industrielle Messtechnik GmbH</Copyright>
1010
<Company>Carl Zeiss Industrielle Messtechnik GmbH</Company>
1111
<Authors>$(Company)</Authors>
12-
<PackageVersion>3.1.1</PackageVersion>
12+
<PackageVersion>3.1.2</PackageVersion>
1313
</PropertyGroup>
1414

1515
<PropertyGroup Label="NuGet package specifications">
@@ -18,7 +18,7 @@
1818
An API to read and write plot data for the ZEISS PiWeb quality data management system.
1919
</Description>
2020
<PackageId>Zeiss.PiWeb.Formplot</PackageId>
21-
<Version>3.1.1</Version>
21+
<Version>3.1.2</Version>
2222
<PackageIcon>logo_128x128.png</PackageIcon>
2323
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2424
<PackageProjectUrl>https://github.com/ZEISS-PiWeb/PiWeb-Formplots</PackageProjectUrl>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace Zeiss.PiWeb.Formplot.Tests.FileFormat
2+
{
3+
using System.IO;
4+
using NUnit.Framework;
5+
using Zeiss.PiWeb.Formplot.FileFormat;
6+
7+
[TestFixture]
8+
public class PropertyWriterTest
9+
{
10+
#region methods
11+
12+
[Test]
13+
public void Test_RangeLists()
14+
{
15+
const int pointCount = 10;
16+
const string propertyName = "Any";
17+
18+
var plot = new StraightnessPlot();
19+
var segment = new Segment<LinePoint, LineGeometry>( string.Empty, SegmentTypes.Line );
20+
21+
for( var i = 0; i < pointCount; i++ )
22+
{
23+
var point = new LinePoint( 0, 0 );
24+
point.Properties.Add( Property.Create( propertyName, i % 2 ) );
25+
segment.Points.Add( point );
26+
}
27+
28+
plot.Segments.Add( segment );
29+
var stream = new MemoryStream();
30+
plot.WriteTo( stream );
31+
stream.Seek( 0, SeekOrigin.Begin );
32+
var clone = Formplot.ReadFrom<StraightnessPlot>( stream );
33+
34+
Assert.That( clone, Is.Not.Null );
35+
Assert.That( clone.Segments.Count, Is.EqualTo( 1 ) );
36+
Assert.That( clone.Segments[ 0 ].Points.Count, Is.EqualTo( pointCount ) );
37+
38+
for( var i = 0; i < 10; i++ )
39+
{
40+
Assert.That( clone.Segments[ 0 ].Points[ i ].Properties[ propertyName ]?.Value, Is.EqualTo( i % 2 ) );
41+
}
42+
}
43+
44+
#endregion
45+
}
46+
}

0 commit comments

Comments
 (0)