worlds-simplest-csharp-wpf-mvvm-example icon indicating copy to clipboard operation
worlds-simplest-csharp-wpf-mvvm-example copied to clipboard

Further simplification using C#6 features

Open igorrafael opened this issue 7 years ago • 4 comments

  • Replace backing field with C#6's get-only auto-implemented property. Arguably simpler as it does not require separate declaration of getter and backing field.
  • Using expression bodied methods in DelegateCommand implementation.
  • Remove pragma warnings as the empty bodies for add and remove are sufficient (https://blogs.msdn.microsoft.com/trevor/2008/08/14/c-warning-cs0067-the-event-event-is-never-used/)

igorrafael avatar Aug 06 '18 14:08 igorrafael

嗯,好的,谢谢大佬告知

------------------ 原始邮件 ------------------ 发件人: "Mark Withall"[email protected]; 发送时间: 2018年8月7日(星期二) 下午2:44 收件人: "MarkWithall/worlds-simplest-csharp-wpf-mvvm-example"[email protected]; 抄送: "Subscribed"[email protected]; 主题: Re: [MarkWithall/worlds-simplest-csharp-wpf-mvvm-example] Furthersimplification using C#6 features (#7)

@MarkWithall commented on this pull request.

In MinimalMVVM/ViewModel/DelegateCommand.cs:

-#pragma warning disable 67
This was added to stop ReSharper complaining about the unused event handler. It would appear that the latest version of ReShaper correctly no longer flags this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

633637 avatar Aug 07 '18 06:08 633637

Thank you for your contribution. I've added some comments with my thoughts. The changes, with the exception of the pragma removal, are all rather subjective, so I'm going to take a little time to think through them before deciding what to do.

MarkWithall avatar Aug 07 '18 07:08 MarkWithall

问一下,关于MoonPdfPanel我用Open属性打开数据源那么该用什么属性才能关闭它

------------------ 原始邮件 ------------------ 发件人: "Mark Withall"[email protected]; 发送时间: 2018年8月7日(星期二) 下午3:13 收件人: "MarkWithall/worlds-simplest-csharp-wpf-mvvm-example"[email protected]; 抄送: "序章·月光"[email protected]; "Comment"[email protected]; 主题: Re: [MarkWithall/worlds-simplest-csharp-wpf-mvvm-example] Furthersimplification using C#6 features (#7)

Thank you for your contribution. I've added some comments with my thoughts. The changes, with the exception of the pragma removal, are all rather subjective, so I'm going to take a little time to think through them before deciding what to do.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

633637 avatar Aug 07 '18 07:08 633637

My apologies for taking so long to follow up.

I've come to the conclusion, after thinking it over, that exposing History as an ObservableCollection<string> is better, as this is how WPF sees the property anyway; so we are effectively lying about the type by calling it IEnumerable<string> on the public API.

I still don't like the expression syntax for methods.

If you're happy to make the following two minor changes, I'll merge the PR:

  • Revert the expression syntax changes to Execute and CanExecute
  • Move the History property to the location in the file where the original property was; just above ConvertTextCommand

I'm happy to keep the removal of the warning suppression #pragma, as ReSharper now does the right thing.

MarkWithall avatar Aug 17 '18 13:08 MarkWithall