kswoll / ReactiveUI.Fody

C# Fody extension to generate RaisePropertyChange notifications for properties and ObservableAsPropertyHelper properties.
MIT License
154 stars 31 forks source link

Consider different strategies to fix the CS0626 warning #11

Closed ljani closed 8 years ago

ljani commented 8 years ago

Consider the following example:

[ObservableAsProperty]
private extern string Example { get; }

This produces the following warning on VS2015, .NET 4.6.1:

Warning CS0626 Method, operator, or accessor 'ViewModel.Example' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation.

On the other hand, this won't produce a warning, but it looks slightly more complicated (and doesn't work at the moment):

private extern string Example
{
    [ObservableAsProperty]
    get;
}

One solution would be to allow both of the usages. Any other ideas how to solve this, other than suppressing the warning? Contact the Roslyn team?

Thanks for the plugin!

kswoll commented 8 years ago

@ljani thanks! I agree with you that that warning is annoying. You could use private setters instead -- though I like your suggestion of supporting the attribute being inside the getter. I will look into that.