Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit pen api #257

Merged
merged 6 commits into from
Mar 8, 2023
Merged

Conversation

stefannikolei
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 馃懏.
  • I have provided test coverage for my change (where applicable)

Description

First spike for Revisit Pen API #195. As a discussion base.

Is this how it was described in the issue or should it be totally different?

@JimBobSquarePants
Copy link
Member

I want to have a good comparison with the changes to pens in #211 There's likely some overlap.

/// <summary>
/// Options for the Pen
/// </summary>
public class PenOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we'd be better with get; init; patter here. I'd make JointStyle and EndCapStyle non-nullable also providing defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. But I would really go for the required keyword. But for that we need to use c#11 and I du not know if this is bound to net7

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's off the table unfortunately. Some stuff works, some stuff doesn't but looks like it would. I'm not sure we can take the risk.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we'd be better with get; init; patter here.

init-only setters officially require .NET 5+, so we would need to drop the old targets, which should be a bigger strategic decision. I recommend to avoid doing it in this PR, and revisit the problem when we switch to .NET 6.0+.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. We can do that then. Thanks!

public Pen(Color color, float width)
: this(new SolidBrush(color), width)
public Pen(PenOptions options)
: this(options.StrokeFill, options.StrokeWidth)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PenOptions contains the joint/endcap properties but we're not using them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've cleaned this up.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #257 (2080b0d) into main (d63aabc) will increase coverage by 0%.
The diff coverage is 86%.

@@         Coverage Diff         @@
##           main   #257   +/-   ##
===================================
  Coverage    71%    71%           
===================================
  Files        88     89    +1     
  Lines      5372   5395   +23     
  Branches   1098   1098           
===================================
+ Hits       3853   3872   +19     
- Misses     1300   1304    +4     
  Partials    219    219           
Flag Coverage 螖
unittests 71% <86%> (+<1%) 猬嗭笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage 螖
...c/ImageSharp.Drawing/Processing/BrushApplicator.cs 100% <酶> (酶)
...p.Drawing/Processing/Extensions/ClearExtensions.cs 100% <酶> (酶)
...awing/Processing/Extensions/ClearPathExtensions.cs 100% <酶> (酶)
.../Processing/Extensions/ClearRectangleExtensions.cs 100% <酶> (酶)
...wing/Processing/Extensions/DrawBezierExtensions.cs 100% <酶> (酶)
...rawing/Processing/Extensions/DrawLineExtensions.cs 100% <酶> (酶)
...cessing/Extensions/DrawPathCollectionExtensions.cs 100% <酶> (酶)
...rawing/Processing/Extensions/DrawPathExtensions.cs 100% <酶> (酶)
...ing/Processing/Extensions/DrawPolygonExtensions.cs 100% <酶> (酶)
...g/Processing/Extensions/DrawRectangleExtensions.cs 100% <酶> (酶)
... and 24 more

馃摚 We鈥檙e building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. This looks great to me now. 馃憤

Thanks for your help!

@JimBobSquarePants JimBobSquarePants merged commit dc7b553 into SixLabors:main Mar 8, 2023
@JimBobSquarePants JimBobSquarePants mentioned this pull request Mar 8, 2023
7 tasks
@antonfirsov
Copy link
Member

@stefannikolei any reason you made PenOptions a class instead of a struct?

@stefannikolei
Copy link
Contributor Author

@stefannikolei any reason you made PenOptions a class instead of a struct?

Because of #195 (comment)

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Mar 8, 2023

There's a chance those options might be removed as part of #211 I'm just merging the conflicts there now.

If not, i'll revisit for UX

@antonfirsov
Copy link
Member

antonfirsov commented Mar 8, 2023

Because of #195 (comment)

That comment actually proposes struct PenOptions, or am I missing something? If we keep it after the revisit, it's better to save a heap allocation.

@stefannikolei
Copy link
Contributor Author

Because of #195 (comment)

That comment actually proposes struct PenOptions, or am I missing something? If we keep it after the revisit, it's better to save a heap allocation.

馃檲 yeah you are absolute right.

@JimBobSquarePants
Copy link
Member

I've got it covered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants