Repository navigation
Move meta data properties to new classes. - #99
Conversation
Codecov Report@@ Coverage Diff @@
## master #99 +/- ##
==========================================
+ Coverage 88.19% 88.31% +0.12%
==========================================
Files 406 410 +4
Lines 19493 19575 +82
Branches 1405 1400 -5
==========================================
+ Hits 17192 17288 +96
+ Misses 1893 1880 -13
+ Partials 408 407 -1
Continue to review full report at Codecov.
|
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Looks good to me. I'll let you decide on the AutoProperties.
| /// <param name="image">The <see cref="ImageBase{TColor}"/> to encode from.</param> | ||
| /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> | ||
| public void Encode<TColor>(ImageBase<TColor> image, Stream stream) | ||
| public void Encode<TColor>(Image<TColor> image, Stream stream) |
There was a problem hiding this comment.
Oops! Yeah that should definitely be Image<TColor>
| /// The default horizontal resolution value (dots per inch) in x direction. | ||
| /// <remarks>The default value is 96 dots per inch.</remarks> | ||
| /// </summary> | ||
| public const double DefaultHorizontalResolution = 96; |
There was a problem hiding this comment.
Do we still need these constants?
We can probably do public double HorizontalResolution {get; set;} = 96
There was a problem hiding this comment.
They are public so that's why I did not remove them. I did not use auto properties with HorizontalResolution because I want to protect them from being set to a value lower or equal to zero. I am okay with removing the constants and setting it in the constructor. Can I go ahead and change this?
| /// </param> | ||
| internal ImageMetaData(ImageMetaData other) | ||
| { | ||
| Debug.Assert(other != null); |
There was a problem hiding this comment.
Now I know why you were asking...
There was a problem hiding this comment.
Yeah, code talks better than twitter 😄.
|
|
||
| set | ||
| { | ||
| if (value > 0) |
There was a problem hiding this comment.
I wonder why do we silently ignore <=0 values instead of throwing an exception. Is this some kind of standard imaging behavior I don't know about? :)
There was a problem hiding this comment.
Personally not a big fan of throwing exceptions inside properties. Rather ignore invalid values. What do you prefer @JimBobSquarePants?
There was a problem hiding this comment.
Meant to respond to this earlier. We're inconsistent in the library. Sometimes we throw, sometimes we clamp. Leave it as is just now but we should readers the library again before final release.
|
|
||
| image.MetaData.SyncProfiles(); | ||
|
|
||
| Assert.Equal(100, ((Rational)image.MetaData.ExifProfile.GetValue(ExifTag.XResolution).Value).ToDouble()); |
There was a problem hiding this comment.
I really believe that unit tests are more valuable, if they contain a single AAA block / test case and have a descriptive name saying an actual Fact about the component under test.
A little bit longer to write, easier to maintain and understand.
There was a problem hiding this comment.
As you have noticed I have a different way of writing the tests. I use Arrange, Act, Assert, Act, Assert ... a lot of times. But I do think we need some common way of how we set up tests. We have a lot of different styles now. I think we need some help from our Grand High Eternal Dictator @JimBobSquarePants
There was a problem hiding this comment.
Tests need a cleanup to be honest. We've got a lot of integration tests but we really need a lot more simple AAA unit tests.
We should look at CoreFX for inspiration. Their tests are a great example of how to keep the tests concise and descriptive.
There was a problem hiding this comment.
I also think corefx tests show a good example, I strongly support following their standard:
- One test case is testing only one aspect of a "thing" (proving one fact), no long test cases containing multiple AAA blocks
- All facts/theories have a descriptive name, no need for additional comments
- If the fact (to be proven by the test) is coplex enough, it's encouraged to use underscores in it's name to improve readability.
There was a problem hiding this comment.
@antonfirsov You and your naming! 😝 I'll actually allow that in tests since naming is so totally different from normal source and it does improve readability in these cases.
| this.SyncExifProfile(); | ||
| } | ||
|
|
||
| private void SyncExifProfile() |
There was a problem hiding this comment.
Wouldn't it be better to move this method into ExifProfile and use it as this.ExifProfile?.Sync(this)?
There was a problem hiding this comment.
To me it felt like the logic should be inside the ImageMetaData class.
There was a problem hiding this comment.
I guess all profiles should probably have a common Sync method enforced by an interface.
There was a problem hiding this comment.
It seems to be a Profile-concern to sync it from an ImageMetadata.
There was a problem hiding this comment.
Okay i'll move it to the ExifProfile.
Prerequisites
Description
This pull requests moves out all the meta data properties to two new classes. One is called
ImageMetaDataand this is used in theImage<TColor>class and the other one is calledImageFrameMetaDataand is used in theImageFrameclass. The latter only contains a FrameDelay value because we only need this at the moment. This could have been added to the ImageFrame class but the TIFF format will not use this.