reactiveui /splat
Cross-platform building blocks for .NET applications. Provides service location and dependency resolution, logging, platform-neutral images, colours and geometry, and unit test and design mode detection.
★ 991⑂ 138👁 50⑃ 1,511● 205▤ 132
+0
日增长
991
stars
138
forks
50
watchers
1,511
prs
205
issues
132
releases
README
!Build
Splat
Table of Contents
- What does it do?
- How do I install?
- Detecting whether you're in a unit test runner
- Service Location
- The Default Dependency Resolver (v19+)
- AppBuilder and IModule
- Logging
- Cross platform drawing
- Cross-platform Image Loading
- Detecting if you're in design mode
- Application Performance Monitoring
- Dependency Resolver Performance Benchmarks
- Contribute
Certain types of things are basically impossible to do in cross-platform
mobile code today, yet there's no reason why. Writing a ViewModel that handles
loading a gallery of pictures from disk will be completely riddled with
ifdefs and basically unreadable.
Splat aims to fix that, by providing a usable leaky abstraction above platform
code. It is leaky, because it always provides an extension method ToNative()
and FromNative(), which converts the abstraction to the platform-specific
version. Load the image in the cross-platform code, then call ToNative() in
your view to actually display it.
What does it do?
Splat currently supports:
Cross-platform image loading/saving
A port of System.Drawing.Color for portable libraries
Cross-platform geometry primitives (PointF, SizeF, RectangleF), as well as a bunch of
additional extension methods to make using them easier.
A way to detect whether you're in a Unit Test runner / Design Mode
A cross-platform logging framework
Simple yet flexible Service Location
Core Team
Glenn Watson
Melbourne, Australia
Rodney Littles II
Texas, USA
David Vreony
UK
Chris Pulman
UK
How do I install?
Always Be NuGetting. Package contains binaries for:
.NET Framework 4.7, .NET Framework 4.7.2, .NET Standard 2.0, .NET 6.0, and .NET 8.0
- Works with:
WPF
Windows Forms
WinUI 3
Maui (WinUI, Android, iOS and Mac)
Avalonia
Detecting whether you're in a unit test runner
cs
// If true, we are running unit tests
ModeDetector.InUnitTestRunner();
Service Location
Splat provides a simple service location implementation that is optimized for
Desktop and Mobile applications, while still remaining reasonably flexible.
There are 2 parts to the locator design:
AppLocator.Current The property to use to retrieve services. AppLocator.Current is a static variable that can be set on startup, to adapt Splat to other DI/IoC frameworks. We're currently working from v7 onward to make it easier to use your DI/IoC framework of choice. (see below)
AppLocator.CurrentMutable The property to use to register services
To get a service:
cs
// To get a single service registration
var toaster = AppLocator.Current.GetService();
// To get all service registrations
var allToasterImpls = AppLocator.Current.GetServices();
Locator.Current is a static variable that can be set Top issues
Discussions
#1729How to integrate with Microsoft.Extensions.DependencyInjection and WPF before Application object is created2 comments · 2026-11-12#1070How to do scoped registrations?2 comments · 2024-01-19#984Is the locator thread safe?1 comments · 2023-01-11#769Welcome to splat Discussions!0 comments · 2021-09-14
Latest release
22.0.1 v22.0.1 2026-11-15This patch updates Splat's Primitives dependency, ReactiveUI.Disposables, from 9.0.0 to 10.0.0. It aligns Splat with the latest Primitives release without changing Splat's public API or supported target frameworks. 🗞️ What's Changed 🧹 General Changes reactiveui/splat@3e293cbb5f719e8bfaf276945f60aa6497788442 build(deps): remove unused verify dependency @glennawatson reactiveui/splat@ed819c1317333e1d33a06557576ce353634f916a build(deps): update disposables to 10.0.0 @glennawatson 🔗 Full Changelog: https://github.com/reactiveui/splat/compare/v22.0.0...v22.0.1 🙌 Contributions 💖 Thanks to