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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernized accessor syntax in several places #13044

Merged
merged 5 commits into from
Oct 6, 2023
Merged

Modernized accessor syntax in several places #13044

merged 5 commits into from
Oct 6, 2023

Conversation

Lehonti
Copy link
Contributor

@Lehonti Lehonti commented Sep 26, 2023

What does the pull request do?

Modernizes syntax of single-expression getters and setters in several files of:

  • Avalonia.Markup.UnitTests
  • Avalonia.Markup.Xaml.UnitTests
  • Avalonia.ReactiveUI.UnitTests
  • Avalonia.RenderTests

What is the updated/expected behavior with this PR?

No behavior change

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0040042-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
}
private string BitmapPath => System.IO.Path.Combine(OutputPath, "github_icon.png");
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this is a step too far. It's less easy to read. The below would have been enough. Yes, this is dev preference which is why I would change less actually. Other people will have different opinions I'm sure.

        private string BitmapPath
        {
            get => System.IO.Path.Combine(OutputPath, "github_icon.png");
        }


private Control Visual
private Control Visual => new Panel
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is a code block in a getter you really shouldn't be "modernizing" it IMO. It is entirely developer preference in that case.

@Lehonti
Copy link
Contributor Author

Lehonti commented Sep 26, 2023

Hi @robloo I just toned down the changes a little. Specifically, the getters that perform calculations are back to having block bodies. See if you like this updated version better.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0040050-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
Copy link
Contributor

Choose a reason for hiding this comment

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

To be clear these one-liners make sense to use get => System.IO.Path.Combine(OutputPath, "github_icon.png");

I was referring to the cases where there are multiple lines of code and the cases where you removed the get accessor entirely.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0040484-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Oct 6, 2023
Merged via the queue into AvaloniaUI:master with commit d1444b4 Oct 6, 2023
5 checks passed
@Lehonti Lehonti deleted the improvement2 branch October 6, 2023 07:04
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.

4 participants