Skip to content

Commit 3869ec5

Browse files
Wi1l-B0tcschuchardt88shargon
committed
Style: more standard code style for Neo.VM (neo-project#4022)
Co-authored-by: Christopher Schuchardt <[email protected]> Co-authored-by: Shargon <[email protected]>
1 parent fc45051 commit 3869ec5

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

src/Neo.VM/EvaluationStack.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@ internal EvaluationStack(IReferenceCounter referenceCounter)
3333
_referenceCounter = referenceCounter;
3434
}
3535

36-
public StackItem this[int index]
37-
{
38-
get => Peek(index);
39-
}
40-
41-
public IReadOnlyList<StackItem> this[Range range]
42-
{
43-
get
44-
{
45-
var start = range.Start.GetOffset(_innerList.Count);
46-
var end = range.End.GetOffset(_innerList.Count);
47-
48-
if (start > end)
49-
throw new ArgumentOutOfRangeException("Range start must be less than or equal to end.");
50-
51-
StackItem[] copyList = [.. _innerList];
52-
List<StackItem> reverseList = [.. copyList.Reverse()];
53-
54-
return reverseList.GetRange(start, end - start);
55-
}
56-
}
57-
5836
/// <summary>
5937
/// Gets the number of items on the stack.
6038
/// </summary>

src/Neo.VM/Types/Integer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Integer(BigInteger value)
5454
{
5555
Size = value.GetByteCount();
5656
if (Size > MaxSize)
57-
throw new ArgumentException($"Integer size {Size} bytes exceeds maximum allowed size of {MaxSize} bytes.", nameof(value));
57+
throw new ArgumentException($"Can not create {nameof(Integer)}, MaxSize of {nameof(Integer)} is exceeded: {Size}/{MaxSize}.");
5858
}
5959
this.value = value;
6060
}

src/Neo.VM/Types/Map.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public StackItem this[PrimitiveType key]
4141
get
4242
{
4343
if (key.Size > MaxKeySize)
44-
throw new ArgumentException($"Key size {key.Size} bytes exceeds maximum allowed size of {MaxKeySize} bytes.", nameof(key));
44+
throw new ArgumentException($"Can not get value from map, MaxKeySize of {nameof(Map)} is exceeded: {key.Size}/{MaxKeySize}.");
4545
return _dict[key];
4646
}
4747
set
4848
{
4949
if (key.Size > MaxKeySize)
50-
throw new ArgumentException($"Key size {key.Size} bytes exceeds maximum allowed size of {MaxKeySize} bytes.", nameof(key));
50+
throw new ArgumentException($"Can not set value to map, MaxKeySize of {nameof(Map)} is exceeded: {key.Size}/{MaxKeySize}.");
5151
if (IsReadOnly) throw new InvalidOperationException("The map is readonly, can not set value.");
5252
if (ReferenceCounter != null)
5353
{
@@ -114,7 +114,7 @@ public override void Clear()
114114
public bool ContainsKey(PrimitiveType key)
115115
{
116116
if (key.Size > MaxKeySize)
117-
throw new ArgumentException($"Key size {key.Size} bytes exceeds maximum allowed size of {MaxKeySize} bytes.", nameof(key));
117+
throw new ArgumentException($"Can not check if map contains key, MaxKeySize of {nameof(Map)} is exceeded: {key.Size}/{MaxKeySize}.");
118118
return _dict.ContainsKey(key);
119119
}
120120

@@ -154,7 +154,7 @@ IEnumerator IEnumerable.GetEnumerator()
154154
public bool Remove(PrimitiveType key)
155155
{
156156
if (key.Size > MaxKeySize)
157-
throw new ArgumentException($"Key size {key.Size} bytes exceeds maximum allowed size of {MaxKeySize} bytes.", nameof(key));
157+
throw new ArgumentException($"Can not remove key from map, MaxKeySize of {nameof(Map)} is exceeded: {key.Size}/{MaxKeySize}.");
158158
if (IsReadOnly) throw new InvalidOperationException("The map is readonly, can not remove key.");
159159
if (!_dict.Remove(key, out var oldValue)) return false;
160160
ReferenceCounter?.RemoveReference(key, this);
@@ -180,7 +180,7 @@ public bool TryGetValue(PrimitiveType key, [MaybeNullWhen(false)] out StackItem
180180
#pragma warning restore CS8767
181181
{
182182
if (key.Size > MaxKeySize)
183-
throw new ArgumentException($"Key size {key.Size} bytes exceeds maximum allowed size of {MaxKeySize} bytes.", nameof(key));
183+
throw new ArgumentException($"Can not get value from map, MaxKeySize of {nameof(Map)} is exceeded: {key.Size}/{MaxKeySize}.");
184184
return _dict.TryGetValue(key, out value);
185185
}
186186
}

0 commit comments

Comments
 (0)