Consider the following code:
public enum SomeCode
{
NIF = 0
,NIE = 1
,CIF = 2
,PAS = 3
,NIN = 4
,SSN = 5
,OTH = 5
,UKN = 6
}
Would changing OTH = 5
to OTH = 7
be a breaking change?
Edit: I never store the int value, only ever the text representation of the enum. It may be used in other DLLs, but will use the same storage.
It is a breaking change, as you are changing a public API.
Libraries/applications that were built with the old value will still hold the old value and use it. You will need to recompile them all.
From MSDN - enum (C# Reference):
Just as with any constant, all references to the individual values of an enum are converted to numeric literals at compile time. This can create potential versioning issues as described in Constants (C# Programming Guide).
It depends upon whether you have control over the complete code for your solution or whether you are exporting a library to be used by others.
There are similar gotchas with publicly exposed consts.
In general, assume yes - it is a breaking change!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With