How is changing a field to readonly a breaking change












2














I have a class library Foo, currently in version 1.0.0.



Another library Foo.Extensions of version 1.0.0, has Foo 1.0.0 as a dependency.



Both libraries try to adhere to semantic versioning, i.e. a program using Foo.Extensions 1.0.0, should be upgrade Foo to version 1.0.1 without breaking functionality of Foo.Extensions.



To avoid any breakage, I'm concerned about making updates to Foo in a source and binary compatibility way.



The Breaking Change Rules states that




Adding readonly to a field




is disallowed.



When is this a breaking change for e.g.



public class Foo
{
private int bar;
}


My best guess would be in some sort of reflection scenario, as I've experienced some (de)serializers to require properties to at least have a private setter.



How does this relates to removing a private setter from a property?



public class Foo2
{
public int Bar2 { get; private set; }
}









share|improve this question




















  • 2




    If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
    – mjwills
    Nov 22 '18 at 21:51












  • Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
    – Jota.Toledo
    Nov 22 '18 at 22:11








  • 1




    Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
    – mjwills
    Nov 22 '18 at 22:31












  • If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
    – Yatin
    Nov 22 '18 at 23:05






  • 1




    @mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
    – Yatin
    Nov 23 '18 at 0:44
















2














I have a class library Foo, currently in version 1.0.0.



Another library Foo.Extensions of version 1.0.0, has Foo 1.0.0 as a dependency.



Both libraries try to adhere to semantic versioning, i.e. a program using Foo.Extensions 1.0.0, should be upgrade Foo to version 1.0.1 without breaking functionality of Foo.Extensions.



To avoid any breakage, I'm concerned about making updates to Foo in a source and binary compatibility way.



The Breaking Change Rules states that




Adding readonly to a field




is disallowed.



When is this a breaking change for e.g.



public class Foo
{
private int bar;
}


My best guess would be in some sort of reflection scenario, as I've experienced some (de)serializers to require properties to at least have a private setter.



How does this relates to removing a private setter from a property?



public class Foo2
{
public int Bar2 { get; private set; }
}









share|improve this question




















  • 2




    If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
    – mjwills
    Nov 22 '18 at 21:51












  • Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
    – Jota.Toledo
    Nov 22 '18 at 22:11








  • 1




    Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
    – mjwills
    Nov 22 '18 at 22:31












  • If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
    – Yatin
    Nov 22 '18 at 23:05






  • 1




    @mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
    – Yatin
    Nov 23 '18 at 0:44














2












2








2







I have a class library Foo, currently in version 1.0.0.



Another library Foo.Extensions of version 1.0.0, has Foo 1.0.0 as a dependency.



Both libraries try to adhere to semantic versioning, i.e. a program using Foo.Extensions 1.0.0, should be upgrade Foo to version 1.0.1 without breaking functionality of Foo.Extensions.



To avoid any breakage, I'm concerned about making updates to Foo in a source and binary compatibility way.



The Breaking Change Rules states that




Adding readonly to a field




is disallowed.



When is this a breaking change for e.g.



public class Foo
{
private int bar;
}


My best guess would be in some sort of reflection scenario, as I've experienced some (de)serializers to require properties to at least have a private setter.



How does this relates to removing a private setter from a property?



public class Foo2
{
public int Bar2 { get; private set; }
}









share|improve this question















I have a class library Foo, currently in version 1.0.0.



Another library Foo.Extensions of version 1.0.0, has Foo 1.0.0 as a dependency.



Both libraries try to adhere to semantic versioning, i.e. a program using Foo.Extensions 1.0.0, should be upgrade Foo to version 1.0.1 without breaking functionality of Foo.Extensions.



To avoid any breakage, I'm concerned about making updates to Foo in a source and binary compatibility way.



The Breaking Change Rules states that




Adding readonly to a field




is disallowed.



When is this a breaking change for e.g.



public class Foo
{
private int bar;
}


My best guess would be in some sort of reflection scenario, as I've experienced some (de)serializers to require properties to at least have a private setter.



How does this relates to removing a private setter from a property?



public class Foo2
{
public int Bar2 { get; private set; }
}






c#






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 7:37

























asked Nov 22 '18 at 21:43









Jonas Nyrup

445310




445310








  • 2




    If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
    – mjwills
    Nov 22 '18 at 21:51












  • Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
    – Jota.Toledo
    Nov 22 '18 at 22:11








  • 1




    Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
    – mjwills
    Nov 22 '18 at 22:31












  • If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
    – Yatin
    Nov 22 '18 at 23:05






  • 1




    @mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
    – Yatin
    Nov 23 '18 at 0:44














  • 2




    If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
    – mjwills
    Nov 22 '18 at 21:51












  • Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
    – Jota.Toledo
    Nov 22 '18 at 22:11








  • 1




    Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
    – mjwills
    Nov 22 '18 at 22:31












  • If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
    – Yatin
    Nov 22 '18 at 23:05






  • 1




    @mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
    – Yatin
    Nov 23 '18 at 0:44








2




2




If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
– mjwills
Nov 22 '18 at 21:51






If you made that change, what do you think it might break? Keep in mind the doc you liked to is for a framework - so they are concerned with ensuring that API changes don't break the callers to the API.
– mjwills
Nov 22 '18 at 21:51














Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
– Jota.Toledo
Nov 22 '18 at 22:11






Adding to the previous comment, your example isnt the greatest, considering that bar isnt part of the public API of your example class.
– Jota.Toledo
Nov 22 '18 at 22:11






1




1




Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
– mjwills
Nov 22 '18 at 22:31






Also, given the quote you linked to was in the context of signatures (i.e. method signatures) you may consider updating the question to show an actual method signature. I also strongly suspect that the context implies that the field is not private (since otherwise it wouldn't form part of the signature).
– mjwills
Nov 22 '18 at 22:31














If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
– Yatin
Nov 22 '18 at 23:05




If there's an IncrementBar() method in the Foo class that increments bar, that will not work anymore; ergo, Breaking Change.
– Yatin
Nov 22 '18 at 23:05




1




1




@mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
– Yatin
Nov 23 '18 at 0:44




@mjwills, I agree, and even I couldn't think of another scenario where this change would be a breaking change.
– Yatin
Nov 23 '18 at 0:44

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438291%2fhow-is-changing-a-field-to-readonly-a-breaking-change%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438291%2fhow-is-changing-a-field-to-readonly-a-breaking-change%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Fiat S.p.A.

Type 'String' is not a subtype of type 'int' of 'index'