-
Notifications
You must be signed in to change notification settings - Fork 1.7k
AVRO-3345: Made Magic readonly in DataFileConstants #1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,9 +21,6 @@ namespace Avro.File | |
| /// <summary> | ||
| /// Constants used in data files. | ||
| /// </summary> | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", | ||
| "CA1052:Static holder types should be Static or NotInheritable", | ||
| Justification = "Maintain public API")] | ||
| public class DataFileConstants | ||
| { | ||
| /// <summary> | ||
|
|
@@ -64,10 +61,13 @@ public class DataFileConstants | |
| /// <summary> | ||
| /// Magic bytes at the beginning of an Avro data file. | ||
| /// </summary> | ||
| public static byte[] Magic = { (byte)'O', | ||
| (byte)'b', | ||
| (byte)'j', | ||
| Version }; | ||
| public static readonly byte[] Magic = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The looks like an API change but I guess no one is supposed to change the magic bytes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change was formatting.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean ? AFAIU
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct. Do we want the backwards support to allow the change? It appears the intention was that it is a constant hence the readonly static. Like with most things, if it is available someone is using it. The other option is I can mark this obsolete, and add the remark for a future change that it be made readonly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am 99% sure no one is setting custom value for the |
||
| { | ||
| (byte)'O', | ||
| (byte)'b', | ||
| (byte)'j', | ||
| Version, | ||
| }; | ||
|
|
||
| /// <summary> | ||
| /// Hash code for the null codec. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to the
Magicconstant ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was, but it's an old rule. The way you get rid of it, is just make the static property readonly. Allows you to essentially make a static property a constant. The reason you do this is because constants are basic types and not a reference type like an array.