RegisterService on GitHub seems to be out of date

Getting the following errors while trying to copy the RegisterService in a new ServiceStack app. This seems to be beyond simple dependency references since I just copied the code as a whole and all ServiceStack libraries are referenced.

if (!HostContext.AppHost.GlobalRequestFiltersAsyncArray.Contains(ValidationFilters.RequestFilterAsync)) //Already gets run
                RegistrationValidator?.ValidateAndThrow(request, registerNewUser ? ApplyTo.Post : ApplyTo.Put);

Error CS1061 ‘ServiceStackHost’ does not contain a definition for ‘GlobalRequestFiltersAsyncArray’ and no accessible extension method ‘GlobalRequestFiltersAsyncArray’ accepting a first argument of type ‘ServiceStackHost’ could be found (are you missing a using directive or an assembly reference?)

            if (registerNewUser)
            {
                session = this.GetSession();
                if (!request.AutoLogin.GetValueOrDefault())
                    session.PopulateSession(user, authRepo);

Severity Code Description Project File Line Suppression State
Error CS1503 Argument 3: cannot convert from ‘ServiceStack.Auth.IAuthRepository’ to ‘System.Collections.Generic.List ServiceStack.Auth.IAuthTokens’

That’s an internal array collection, you can use the public list HostContext.AppHost.GlobalRequestFiltersAsync but you don’t need that check at all if you have the ValidationFeature plugin registered, e.g:

Plugins.Add(new ValidationFeature());

What about this one?

if (registerNewUser)
{
    session.PopulateSession(user, authRepo);
    session.OnRegistered(Request, session, this);
    AuthEvents?.OnRegistered(this.Request, session, this);
}


Error	CS1503	Argument 3: cannot convert from 'ServiceStack.Auth.IAuthRepository' to 'System.Collections.Generic.List<ServiceStack.Auth.IAuthTokens>'

PopulateSession seems to want something different for the second argument than what the code on GitHub is expecting. How to fix this?

You could upgrade to v5.5.1 on MyGet which has the additional property in PopulateSession(), but the authRepo isn’t needed here, so you can just call it without the authRepo:

session.PopulateSession(user);

As it’s not needed I’ve also removed it from RegisterService so its source-compatible with previous versions.

Except that I can’t. Now it says:

Error	CS7036	There is no argument given that corresponds to the required formal parameter 'authTokens' of 'UserAuthRepositoryExtensions.PopulateSession(IAuthSession, IUserAuth, List<IAuthTokens>)'	

Seems like session.PopulateSession is expecting two parameters.

If you’re on v5.5 you’ll need to provide an empty List:

session.PopulateSession(user, new List<IAuthTokens>());

To find the RegisterService source code for your version of ServiceStack you’re using, you can go to the /releases tab, click on tag next to the release, e.g. v5.5:

This will now let you browse the source code for your Release, which you can either navigate to the class you’re looking for or type T to bring up GitHub’s auto-complete to quickly find files (which also supports CamelHumpsNotation).

Alternatively if you’re already at the class you want to browse/copy, you can click on the branch tag and switch to the v5.5 tag that way: