Split namespaces into Different Libraries.#3136
Conversation
shargon
left a comment
There was a problem hiding this comment.
Thanks for make this in small pr
src/Neo.IO/ByteArrayComparer.cs
Outdated
| : -CompareInternal(x, y); | ||
| if (ReferenceEquals(x, y)) return 0; | ||
| if (x is null && y is not null) return -y.Length; | ||
| if (y is null && x is not null) return x.Length; |
There was a problem hiding this comment.
If x is empty, it will return 0 that means is the same, I think that it's better to return -1 and +1 only when null
There was a problem hiding this comment.
Now tell if i'm wrong; i sometimes have trouble with stuff like this.
Currently flow goes
- if
xis same instance asyreturn0 - if
xisnullandyis notnullthen returnxis less thanylength. - if
yisnullandxis notnullthen returnxis greater thanylength - if
xandyis notnullthen return the comparison - the only thing left is: if
xandyisnullthen return0aka the same.
src/Neo.IO/ByteArrayComparer.cs
Outdated
| if (ReferenceEquals(x, y)) return 0; | ||
| if (x is null && y is not null) return -y.Length; | ||
| if (y is null && x is not null) return x.Length; | ||
| if (x is not null && y is not null) |
There was a problem hiding this comment.
Is imposible to be null x and y here, we can remove this if
There was a problem hiding this comment.
if they both null it return 0 its the last line in the method.
There was a problem hiding this comment.
But we check if both are null twice
public int Compare(byte[]? x, byte[]? y)
{
if (ReferenceEquals(x, y)) return 0; // x == y || x == null && y == null
if (x is null && y is not null)
return _direction > 0 ? -y.Length : y.Length;
if (y is null && x is not null)
return _direction > 0 ? x.Length : -x.Length;
#pragma warning disable CS8604 // Possible null reference argument.
return _direction > 0 ?
CompareInternal(x, y) :
-CompareInternal(x, y);
#pragma warning restore CS8604 // Possible null reference argument.
}
@shargon All test pass. Updated unit tests for
|
| @@ -31,7 +31,7 @@ public Logger() | |||
| } | |||
| } | |||
|
|
|||
| public static event LogEventHandler Logging; | |||
There was a problem hiding this comment.
Use Neo.Extensions in Neo.Vm to avoid duplicate Neo.VM.Utility.StrictUTF8? This can be done later.
| using Neo.IO; | ||
| using System; | ||
|
|
||
| namespace Neo.UnitTests.IO |
There was a problem hiding this comment.
We should create a test project to Neo.IO and move these test to that project.
There was a problem hiding this comment.
I planning on it.
There was a problem hiding this comment.
This PR moves existing code to new library. There is or should be tests already created. This PR also doesn't change anything for application besides, now having an extra dll. In the next few PRs will be moving and checking for tests, if none than iIl create them. Just want to get the library projects started and not be to big.
@shargon
I can create one. If you would like.
src/Neo.IO/ByteArrayComparer.cs
Outdated
| if (ReferenceEquals(x, y)) return 0; | ||
| if (x is null && y is not null) return -y.Length; | ||
| if (y is null && x is not null) return x.Length; | ||
| if (x is not null && y is not null) |
There was a problem hiding this comment.
But we check if both are null twice
public int Compare(byte[]? x, byte[]? y)
{
if (ReferenceEquals(x, y)) return 0; // x == y || x == null && y == null
if (x is null && y is not null)
return _direction > 0 ? -y.Length : y.Length;
if (y is null && x is not null)
return _direction > 0 ? x.Length : -x.Length;
#pragma warning disable CS8604 // Possible null reference argument.
return _direction > 0 ?
CompareInternal(x, y) :
-CompareInternal(x, y);
#pragma warning restore CS8604 // Possible null reference argument.
}There was a problem hiding this comment.
@shargon thanks for fixing that up. if statements lose me sometimes.
|
working on it. |
I was waiting this response #3136 (comment) |

Description
This is a small change for now. A lot more changes to come in future
PRs. But this will force everyone to organize their code to the appropriate libraries. Allnamespace,class,methodsandetcare all the same. The only difference is they may have moved to a different library. In addition, local or global variable names may have changed; these changes do not affect the functionality in any way; just following our coding practices.Please Note: This will break
neo-modules. We will need to update after thisPRis merged. Nevermind this won't break them unless you don't import fromneo.dllLibraries
Neo.IOIONeo.Extensionsneo. Including but not limited to other libraries. Notestfunctionality allowed. Please Note: you can include this library in tests; just don't add code that extendstests.Type of change
How Has This Been Tested?
Checklist: