Skip to content

5.0.0 — thread-safe IPNetwork2

Choose a tag to compare

@lduchosal lduchosal released this 24 Oct 15:13
· 6 commits to master since this release
a2cce77

Highlights

IPNetwork2 is safe to share between threads

The address, family and CIDR now live in one immutable snapshot behind a single reference. Assigning Value replaces the whole network in one store, so a concurrent reader always observes a network that was actually assigned, never a mix of the old and the new one. Every single call (ToString, Contains, CompareTo, Network, Broadcast, FirstUsable, LastUsable, Usable, WildcardMask, ...) reports one coherent network.

The memoized broadcast address and hash code live on that snapshot too, so they are invalidated together with the network they describe.

Shared blocks can no longer be rewritten

The IANA_* blocks and the UniqueLocalAddress ULA prefixes used to hand out process-wide instances. Since Value is publicly settable, any caller could change what the library considers reserved or ULA. They now return a copy that shares the immutable snapshot.

Collection fixes

  • IPNetworkCollection hands out an enumerator of its own per GetEnumerator() call. A second, nested or concurrent enumeration no longer disturbs another one.
  • IPNetworkCollection and IPAddressCollection reject negative indexes.

Breaking changes

  • GetHashCode follows Value, as the Equals/GetHashCode contract requires. A network mutated after being added to a Dictionary or a HashSet can no longer be found there.
  • UniqueLocalAddress.UlaLocallyAssigned, UlaCentrallyAssigned and UlaRange are properties instead of static readonly fields. Source compatible, but code compiled against 4.x must be recompiled.
  • IANA_* and the ULA properties return a new instance on every call, so ReferenceEquals between two calls no longer holds. Use Equals.
  • AssemblyVersion is now 5.0.0.0 (it had been left at 3.2.0.0).

Full changelog: 4.3.0...5.0.0