From ec1f5dc317182582ebff843c9e8a4d5277405469 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 6 Jan 2019 21:50:43 +0100 Subject: Mayor code cleanup Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment. --- .../Networking/IPNetwork/IPNetworkCollection.cs | 36 ++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs') diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs index 35cff88dc..48d404124 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs @@ -11,22 +11,12 @@ namespace System.Net private byte _cidrSubnet; private IPNetwork _ipnetwork; - private byte _cidr - { - get { return this._ipnetwork.Cidr; } - } - private BigInteger _broadcast - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.Broadcast); } - } - private BigInteger _lastUsable - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.LastUsable); } - } - private BigInteger _network - { - get { return IPNetwork.ToBigInteger(this._ipnetwork.Network); } - } + private byte _cidr => this._ipnetwork.Cidr; + + private BigInteger _broadcast => IPNetwork.ToBigInteger(this._ipnetwork.Broadcast); + + private BigInteger _lastUsable => IPNetwork.ToBigInteger(this._ipnetwork.LastUsable); + private BigInteger _network => IPNetwork.ToBigInteger(this._ipnetwork.Network); #if TRAVISCI public #else @@ -38,7 +28,7 @@ namespace System.Net int maxCidr = ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidrSubnet > maxCidr) { - throw new ArgumentOutOfRangeException("cidrSubnet"); + throw new ArgumentOutOfRangeException(nameof(cidrSubnet)); } if (cidrSubnet < ipnetwork.Cidr) @@ -68,7 +58,7 @@ namespace System.Net { if (i >= this.Count) { - throw new ArgumentOutOfRangeException("i"); + throw new ArgumentOutOfRangeException(nameof(i)); } BigInteger last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6 @@ -96,10 +86,7 @@ namespace System.Net #region IEnumerator Members - public IPNetwork Current - { - get { return this[this._enumerator]; } - } + public IPNetwork Current => this[this._enumerator]; #endregion @@ -115,10 +102,7 @@ namespace System.Net #region IEnumerator Members - object IEnumerator.Current - { - get { return this.Current; } - } + object IEnumerator.Current => this.Current; public bool MoveNext() { -- cgit v1.2.3