Skip to content

Commit 82d09cf

Browse files
Fix StreamView Position property
Setting the position past the length is expected to increase the length of the stream.
1 parent 578d5a6 commit 82d09cf

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

sources/OpenMcdf/StreamView.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,8 @@ public override void Flush()
6363

6464
public override long Position
6565
{
66-
get
67-
{
68-
return position;
69-
}
70-
71-
set
72-
{
73-
if (position > length - 1)
74-
throw new ArgumentOutOfRangeException(nameof(value));
75-
76-
position = value;
77-
}
66+
get => position;
67+
set => Seek(value, SeekOrigin.Begin);
7868
}
7969

8070
public override int Read(byte[] buffer, int offset, int count)
@@ -184,7 +174,7 @@ public override long Seek(long offset, SeekOrigin origin)
184174
break;
185175
}
186176

187-
if (length <= position) // Don't adjust the length when position is inside the bounds of 0 and the current length.
177+
if (position > length)
188178
AdjustLength(position);
189179

190180
return position;

0 commit comments

Comments
 (0)