Edit on GitHub

v4.0.30 Release Notes

Add ServiceStack Reference

We have an exciting feature in this release showcasing our initial support for generating Native Types from client VS.NET projects using ServiceStackVS new Add ServiceStack Reference feature. It provides a simpler, cleaner and more versatile alternative to WCF’s Add Service Reference in VS.NET.

Our goal with Native Types is to provide an alternative for sharing DTO dlls, that can enable a better dev workflow for external clients who are now able to generate (and update) Typed APIs for your Services from a remote url - reducing the burden and effort required to consume ServiceStack Services whilst benefiting from clients native language strong-typing feedback.

This is just the beginning, whilst C# is the first language supported it lays the groundwork and signals our approach on adding support for typed API’s in other languages in future. Add a feature request for your favorite language to prioritize support for it sooner!

Example Usage

The easiest way to Add a ServiceStack reference to your project is to right-click on your project to bring up ServiceStackVS’s Add ServiceStack Reference context-menu item. This opens a dialog where you can add the url of the ServiceStack instance you want to typed DTO’s for, as well as the name of the T4 template that’s added to your project.

Add ServiceStack Reference

After clicking OK, the servers DTO’s and ServiceStack.Client NuGet package are added to the project, providing an instant typed API:

Calling ServiceStack Service

Consuming Services from Mobile Clients now Easier than Ever!

In addition with our improved PCL Support in this release, it’s never been easier to create an instant Typed API for a remote Service consumable from any Xamarin.Android, Xamarin.iOS, Silverlgiht 5, Windows Store or .full NET4.0+ platforms - Here’s a quick demo of it working in Android:

Android Add ServiceStack Reference

Advantages over WCF

Available from v4.0.30+ ServiceStack Projects

Native Types is now available by default on all v4.0.30+ ServiceStack projects. It can be disabled by removing the NativeTypesFeature plugin with:

Plugins.RemoveAll(x => x is NativeTypesFeature);

For detailed info on how NativeTypesFeature works, its different customization options and improvements over WCF, checkout the Add ServiceStack Reference docs.

Upgrade ServiceStackVS

To take advantage of this feature Upgrade or Install ServiceStackVS VS.NET Extension. If you already have ServiceStackVS installed, uninstall it first from Tools -> Extensions and Updates... -> ServiceStackVS -> Uninstall.

Improved PCL Story

Our PCL Story has been greatly improved in this release now that ServiceStack.Interfaces has been converted into a pure PCL dll. This now lets you maintain your server DTO’s in a pure PCL DLL that can be shared as-is on most supported platforms (Profile136):

Whilst our impl-free ServiceStack.Interfaces.dll was able to be converted into a pure PCL dll, our Client libraries have instead resorted to using PCL’s Bait and Switch technique to provide platform-specific extensions and optimizations. The one outlier is Silverlight5 which remains a custom (non-PCL) SL5 build, that whilst can now share DTO’s, still can’t support projects with dependencies on the PCL-compatible version of ServiceStack.Client.

As of this release all PCL, platform and Silverlight dlls are now merged into the main ServiceStack.Client NuGet packages so now any clients need only reference the main Client NuGet package:

Install-Package ServiceStack.Client

The Hello PCL project now contains examples of reusing a Server DTO project with all supported client platforms as well as showing re-use of a high-level SharedGateway which referenes ServiceStack.Client that’s shared between all PCL-compatible platforms.

New ServiceStack + AngularJS Example - StackApis

StackApis Home

StackApis is a simple new ServiceStack + AngularJS example project created with ServiceStackVS AngularJS Template showcasing how quick and easy it is to create responsive feature-rich Single Page Apps with AngularJS and AutoQuery. StackApis is powered by a Sqlite database containing snapshot of ServiceStack questions from StackOverflow APIs that’s persisted in an sqlite database using OrmLite.

StackApis AutoQuery Service

The Home Page is built with less than <50 Lines of JavaScript which thanks to AutoQuery routes all requests to the single AutoQuery Service below:

[Route("/questions")]
public class StackOverflowQuery : QueryBase<Question>
{
    public int? ScoreGreaterThan { get; set; }
}

Not even ScoreGreaterThan is a required property, it’s just an example of a formalized convention enabling queries from Typed Service Clients.

Feel free to play around with a deployed version of StackApis at stackapis.servicestack.net.

You can also use the public http://stackapis.servicestack.net/ url to test out ServiceStack’s new Add ServiceStack Reference feature :)

Swagger Support

All static resources are now embedded

ServiceStack’s Swagger Support received some welcomed enhancements thanks to @tvjames and @tyst’s efforts which now sees all of Swagger’s static resources embedded into a single ServiceStack.Api.Swagger.dll, taking advantage of the Virtual File Systems transparent support for Embedded Resources, making it easier to manage and upgrade Swagger as a self-contained unit.

New Bootstrap theme for Swagger

A new attractive Bootstrap Theme was also added to Swagger, available from /swagger-ui-bootstrap/:

Swagger Bootstrap

You can change the metadata page plugin link to point to this new theme with:

Plugins.Add(new SwaggerFeature {
    UseBootstrapTheme = true, 
    LogoUrl = "your-logo.png" //optional use your own logo
});

Swagger was also been updated to the latest version.

Authentication

Unique Emails

ServiceStack now verifies emails returned by OAuth providers are now unique where if there’s already another UserAuth with an existing email, authentication will fail and redirect (for HTML/Web Browser requests) with the Error token:

/#f=EmailAlreadyExists

This behavior is in-line with ServiceStack’s other AuthProviders. If this change causes any issues, it can be disabled with:

AuthProvider.ValidateUniqueEmails = false;

This doesn’t apply to Users who login with multiple OAuth Providers as there accounts automatically get merged into a single UserAuth entity.

CustomValidationFilter

A new CustomValidationFilter was added to all AuthProviders which can be used to return a IHttpResult to control what error response is returned, e.g:

Plugins.Add(new AuthFeature(
    () => new CustomUserSession(), 
    new IAuthProvider[] {
        new FacebookAuthProvider(appSettings) { 
            CustomValidationFilter = authCtx => 
                CustomIsValid(authCtx) 
                    ? authCtx.Service.Redirect(authCtx.Session.ReferrerUrl
                        .AddHashParam("f","CustomErrorCode"))
                    : null,
        },
    }));

Breaking Changes

Upgrade all ServiceStack NuGet packages

The primary breaking change was converting ServiceStack’s core ServiceStack.Interfaces.dll into a pure portable class library which as it’s incompatible with the previous non-PCL ServiceStack.Interfaces.dll requires that all NuGet dependenices (inc. transitive dependencies) be upgraded to v4.0.30. The version number was bumped to v4.0.30 specifically to stress that it’s incompatible with any <v4.0.2x before it. The only other issue we ran into after upgrading most of ServiceStack projects is on projects that reference or mock Interfaces that reference a System.Net.* Type like HttpWebResponse in IServiceClient will now require an explicit reference to System.Net for the C# compiler to consider them to be of the same type.

In summary if you have a build error when upgrading v4.0.30 then:

More details about these issues is available on the announcement post.

TypeDescriptor support removed

In order to convert ServiceStack.Interfaces into a portable class library we’ve had to remove support for an undocumented feature allowing adding of Attributes via .NET’s TypeDescriptor. If you were using TypeDescriptor, you can switch to adding attributes dynamically using ServiceStack’s Reflection APIs.