WebSharper 4 was a long journey. Started from the initial idea to add C# support and move to read F# source code directly for covering F# language features better, a lot of other new features requested by the community or needed for ongoing projects were added to make development with WebSharper even more powerful.
Today we are publishing the full stack of
WebSharper libraries, compilers and extensions with the
Feature-wise these are the same as the latest
Zafir (WebSharper 4 codename) releases.
WebSharper 4 is open source under the Apache 2.0 License. Contributions are welcome at the GitHub repository.
For updating previous WebSharper 3 projects and breaking changes, look for the upgrade guide.
We are continuing to round out the documentation with more help for beginners. Your questions are welcome on the forums. All the source for the documentation browser are also available on GitHub, please feel free to submit issues and pull requests.
Try WebSharper has also been updated, test out WebSharper for both languages right in your browser.
Big thanks to everyone who has been testing WebSharper 4 beta and submitted bug reports, questions and feature ideas!
Biggest new features
1 2 3 4 5
- Many new .NET framework features are usable client-side, including delegates, Tasks (usable for remote calls too), Linq methods.
1 2 3 4 5
ul( // Create HTML list from a query. Syntax is reusable for both server and client (from p in people where p.Age > 18 select li(attr.@class("person-name"), p.Name)).ToArray() );
- All F# language features are now supported, up to date with F# 4.1, including object expressions,
&operator, inner generic functions, pattern matching on arrays, statically resolved type parameters, struct unions and records. While WebSharper 3 focused on the functional programming aspects of F#, with the introduction of C# support, WebSharper 4 embraces object-oriented programming too for both languages.
1 2 3 4
New templating engine
UI.Next has been updated with a newer templating syntax and engine that allows declaratively reusing sub-templates and has more flexibility for filling in holes while keeping strong typing. For details, see the documentation.
Other new features
- Erased union and option types have been added to
Optional. These are similar to
Optiontypes of F#, but work as TypeScript's erased unions in the JS translation. Conversion functions are available under modules
- Classes now have reference equality by default (you can override Equals as in .NET). Arrays, tuples, F# records and unions still use structural equality.
- Automatic download of remote web resources to serve from locally. Set
True</WebSharperDownloadResources> in your project file to have WebSharper download all remote js/css defined in current project and all references. Add to your section in web.config.
- Auto-hash WebSharper-generated output and files included as WebResource, use this hash on generating links to avoid browsers caching an outdated version.
List.map2. This is done by analyzing uses of the function parameter, not making any assumptions.
- And many more, see list of beta releases on GitHub for full details.
For the 4.0 stable release, we will publish a site to browse what .NET types and methods WebSharper translation cover via proxies. We will use this ourselves to expand coverage where lacking. We will also address bug reports coming in for the RC release.
High on our priority list for 4.x versions:
- .NET Core and Standard support
- Web workers with a type-safe communication
- TypeScript 2.5 interoperability: generate .NET wrapper classes for
.d.tsfor WebSharper code
- WebAssembly interoperability: generate .NET wrapper classes for
.wasmfiles and compile a subset of the languages to WebAssembly
Discuss upcoming features and make feature requests on the WebSharper forums.