Comments (4)
Here's a simple example to explain the situation i just described. Use the v4.0.1 library to run this
public static void Main(string[] args)
{
MemoryStream stream = new MemoryStream();
EDecimal dec = EDecimal.FromString("34.6");
CBORObject encode = CBORObject.FromObject(dec);
encode.WriteTo(stream);
stream.Flush();
stream.Position = 0;
var decode = CBORObject.Read(stream);
bool old = decode.Type == CBORType.Number;
// this returns true in v3.4.0 but false in v4.0.1
// thus breaking functionality without compilation failures
Console.WriteLine("CBORType.Number works " + old);
Console.WriteLine("isNumber works " + decode.IsNumber);
}
from cbor.
This library follows the semantic versioning rules, where backward-incompatible behavior can exist between major versions (such as between 3.x and 4.x), but not between minor or patch versions (e.g., between 3.1 and 3.2).
In version 4.0, CBORObject
s were changed to no longer store objects directly as decimal fractions, bigfloats, or rational numbers, and CBORObject.Type
now no longer returns CBORType.Number
(which covered many of the same CBOR objects as the new IsNumber
property does) for any CBOR object. The latter change, in particular, is not backward compatible with versions earlier than 4.0. In the future, CBORType.Number
is expected to be removed in the next major version (version 5.0).
In addition, many properties and methods of CBORObject that dealt with numbers (such as AsEDecimal
, Addition
, etc.) will be deprecated in the 4.x series and many of them will be moved to the CBORNumber class, which stores numbers that CBOR will represent. These properties and methods, once deprecated, are expected to be removed in version 5.0.
from cbor.
I do agree that a major release is allowed to bring an incompatible change? but in this case the following happened:
CBORType.Number
was deprecated- Behaviour changed
- New major release
My question is: why not to remove Number
in this major release and cause a build time failure?
Right now library clients still compile, but they are broken because the behaviour is different and it seems the only way to find out about this is through testing and reading change-log. While both of the options are valid, there's inherently a risk that there's not enough tests and change-log doesn't cover all of the changes. Essentially at this point it every client has to do something to make it work again, which is best enforced by a build time failure.
Right now there's a concern that Number
change wasn't the only incompatible change and extensive testing has to be performed.
Could you please confirm whether Number
was the only such change and what would you recommend to test in addition to Number
related changes?
from cbor.
CBORType.Number
wasn't the only incompatible change in version 4.0 that wasn't the removal of an API. Another such change is the Base64Padding
property of JSONOptions
, which now has no effect in version 4.0. However, at least the deprecation notice mentions that that property now has no effect. (A third incompatible change is that CBORObject's CompareTo
method uses a different algorithm to compare CBOR objects.)
In any case, compiling code with a deprecated API will usually output a warning that the API is deprecated, and will include the deprecation notice in the warning. The mistake of the CBORType.Number
deprecation notice was that it didn't mention that the value is now no longer returned for any CBOR object. The notice will change to mention this in version 4.1, or perhaps in a patch version 4.0.2.
Note also that code that compiles with warnings, including warnings of a deprecated API, is not necessarily code that "compiles correctly". There are ways to treat warnings as build errors (either all warnings or specific ones like the deprecation warning CS0618
), such as via Visual Studio or via MSBuild's /warnAsError:CS0618
.
from cbor.
Related Issues (20)
- How to convert a type in F# to CBORobject? HOT 4
- Flags enum doesn't pass the IsDefined Check HOT 1
- Missing attribute to change name of the properties HOT 1
- Could not load file or assembly 'Numbers' HOT 2
- Unable to encode value as half-float HOT 1
- Expected double header, but found F9 HOT 1
- [Error] PeterO type or namespace could not be found. HOT 1
- CBOR NumberConverstion=Double Issue HOT 3
- Object serialization/deserialization and using integers as map keys HOT 4
- AsString throws System.InvalidOperationException: Not a text string type HOT 4
- CBOR Byte String Support HOT 2
- CBORObject.ToObject when destination type contains IReadOnlyXxxx properties HOT 4
- Efficient way to pass in immutable/non-array collections HOT 2
- Different output from VS2022 HOT 1
- Typed CBORObject.FromInt etc. HOT 4
- Premature end of data HOT 1
- Props prefixed with "Is" are not decoded HOT 3
- support/interop with System.Formats.Cbor HOT 4
- Example "custom strategy for converting objects" contains null in result object HOT 2
- Code style - reformat or add configuration file?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbor.