1

I have been reading about ReactiveUI, and have reached a problem on the very first example! On the project's website, the following code is given:

public class SearchViewModel : ISearchViewModel
{
    public ReactiveList<SearchResults> SearchResults { get; set; }

    private string searchQuery;
    public string SearchQuery {
        get { return searchQuery; }
        set { this.RaiseAndSetIfChanged(ref searchQuery, value); }   
    }

    public ReactiveCommand<List<SearchResults>> Search { get; set; }

    public ISearchService SearchService { get; set; }
}

And then,

public SearchViewModel(ISearchService searchService = null) : ReactiveObject, IRoutableViewHost
{
    SearchService = searchService ?? Locator.Current.GetService<ISearchService>();

    ... // example continues

}

However, I can't make any sense of the syntax used for the second part. It seems like it is half a constructor, and half a class definition.

What is it supposed to mean, exactly? I can't make a simple, equivalent example compile - is there some language/compiler extension at work?

Oliver
  • 11,297
  • 18
  • 71
  • 121
  • An inheritance-chain at constructor? Seems indeed strange? Did you miss any generic parameters making those conditions to generic gonstraints? – MakePeaceGreatAgain Jan 08 '16 at 13:02
  • 3
    Looks like a typo to me. It seems like the example code is what they are trying to highlight, so you probably can just ignore that weird constructor signature. – juharr Jan 08 '16 at 13:04
  • 1
    Isn't that the new C# 6.0 default constructor syntax? – Daniel Santos Jan 08 '16 at 13:18
  • 1
    @Daniel nope - this feature was removed from C# 6.0. See http://stackoverflow.com/a/26915809/1108916 – pmbanka Jan 08 '16 at 13:25

1 Answers1

1

This is indeeed an error/typo. The syntax is incorrect. I have just submitted a PR fixing it.

pmbanka
  • 1,902
  • 17
  • 24