├── .editorconfig ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── renovate.json └── workflows │ ├── ci-build.yml │ ├── lock.yml │ └── release.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── images └── logo.png ├── src ├── Benchmarks │ ├── CurrentBenchmark.cs │ ├── CurrentMutableBenchmark.cs │ ├── DependencyResolver.cs │ ├── Directory.Packages.props │ ├── LocatorBenchmark.cs │ ├── Program.cs │ ├── Splat.Benchmarks.csproj │ ├── Splat.Benchmarks.sln │ └── ViewModel.cs ├── Directory.Packages.props ├── Directory.build.props ├── Directory.build.targets ├── ReactiveUI.DI.Tests │ ├── AutoFacReactiveUIDependencyTests.cs │ ├── DryIocReactiveUIDependencyTests.cs │ ├── Mocks │ │ ├── ActivatingView.cs │ │ ├── ActivatingViewFetcher.cs │ │ └── ActivatingViewModel.cs │ ├── NinjectReactiveUIDependencyTests.cs │ ├── ReactiveUI.DI.Tests.csproj │ ├── SimpleInjectorReactiveUIDependencyTests.cs │ └── ViewWithViewContractThatShouldNotLoad.cs ├── Splat.AppCenter │ ├── AppCenterFeatureUsageTrackingSession.cs │ ├── AppCenterViewTracking.cs │ └── Splat.AppCenter.csproj ├── Splat.ApplicationInsights │ ├── ApplicationInsightsFeatureUsageTrackingSession.cs │ ├── ApplicationInsightsViewTracking.cs │ └── Splat.ApplicationInsights.csproj ├── Splat.Autofac.Tests │ ├── DependencyResolverTests.cs │ ├── Splat.Autofac.Tests.csproj │ └── xunit.runner.json ├── Splat.Autofac │ ├── AutofacDependencyResolver.cs │ ├── README.md │ ├── Splat.Autofac.csproj │ └── SplatAutofacExtensions.cs ├── Splat.Avalonia.Autofac │ ├── AvaloniaMixins.cs │ └── Splat.Avalonia.Autofac.csproj ├── Splat.Avalonia.DryIoc │ ├── AvaloniaMixins.cs │ └── Splat.Avalonia.DryIoc.csproj ├── Splat.Avalonia.DryIoc1.Tests │ ├── AvaloniaUIThreadTestsDryIoc.cs │ └── Splat.Avalonia.DryIoc1.Tests.csproj ├── Splat.Avalonia.DryIoc2.Tests │ └── Splat.Avalonia.DryIoc2.Tests.csproj ├── Splat.Avalonia.Microsoft.Extensions.DependencyInjection │ ├── AvaloniaMixins.cs │ └── Splat.Avalonia.Microsoft.Extensions.DependencyInjection.csproj ├── Splat.Avalonia.Microsoft1.Tests │ ├── AvaloniaUIThreadTestsMicrosoft.cs │ └── Splat.Avalonia.Microsoft1.Tests.csproj ├── Splat.Avalonia.Microsoft2.Tests │ └── Splat.Avalonia.Microsoft2.Tests.csproj ├── Splat.Avalonia.Ninject │ ├── AvaloniaMixins.cs │ └── Splat.Avalonia.Ninject.csproj ├── Splat.Avalonia.Tests │ ├── AvaloniaUIThreadTestsMain.cs │ ├── Mocks │ │ ├── App.axaml │ │ ├── App.axaml.cs │ │ ├── MainWindow.axaml │ │ ├── MainWindow.axaml.cs │ │ ├── ViewModels │ │ │ ├── BarViewModel.cs │ │ │ ├── FooViewModel.cs │ │ │ ├── MainWindowViewModel.cs │ │ │ └── RoutedViewHostPageViewModel.cs │ │ └── Views │ │ │ ├── BarView.axaml │ │ │ ├── BarView.axaml.cs │ │ │ ├── FooView.axaml │ │ │ └── FooView.axaml.cs │ └── Splat.Avalonia.Tests.csproj ├── Splat.Common.Test │ ├── DummyObjectClass1.cs │ ├── DummyObjectClass2.cs │ ├── DummyObjectClass3.cs │ ├── IDummyInterface.cs │ ├── IScreen.cs │ ├── IViewFor.cs │ ├── IViewModelOne.cs │ ├── MockScreen.cs │ ├── Splat.Common.Test.csproj │ ├── ViewModelOne.cs │ ├── ViewModelTwo.cs │ ├── ViewOne.cs │ ├── ViewThatShouldNotLoad.cs │ └── ViewTwo.cs ├── Splat.Drawing.Tests │ ├── API │ │ ├── ApiApprovalTests.SplatUIProject.DotNet8_0.verified.txt │ │ ├── ApiApprovalTests.SplatUIProject.DotNet9_0.verified.txt │ │ └── ApiApprovalTests.cs │ ├── BitmapLoaderTests.cs │ ├── Colors │ │ ├── CoverageColorTests.cs │ │ ├── KnownColorTests.cs │ │ └── SplatColorTests.cs │ ├── PlatformBitmapLoaderTests.cs │ └── Splat.Drawing.Tests.csproj ├── Splat.Drawing │ ├── Bitmaps │ │ ├── BitmapLoader.cs │ │ ├── BitmapLoaderException.cs │ │ ├── CompressedBitmapFormat.cs │ │ ├── IBitmap.cs │ │ └── IBitmapLoader.cs │ ├── Colors │ │ ├── KnownColor.cs │ │ ├── KnownColors.cs │ │ ├── SplatColor.KnownColors.cs │ │ └── SplatColor.cs │ ├── DefaultPlatformModeDetector.cs │ ├── IPlatformModeDetector.cs │ ├── PlatformModeDetector.cs │ ├── Platforms │ │ ├── Android │ │ │ ├── Bitmaps │ │ │ │ ├── AndroidBitmap.cs │ │ │ │ ├── BitmapMixins.cs │ │ │ │ ├── DrawableBitmap.cs │ │ │ │ └── PlatformBitmapLoader.cs │ │ │ ├── Colors │ │ │ │ ├── ColorExtensions.cs │ │ │ │ └── SplatColorExtensions.cs │ │ │ └── Maths │ │ │ │ ├── PointExtensions.cs │ │ │ │ └── RectExtensions.cs │ │ ├── BindingFlags.cs │ │ ├── Cocoa │ │ │ ├── Bitmaps │ │ │ │ ├── BitmapMixins.cs │ │ │ │ ├── CocoaBitmap.cs │ │ │ │ └── PlatformBitmapLoader.cs │ │ │ └── Colors │ │ │ │ └── SplatColorExtensions.cs │ │ ├── ReflectionStubs.cs │ │ ├── ServiceLocationDrawingInitialization.cs │ │ ├── Tizen │ │ │ └── Bitmaps │ │ │ │ ├── BitmapMixins.cs │ │ │ │ ├── PlatformBitmapLoader.cs │ │ │ │ └── TizenBitmap.cs │ │ ├── TypeForwardedSystemDrawing.cs │ │ ├── net4 │ │ │ ├── Bitmaps │ │ │ │ ├── BitmapMixins.cs │ │ │ │ ├── BitmapSourceBitmap.cs │ │ │ │ └── PlatformBitmapLoader.cs │ │ │ ├── Colors │ │ │ │ ├── ColorExtensions.cs │ │ │ │ └── SplatColorExtensions.cs │ │ │ └── Maths │ │ │ │ ├── PointExtensions.cs │ │ │ │ ├── RectExtensions.cs │ │ │ │ └── SizeExtensions.cs │ │ ├── net6 │ │ │ ├── Bitmaps │ │ │ │ ├── BitmapMixins.cs │ │ │ │ ├── BitmapSourceBitmap.cs │ │ │ │ └── PlatformBitmapLoader.cs │ │ │ ├── Colors │ │ │ │ ├── ColorExtensions.cs │ │ │ │ └── SplatColorExtensions.cs │ │ │ └── Maths │ │ │ │ ├── PointExtensions.cs │ │ │ │ ├── RectExtensions.cs │ │ │ │ └── SizeExtensions.cs │ │ └── netcoreapp3 │ │ │ ├── Bitmaps │ │ │ ├── BitmapMixins.cs │ │ │ ├── BitmapSourceBitmap.cs │ │ │ └── PlatformBitmapLoader.cs │ │ │ ├── Colors │ │ │ ├── ColorExtensions.cs │ │ │ └── SplatColorExtensions.cs │ │ │ └── Maths │ │ │ ├── PointExtensions.cs │ │ │ ├── RectExtensions.cs │ │ │ └── SizeExtensions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ └── Resource.designer.cs │ └── Splat.Drawing.csproj ├── Splat.DryIoc.Tests │ ├── DependencyResolverTests.cs │ └── Splat.DryIoc.Tests.csproj ├── Splat.DryIoc │ ├── DryIocDependencyResolver.cs │ ├── README.md │ ├── Splat.DryIoc.csproj │ └── SplatDryIocExtensions.cs ├── Splat.Exceptionless │ ├── ExceptionlessFeatureUsageTrackingSession.cs │ ├── ExceptionlessSplatLogger.cs │ ├── ExceptionlessViewTracking.cs │ ├── MutableDependencyResolverExtensions.cs │ └── Splat.Exceptionless.csproj ├── Splat.Log4Net │ ├── Log4NetLogger.cs │ ├── LogResolver.cs │ ├── MutableDependencyResolverExtensions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Splat.Log4Net.csproj ├── Splat.Microsoft.Extensions.DependencyInjection.Tests │ ├── ContainerWrapper.cs │ ├── DependencyResolverTests.cs │ ├── MicrosoftDependencyResolverTests.cs │ └── Splat.Microsoft.Extensions.DependencyInjection.Tests.csproj ├── Splat.Microsoft.Extensions.DependencyInjection │ ├── MicrosoftDependencyResolver.cs │ ├── README.md │ ├── Splat.Microsoft.Extensions.DependencyInjection.csproj │ └── SplatMicrosoftExtensions.cs ├── Splat.Microsoft.Extensions.Logging │ ├── MicrosoftExtensionsLogProvider.cs │ ├── MicrosoftExtensionsLoggingExtensions.cs │ ├── MicrosoftExtensionsLoggingLogger.cs │ ├── MsLoggingHelpers.cs │ └── Splat.Microsoft.Extensions.Logging.csproj ├── Splat.NLog │ ├── LogResolver.cs │ ├── MutableDependencyResolverExtensions.cs │ ├── NLogLogger.cs │ └── Splat.NLog.csproj ├── Splat.Ninject.Tests │ ├── DependencyResolverTests.cs │ ├── NInjectDependencyResolverTests.cs │ └── Splat.Ninject.Tests.csproj ├── Splat.Ninject │ ├── NinjectDependencyResolver.cs │ ├── README.md │ ├── Splat.Ninject.csproj │ └── SplatNinjectExtensions.cs ├── Splat.Prism.Forms │ ├── PrismApplication.cs │ └── Splat.Prism.Forms.csproj ├── Splat.Prism.Tests │ ├── DependencyResolverTests.cs │ └── Splat.Prism.Tests.csproj ├── Splat.Prism │ ├── Splat.Prism.csproj │ └── SplatContainerExtension.cs ├── Splat.Raygun │ ├── RaygunFeatureUsageTrackingSession.cs │ └── Splat.Raygun.csproj ├── Splat.Serilog │ ├── MutableDependencyResolverExtensions.cs │ ├── Registration.cs │ ├── SerilogFullLogger.cs │ ├── SerilogHelper.cs │ └── Splat.Serilog.csproj ├── Splat.SimpleInjector.Tests │ ├── DependencyResolverTests.cs │ ├── Splat.SimpleInjector.Tests.csproj │ └── xunit.runner.json ├── Splat.SimpleInjector │ ├── README.md │ ├── SimpleInjectorDependencyResolver.cs │ ├── SimpleInjectorInitializer.cs │ ├── Splat.SimpleInjector.csproj │ ├── SplatSimpleInjectorExtensions.cs │ └── TransientSimpleInjectorRegistration.cs ├── Splat.TestRunner.Android │ ├── Assets │ │ └── AboutAssets.txt │ ├── MainActivity.cs │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── AboutResources.txt │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ └── content_main.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ └── values │ │ │ ├── Strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── ic_launcher_background.xml │ │ │ └── styles.xml │ └── Splat.TestRunner.Android.csproj ├── Splat.TestRunner.Uwp │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── Package.appxmanifest │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ ├── Splat.TestRunner.Uwp.GeneratedMSBuildEditorConfig.editorconfig │ ├── Splat.TestRunner.Uwp.csproj │ ├── UnitTestApp.xaml │ └── UnitTestApp.xaml.cs ├── Splat.Tests │ ├── API │ │ ├── ApiApprovalTests.SplatProject.DotNet6_0.verified.txt │ │ ├── ApiApprovalTests.SplatProject.DotNet7_0.verified.txt │ │ ├── ApiApprovalTests.SplatProject.DotNet8_0.verified.txt │ │ ├── ApiApprovalTests.SplatProject.DotNet9_0.verified.txt │ │ └── ApiApprovalTests.cs │ ├── ApiExtensions.cs │ ├── ApplicationPerformanceMonitoring │ │ ├── AppCenterFeatureUsageTrackingSessionTests.cs │ │ ├── AppCenterViewTrackingTests.cs │ │ ├── ApplicationInsightsFeatureUsageTrackingSessionTests.cs │ │ ├── ApplicationInsightsViewTrackingTests.cs │ │ ├── BaseFeatureUsageTrackingTests.cs │ │ ├── BaseViewTrackingTests.cs │ │ ├── EnableFeatureUsageTrackingExtensionsTests.cs │ │ ├── ExceptionlessFeatureUsageTrackingSessionTests.cs │ │ └── RaygunFeatureUsageTrackingSessionTests.cs │ ├── LocatorSerialRegisterTests.cs │ ├── LocatorTests.cs │ ├── Logging │ │ ├── ActionLoggerTests.cs │ │ ├── BaseTests │ │ │ ├── AllocateFreeErrorLoggerTestBase.cs │ │ │ ├── AllocationFreeLoggerBaseTestBase.cs │ │ │ ├── FullLoggerTestBase.cs │ │ │ ├── LoggerBase.cs │ │ │ └── WrappingFullLoggerTestBase.cs │ │ ├── FullLoggers │ │ │ ├── NLogLoggerTests.cs │ │ │ └── SerilogLoggerTests.cs │ │ ├── Helpers │ │ │ └── FormatHelper.cs │ │ ├── StaticLoggerTests.cs │ │ ├── WrappingFullLoggers │ │ │ ├── ConsoleLoggerTests.cs │ │ │ ├── ExceptionlessLoggerTests.cs │ │ │ ├── Log4NetLoggerTests.cs │ │ │ └── MicrosoftExtensionsLoggingLoggerTests.cs │ │ └── WrappingPrefixLoggerTests.cs │ ├── MemoizingMRUCacheTests.cs │ ├── Mocks │ │ ├── IMockLogTarget.cs │ │ └── TextLogger.cs │ ├── ModeDetection │ │ └── ModeTests.cs │ ├── ServiceLocation │ │ ├── BaseDependencyResolverTests.cs │ │ └── ModernDependencyResolverTests.cs │ ├── Splat.Tests.csproj │ ├── TargetFrameworkExtensionsTests.cs │ ├── XUnitHelpers.cs │ ├── splatlogo.bmp │ ├── splatlogo.jpg │ ├── splatlogo.png │ └── xunit.runner.json ├── Splat.sln ├── Splat │ ├── ApplicationPerformanceMonitoring │ │ ├── DefaultFeatureUsageTrackingManager.cs │ │ ├── DefaultFeatureUsageTrackingSession.cs │ │ ├── EnableFeatureUsageTrackingExtensions.cs │ │ ├── FuncFeatureUsageTrackingManager.cs │ │ ├── IEnableFeatureUsageTracking.cs │ │ ├── IFeatureUsageTrackingManager.cs │ │ ├── IFeatureUsageTrackingSession.cs │ │ ├── IFeatureUsageTrackingSession{TReferenceType}.cs │ │ └── IViewTracking.cs │ ├── AssemblyFinder.cs │ ├── Disposables │ │ ├── ActionDisposable.cs │ │ ├── BooleanDisposable.cs │ │ └── CompositeDisposable.cs │ ├── ExceptionMixins.cs │ ├── Logging │ │ ├── ActionLogger.cs │ │ ├── AllocationFreeLoggerBase.cs │ │ ├── ConsoleLogger.cs │ │ ├── DebugLogger.cs │ │ ├── DefaultLogManager.cs │ │ ├── FullLoggerExtensions.cs │ │ ├── FuncLogManager.cs │ │ ├── IAllocationFreeErrorLogger.cs │ │ ├── IAllocationFreeLogger.cs │ │ ├── IEnableLogger.cs │ │ ├── IFullLogger.cs │ │ ├── ILogManager.cs │ │ ├── ILogger.cs │ │ ├── IStaticFullLogger.cs │ │ ├── LogHost.cs │ │ ├── LogLevel.cs │ │ ├── LogManagerMixin.cs │ │ ├── LoggingException.cs │ │ ├── NullLogger.cs │ │ ├── StaticFullLogger.cs │ │ ├── WrappingFullLogger.cs │ │ ├── WrappingLogLevelLogger.cs │ │ └── WrappingPrefixLogger.cs │ ├── Maths │ │ ├── PointMathExtensions.cs │ │ ├── RectEdge.cs │ │ ├── RectangleMathExtensions.cs │ │ └── SizeMathExtensions.cs │ ├── MemoizingMRUCache.cs │ ├── ModeDetection │ │ ├── DefaultModeDetector.cs │ │ ├── IModeDetector.cs │ │ ├── Mode.cs │ │ └── ModeDetector.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServiceLocation │ │ ├── DependencyResolverMixins.cs │ │ ├── FuncDependencyResolver.cs │ │ ├── IDependencyResolver.cs │ │ ├── IMutableDependencyResolver.cs │ │ ├── IReadonlyDependencyResolver.cs │ │ ├── InternalLocator.cs │ │ ├── Locator.cs │ │ ├── ModernDependencyResolver.cs │ │ ├── NullServiceType.cs │ │ ├── ResolverMixins.cs │ │ └── ServiceLocationInitialization.cs │ ├── Splat.csproj │ └── TargetFrameworkExtensions.cs └── stylecop.json └── version.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Catch all for anything we forgot. Add rules if you get CRLF to LF warnings. 2 | * text=auto 3 | 4 | # Text files that should be normalized to LF in odb. 5 | *.cs text diff=csharp 6 | *.xaml text 7 | *.config text 8 | *.c text 9 | *.h text 10 | *.cpp text 11 | *.hpp text 12 | 13 | *.sln text 14 | *.csproj text 15 | *.vcxproj text 16 | 17 | *.md text 18 | *.tt text 19 | *.sh text 20 | *.ps1 text 21 | *.cmd text 22 | *.bat text 23 | *.markdown text 24 | *.msbuild text 25 | 26 | 27 | # Binary files that should not be normalized or diffed 28 | *.png binary 29 | *.jpg binary 30 | *.gif binary 31 | *.ico binary 32 | *.rc binary 33 | 34 | *.pfx binary 35 | *.snk binary 36 | *.dll binary 37 | *.exe binary 38 | *.lib binary 39 | *.exp binary 40 | *.pdb binary 41 | *.sdf binary 42 | *.7z binary 43 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # A CODEOWNERS file uses a pattern that follows the same rules used in gitignore files. 2 | # The pattern is followed by one or more GitHub usernames or team names using the 3 | # standard @username or @org/team-name format. You can also refer to a user by an 4 | # email address that has been added to their GitHub account, for example user@example.com 5 | 6 | .github/* @reactiveui/maintainers 7 | 8 | * @reactiveui/splat-team 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG] Summary of item" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please note although we can't commit to any timeline, priority will be given to those who are [Contributors](https://github.com/reactiveui/splat#contribute ) to the project. 11 | 12 | If this is a question please ask on [StackOverflow](https://stackoverflow.com/questions/tagged/splat). 13 | 14 | **Describe the bug** 15 | A clear and concise description of what the bug is. 16 | 17 | **Steps To Reproduce** 18 | Provide the steps to reproduce the behavior: 19 | 1. Go to '...' 20 | 2. Click on '....' 21 | 3. Scroll down to '....' 22 | 4. See error 23 | 24 | **Expected behavior** 25 | A clear and concise description of what you expected to happen. 26 | 27 | **Screenshots** 28 | If applicable, add screenshots to help explain your problem. 29 | 30 | **Environment(please complete the following information):** 31 | - OS: [e.g. iOS] 32 | - Version [e.g. 22] 33 | - Device: [e.g. iPhone6] 34 | 35 | **Additional context** 36 | Add any other context about the problem here. 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: Feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please note although we can't commit to any timeline, priority will be given to those who are [Contributors](https://github.com/reactiveui/splat#contribute ) to the project. 11 | 12 | If this is a question please ask on [StackOverflow](https://stackoverflow.com/questions/tagged/splat). 13 | 14 | **Is your feature request related to a problem? Please describe.** 15 | A clear and concise description of what the problem is. 16 | 17 | **Describe the solution you'd like** 18 | A clear and concise description of what you want to happen. 19 | 20 | **Describe alternatives you've considered** 21 | A clear and concise description of any alternative solutions or features you've considered. 22 | 23 | **Describe suggestions on how to achieve the feature** 24 | A clear description to how to achieve the feature. 25 | 26 | **Additional context** 27 | Add any other context or screenshots about the feature request here. 28 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["local>reactiveui/.github:renovate"] 4 | } 5 | -------------------------------------------------------------------------------- /.github/workflows/ci-build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | productNamespacePrefix: "Splat" 11 | 12 | jobs: 13 | build: 14 | uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main 15 | with: 16 | configuration: Release 17 | productNamespacePrefix: "Splat" 18 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: 'Lock Threads' 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | 12 | concurrency: 13 | group: lock 14 | 15 | jobs: 16 | action: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: dessant/lock-threads@v5 20 | with: 21 | github-token: ${{ github.token }} 22 | issue-inactive-days: '14' 23 | pr-inactive-days: '14' 24 | issue-comment: > 25 | This issue has been automatically locked since there 26 | has not been any recent activity after it was closed. 27 | Please open a new issue for related bugs. 28 | pr-comment: > 29 | This pull request has been automatically locked since there 30 | has not been any recent activity after it was closed. 31 | Please open a new issue for related bugs. 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | jobs: 8 | release: 9 | uses: reactiveui/actions-common/.github/workflows/workflow-common-release.yml@main 10 | with: 11 | productNamespacePrefix: "Splat" 12 | secrets: 13 | SIGN_ACCOUNT_NAME: ${{ secrets.SIGN_ACCOUNT_NAME }} 14 | SIGN_PROFILE_NAME: ${{ secrets.SIGN_PROFILE_NAME }} 15 | AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} 16 | AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} 17 | AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} 18 | NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} 19 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | If you’re being harassed, noticed someone else being harassed, or have any other concerns, please contact us immediately. Your reports will be taken seriously and will not be dismissed or argued with. All members, committers and volunteers in this community are required to act according to the [Code of Conduct](https://reactiveui.net/code-of-conduct/). 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) ReactiveUI 2018 - 2025 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactiveui/splat/f449faa86406086ebd3e588f723c8f03f31fff75/images/logo.png -------------------------------------------------------------------------------- /src/Benchmarks/Directory.Packages.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | true 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /src/Benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System; 7 | using BenchmarkDotNet.Running; 8 | 9 | namespace Splat.Benchmarks 10 | { 11 | /// 12 | /// Class which hosts the main entry point into the application. 13 | /// 14 | public static class Program 15 | { 16 | /// 17 | /// The main entry point into the benchmarking application. 18 | /// 19 | /// Arguments from the command line. 20 | public static void Main(string[] args) 21 | { 22 | var results = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 23 | foreach (var result in results) 24 | { 25 | Console.WriteLine(result); 26 | } 27 | 28 | Console.ReadLine(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Benchmarks/Splat.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | net6.0 5 | AnyCPU 6 | pdbonly 7 | true 8 | Exe 9 | ;1591;1701;1702;1705;CA1822 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Benchmarks/ViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Benchmarks 7 | { 8 | /// 9 | /// A plain object for registration. 10 | /// 11 | public class ViewModel 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Directory.build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(AssemblyName) ($(TargetFramework)) 4 | false 5 | 6 | 7 | 8 | $(DefineConstants);NET_45;XAML 9 | 10 | 11 | $(DefineConstants);TIZEN 12 | 13 | 14 | $(DefineConstants);MONO;UIKIT;COCOA;IOS 15 | 16 | 17 | $(DefineConstants);MONO;COCOA 18 | 19 | 20 | $(DefineConstants);MONO;UIKIT;COCOA;TVOS 21 | 22 | 23 | $(DefineConstants);MONO;UIKIT;COCOA;MACCATALYST 24 | 25 | 26 | $(DefineConstants);MONO;ANDROID 27 | 28 | 29 | $(DefineConstants);IS_SHARED_NET 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/ReactiveUI.DI.Tests/DryIocReactiveUIDependencyTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using DryIoc; 7 | 8 | using FluentAssertions; 9 | 10 | using Splat.DryIoc; 11 | 12 | namespace ReactiveUI.DI.Tests; 13 | 14 | /// 15 | /// DryIoc ReactiveUI Dependency Tests. 16 | /// 17 | public class DryIocReactiveUIDependencyTests 18 | { 19 | /// 20 | /// DyyIoC dependency resolver should register reactive UI creates command binding. 21 | /// 22 | [Fact] 23 | public void DryIocDependencyResolverShouldRegisterReactiveUI() 24 | { 25 | // Invoke RxApp which initializes the ReactiveUI platform. 26 | var container = new Container(); 27 | 28 | var locator = new DryIocDependencyResolver(container); 29 | locator.RegisterViewsForViewModels(typeof(ViewWithViewContractThatShouldNotLoad).Assembly); 30 | locator.InitializeReactiveUI(); 31 | 32 | var converters = container.Resolve>().ToList(); 33 | 34 | converters.Should().NotBeNull(); 35 | converters.Should().Contain(x => x.GetType() == typeof(CreatesCommandBindingViaEvent)); 36 | converters.Should().Contain(x => x.GetType() == typeof(CreatesCommandBindingViaCommandParameter)); 37 | 38 | var convertersb = container.Resolve>().ToList(); 39 | 40 | convertersb.Should().NotBeNull(); 41 | convertersb.Should().Contain(x => x.GetType() == typeof(StringConverter)); 42 | convertersb.Should().Contain(x => x.GetType() == typeof(EqualityTypeConverter)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/ReactiveUI.DI.Tests/Mocks/ActivatingViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Reactive.Disposables; 7 | 8 | namespace ReactiveUI.DI.Tests.Mocks; 9 | 10 | /// 11 | /// ActivatingViewModel. 12 | /// 13 | /// 14 | public class ActivatingViewModel : ReactiveObject, IActivatableViewModel 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public ActivatingViewModel() 20 | { 21 | Activator = new(); 22 | 23 | this.WhenActivated(d => 24 | { 25 | IsActiveCount++; 26 | d(Disposable.Create(() => IsActiveCount--)); 27 | }); 28 | } 29 | 30 | /// 31 | /// Gets the Activator which will be used by the View when Activation/Deactivation occurs. 32 | /// 33 | public ViewModelActivator Activator { get; } 34 | 35 | /// 36 | /// Gets or sets the active count. 37 | /// 38 | public int IsActiveCount { get; protected set; } 39 | } 40 | -------------------------------------------------------------------------------- /src/ReactiveUI.DI.Tests/ReactiveUI.DI.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net472;net8.0;net9.0 4 | $(NoWarn);1591;CA1707;SA1633;CA2000;CA1515 5 | false 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/ReactiveUI.DI.Tests/ViewWithViewContractThatShouldNotLoad.cs: -------------------------------------------------------------------------------- 1 | using Splat.Common.Test; 2 | 3 | namespace ReactiveUI.DI.Tests; 4 | 5 | /// 6 | /// This is a test view relating to issue #889. 7 | /// It's intended to ensure that view registration by different DI\IoC implementations 8 | /// does not create an instance at the point of registration. 9 | /// 10 | [ViewContract("somecontract")] 11 | public sealed class ViewWithViewContractThatShouldNotLoad : IViewFor 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public ViewWithViewContractThatShouldNotLoad() => throw new InvalidOperationException("This view should not be created."); 17 | 18 | /// 19 | object? IViewFor.ViewModel 20 | { 21 | get => ViewModel; 22 | set => ViewModel = (ViewModelOne?)value; 23 | } 24 | 25 | /// 26 | public ViewModelOne? ViewModel { get; set; } 27 | } 28 | -------------------------------------------------------------------------------- /src/Splat.AppCenter/AppCenterViewTracking.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Splat.ApplicationPerformanceMonitoring; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// View Tracking integration for AppCenter. 12 | /// 13 | public sealed class AppCenterViewTracking : IViewTracking 14 | { 15 | /// 16 | /// Track a view navigation using just a name. 17 | /// 18 | /// Name of the view. 19 | public void OnViewNavigation(string name) => 20 | Microsoft.AppCenter.Analytics.Analytics.TrackEvent("PageView", GetProperties(name)); 21 | 22 | private static Dictionary GetProperties(string name) => 23 | new() { { "Name", name }, }; 24 | } 25 | -------------------------------------------------------------------------------- /src/Splat.AppCenter/Splat.AppCenter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0;$(SplatWindowsTargetFrameworks) 4 | 5 | Splat.AppCenter 6 | Splat 7 | .NET Foundation and Contributors 8 | Visual Studio AppCenter integrations for Splat 9 | Splat.AppCenter 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Microsoft.ApplicationInsights; 7 | using Microsoft.ApplicationInsights.DataContracts; 8 | using Splat.ApplicationPerformanceMonitoring; 9 | 10 | namespace Splat; 11 | 12 | /// 13 | /// View Tracking integration for Application Insights. 14 | /// 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The Application Insights telemetry client instance to use. 19 | public sealed class ApplicationInsightsViewTracking(TelemetryClient telemetryClient) : IViewTracking 20 | { 21 | private readonly TelemetryClient _telemetryClient = telemetryClient; 22 | 23 | /// 24 | /// Track a view navigation using just a name. 25 | /// 26 | /// Name of the view. 27 | public void OnViewNavigation(string name) => _telemetryClient.TrackPageView(name); 28 | 29 | /// 30 | /// Track a View Navigation with Extended Data. 31 | /// 32 | /// Telemetry data. 33 | public void OnViewNavigation(PageViewTelemetry telemetry) 34 | { 35 | _ = GetPageViewTelemetry(); 36 | _telemetryClient.TrackPageView(telemetry); 37 | } 38 | 39 | internal static PageViewTelemetry GetPageViewTelemetry() => new(); 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.ApplicationInsights/Splat.ApplicationInsights.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.ApplicationInsights 6 | Splat 7 | .NET Foundation and Contributors 8 | ApplicationInsights integrations for Splat 9 | Splat.ApplicationInsights 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0 5 | 6 | false 7 | $(NoWarn);1591;CA1707;SA1633;CA2000;CA1851 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Always 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Splat.Autofac.Tests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "shadowCopy": false 3 | } 4 | -------------------------------------------------------------------------------- /src/Splat.Autofac/Splat.Autofac.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Autofac adapter for Splat 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Splat.Autofac/SplatAutofacExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Autofac; 7 | 8 | namespace Splat.Autofac; 9 | 10 | /// 11 | /// Extension methods for the Autofac adapter. 12 | /// 13 | public static class SplatAutofacExtensions 14 | { 15 | /// 16 | /// Initializes an instance of that overrides the default . 17 | /// 18 | /// Autofac container builder. 19 | /// The Autofac dependency resolver. 20 | public static AutofacDependencyResolver UseAutofacDependencyResolver(this ContainerBuilder builder) 21 | { 22 | var autofacResolver = new AutofacDependencyResolver(builder); 23 | Locator.SetLocator(autofacResolver); 24 | return autofacResolver; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Autofac/Splat.Avalonia.Autofac.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.DryIoc/Splat.Avalonia.DryIoc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.DryIoc1.Tests/AvaloniaUIThreadTestsDryIoc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Avalonia; 6 | using Avalonia.ReactiveUI; 7 | using Avalonia.ReactiveUI.Splat; 8 | using DryIoc; 9 | using ReactiveUIDemo; 10 | using Splat; 11 | using Splat.DryIoc; 12 | 13 | namespace ReactiveUI.Avalonia.DryIoc1.Tests 14 | { 15 | public class AvaloniaUIThreadTestsDryIoc 16 | { 17 | #if DRYIOC1 18 | [Fact] 19 | public void Test1() 20 | { 21 | DryIocDependencyResolver? container = default; 22 | DryIocDependencyResolver? resolver = default; 23 | AppBuilder.Configure() 24 | .UsePlatformDetect() 25 | .UseReactiveUIWithDIContainer(() => new(), con => container = con, res => resolver = res) 26 | .LogToTrace() 27 | .SetupWithoutStarting(); 28 | Assert.IsType(RxApp.MainThreadScheduler); 29 | Assert.NotNull(container); 30 | Assert.NotNull(resolver); 31 | Assert.IsType(Locator.Current); 32 | } 33 | #endif 34 | #if DRYIOC2 35 | [Fact] 36 | public void Test2() 37 | { 38 | Container? container = default; 39 | AppBuilder.Configure() 40 | .UsePlatformDetect() 41 | .UseReactiveUIWithDryIoc(con => container = con) 42 | .LogToTrace() 43 | .SetupWithoutStarting(); 44 | Assert.IsType(RxApp.MainThreadScheduler); 45 | Assert.NotNull(container); 46 | Assert.IsType(Locator.Current); 47 | } 48 | #endif 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Microsoft.Extensions.DependencyInjection/Splat.Avalonia.Microsoft.Extensions.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Ninject/Splat.Avalonia.Ninject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/AvaloniaUIThreadTestsMain.cs: -------------------------------------------------------------------------------- 1 | namespace ReactiveUI.Avalonia.Tests 2 | { 3 | public class AvaloniaUIThreadTestsMain 4 | { 5 | ////[Fact] 6 | ////public void Test1() 7 | ////{ 8 | ////AppBuilder.Configure() 9 | //// .UsePlatformDetect() 10 | //// .UseReactiveUI() 11 | //// .LogToTrace() 12 | //// .SetupWithoutStarting(); 13 | ////Assert.IsType(RxApp.MainThreadScheduler); 14 | ////} 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/App.axaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/App.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls.ApplicationLifetimes; 3 | using Avalonia.Markup.Xaml; 4 | using ReactiveUI; 5 | using ReactiveUIDemo.ViewModels; 6 | using ReactiveUIDemo.Views; 7 | using Splat; 8 | 9 | namespace ReactiveUIDemo 10 | { 11 | public class App : Application 12 | { 13 | public override void Initialize() 14 | { 15 | AvaloniaXamlLoader.Load(this); 16 | Locator.CurrentMutable.Register(() => new FooView(), typeof(IViewFor)); 17 | Locator.CurrentMutable.Register(() => new BarView(), typeof(IViewFor)); 18 | } 19 | 20 | public override void OnFrameworkInitializationCompleted() 21 | { 22 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) 23 | { 24 | desktop.MainWindow = new MainWindow(); 25 | } 26 | 27 | base.OnFrameworkInitializationCompleted(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/MainWindow.axaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/MainWindow.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Markup.Xaml; 3 | using ReactiveUIDemo.ViewModels; 4 | 5 | namespace ReactiveUIDemo 6 | { 7 | public partial class MainWindow : Window 8 | { 9 | public MainWindow() 10 | { 11 | InitializeComponent(); 12 | DataContext = new MainWindowViewModel(); 13 | } 14 | 15 | private void InitializeComponent() => AvaloniaXamlLoader.Load(this); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/ViewModels/BarViewModel.cs: -------------------------------------------------------------------------------- 1 | using ReactiveUI; 2 | 3 | namespace ReactiveUIDemo.ViewModels 4 | { 5 | internal sealed class BarViewModel(IScreen screen) : ReactiveObject, IRoutableViewModel 6 | { 7 | public string UrlPathSegment => "Bar"; 8 | 9 | public IScreen HostScreen { get; } = screen; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/ViewModels/FooViewModel.cs: -------------------------------------------------------------------------------- 1 | using ReactiveUI; 2 | 3 | namespace ReactiveUIDemo.ViewModels 4 | { 5 | internal sealed class FooViewModel(IScreen screen) : ReactiveObject, IRoutableViewModel 6 | { 7 | public string UrlPathSegment => "Foo"; 8 | 9 | public IScreen HostScreen { get; } = screen; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using ReactiveUI; 2 | 3 | namespace ReactiveUIDemo.ViewModels 4 | { 5 | internal sealed class MainWindowViewModel : ReactiveObject 6 | { 7 | public RoutedViewHostPageViewModel RoutedViewHost { get; } = new(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/ViewModels/RoutedViewHostPageViewModel.cs: -------------------------------------------------------------------------------- 1 | using ReactiveUI; 2 | 3 | namespace ReactiveUIDemo.ViewModels 4 | { 5 | internal sealed class RoutedViewHostPageViewModel : ReactiveObject, IScreen 6 | { 7 | public RoutedViewHostPageViewModel() 8 | { 9 | Foo = new(this); 10 | Bar = new(this); 11 | Router.Navigate.Execute(Foo); 12 | } 13 | 14 | public RoutingState Router { get; } = new(); 15 | 16 | public FooViewModel Foo { get; } 17 | 18 | public BarViewModel Bar { get; } 19 | 20 | public void ShowFoo() => Router.Navigate.Execute(Foo); 21 | 22 | public void ShowBar() => Router.Navigate.Execute(Bar); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/Views/BarView.axaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 13 | Bar! 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/Views/BarView.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Markup.Xaml; 3 | using ReactiveUI; 4 | using ReactiveUIDemo.ViewModels; 5 | 6 | namespace ReactiveUIDemo.Views 7 | { 8 | internal sealed partial class BarView : UserControl, IViewFor 9 | { 10 | public BarView() => InitializeComponent(); 11 | 12 | public BarViewModel? ViewModel { get; set; } 13 | 14 | object? IViewFor.ViewModel 15 | { 16 | get => ViewModel; 17 | set => ViewModel = (BarViewModel?)value; 18 | } 19 | 20 | private void InitializeComponent() => AvaloniaXamlLoader.Load(this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/Views/FooView.axaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 13 | Foo! 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Mocks/Views/FooView.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Controls; 2 | using Avalonia.Markup.Xaml; 3 | using ReactiveUI; 4 | using ReactiveUIDemo.ViewModels; 5 | 6 | namespace ReactiveUIDemo.Views 7 | { 8 | internal sealed partial class FooView : UserControl, IViewFor 9 | { 10 | public FooView() => InitializeComponent(); 11 | 12 | public FooViewModel? ViewModel { get; set; } 13 | 14 | object? IViewFor.ViewModel 15 | { 16 | get => ViewModel; 17 | set => ViewModel = (FooViewModel?)value; 18 | } 19 | 20 | private void InitializeComponent() => AvaloniaXamlLoader.Load(this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.Avalonia.Tests/Splat.Avalonia.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0;net9.0 4 | enable 5 | enable 6 | $(NoWarn);1591;CA1707;SA1600;SA1601;SA1633;CA2000;CA1515 7 | false 8 | true 9 | $(DefineConstants);MAIN 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/DummyObjectClass1.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Tests.Mocks; 9 | 10 | /// 11 | /// A dummy class used during Locator testing. 12 | /// 13 | [ExcludeFromCodeCoverage] 14 | public class DummyObjectClass1 : IDummyInterface 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/DummyObjectClass2.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Tests.Mocks; 9 | 10 | /// 11 | /// A dummy class used during Locator testing. 12 | /// 13 | [ExcludeFromCodeCoverage] 14 | public class DummyObjectClass2 : IDummyInterface 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/DummyObjectClass3.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Tests.Mocks; 9 | 10 | /// 11 | /// A dummy class used during Locator testing. 12 | /// 13 | [ExcludeFromCodeCoverage] 14 | public class DummyObjectClass3 : IDummyInterface 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/IDummyInterface.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Tests.Mocks; 7 | 8 | /// 9 | /// A dummy interface used during Locator testing. 10 | /// 11 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "By Design")] 12 | public interface IDummyInterface 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/IScreen.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Common.Test; 7 | 8 | /// 9 | /// Represents a screen. 10 | /// 11 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "By Design")] 12 | public interface IScreen 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/IViewFor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Common.Test; 7 | 8 | #pragma warning disable SA1402 // File may only contain a single type 9 | 10 | /// 11 | /// Represents a view bound to a view model. 12 | /// 13 | /// The view model type. 14 | /// 15 | public interface IViewFor : IViewFor 16 | where T : class 17 | { 18 | /// 19 | /// Gets or sets the view model. 20 | /// 21 | new T? ViewModel { get; set; } 22 | } 23 | 24 | /// 25 | /// Represents a view bound to a view model. 26 | /// 27 | /// 28 | public interface IViewFor 29 | { 30 | /// 31 | /// Gets or sets the view model. 32 | /// 33 | object? ViewModel { get; set; } 34 | } 35 | 36 | #pragma warning restore SA1402 // File may only contain a single type 37 | 38 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/IViewModelOne.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Common.Test; 7 | 8 | /// 9 | /// Interface for ViewModelOne. 10 | /// 11 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1040:Avoid empty interfaces", Justification = "By Design")] 12 | public interface IViewModelOne 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/MockScreen.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Common.Test; 9 | 10 | /// 11 | /// An implementation. 12 | /// 13 | /// 14 | [ExcludeFromCodeCoverage] 15 | public class MockScreen : IScreen 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/Splat.Common.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0;net8.0;net9.0 5 | $(NoWarn);CA2000 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/ViewModelOne.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Common.Test; 9 | 10 | /// 11 | /// View Model One. 12 | /// 13 | [ExcludeFromCodeCoverage] 14 | public class ViewModelOne : IViewModelOne 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public ViewModelOne() 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/ViewModelTwo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Common.Test; 9 | 10 | /// 11 | /// View Model Two. 12 | /// 13 | [ExcludeFromCodeCoverage] 14 | public class ViewModelTwo 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/ViewOne.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Common.Test; 9 | 10 | /// 11 | /// View One. 12 | /// 13 | /// 14 | [ExcludeFromCodeCoverage] 15 | public class ViewOne : IViewFor 16 | { 17 | /// 18 | object? IViewFor.ViewModel 19 | { 20 | get => ViewModel; 21 | set => ViewModel = (ViewModelOne?)value; 22 | } 23 | 24 | /// 25 | public ViewModelOne? ViewModel { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/ViewThatShouldNotLoad.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Common.Test; 7 | 8 | /// 9 | /// This is a test view relating to issue #889. 10 | /// It's intended to ensure that view registration by different DI\IoC implementations 11 | /// does not create an instance at the point of registration. 12 | /// 13 | public sealed class ViewThatShouldNotLoad : IViewFor 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public ViewThatShouldNotLoad() => throw new InvalidOperationException("This view should not be created."); 19 | 20 | /// 21 | object? IViewFor.ViewModel 22 | { 23 | get => ViewModel; 24 | set => ViewModel = (ViewModelOne?)value; 25 | } 26 | 27 | /// 28 | public ViewModelOne? ViewModel { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Splat.Common.Test/ViewTwo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat.Common.Test; 9 | 10 | /// 11 | /// View Two. 12 | /// 13 | /// 14 | [ExcludeFromCodeCoverage] 15 | public class ViewTwo : IViewFor 16 | { 17 | /// 18 | object? IViewFor.ViewModel 19 | { 20 | get => ViewModel; 21 | set => ViewModel = (ViewModelTwo?)value; 22 | } 23 | 24 | /// 25 | public ViewModelTwo? ViewModel { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Splat.Drawing.Tests/API/ApiApprovalTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | #pragma warning disable SA1615 // Element return value should be documented 9 | 10 | namespace Splat.Tests; 11 | 12 | /// 13 | /// Tests to make sure that the API matches the approved ones. 14 | /// 15 | [ExcludeFromCodeCoverage] 16 | public class ApiApprovalTests 17 | { 18 | /// 19 | /// Tests to make sure the splat project is approved. 20 | /// 21 | [Fact] 22 | public Task SplatUIProject() => typeof(IPlatformModeDetector).Assembly.CheckApproval(["Splat"]); 23 | } 24 | -------------------------------------------------------------------------------- /src/Splat.Drawing.Tests/Colors/KnownColorTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Tests.Colors; 7 | 8 | /// 9 | /// Unit Tests for Known Color logic. 10 | /// 11 | public class KnownColorTests 12 | { 13 | /// 14 | /// Gets the test data for FromKnownColor. 15 | /// 16 | public static IEnumerable KnownColorEnums { get; } = XUnitHelpers.GetEnumAsTestTheory(); 17 | 18 | /// 19 | /// Tests to ensure a name is returned from a number akin to a KnownColor. 20 | /// 21 | /// Known Color Enum to check. 22 | [Theory] 23 | [MemberData(nameof(KnownColorEnums))] 24 | public void GetNameReturnsName(KnownColor knownColor) 25 | { 26 | #if !NET_2_0 27 | if ((short)knownColor > 167) 28 | { 29 | // can't assess these. 30 | return; 31 | } 32 | #endif 33 | 34 | var name = KnownColors.GetName(knownColor); 35 | Assert.False(string.IsNullOrWhiteSpace(name)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Splat.Drawing.Tests/Splat.Drawing.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0 5 | false 6 | $(NoWarn);1591;CA1707;SA1633;CA2000;CA1034;CA1515 7 | enable 8 | true 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Bitmaps/BitmapLoader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// This class loads and creates bitmap resources in a platform-independent. 12 | /// way. 13 | /// 14 | public static class BitmapLoader 15 | { 16 | // TODO: This needs to be improved once we move the "Detect in Unit Test 17 | // Runner" code into Splat 18 | private static IBitmapLoader? _current = Locator.Current.GetService(); 19 | 20 | /// 21 | /// Gets or sets the current bitmap loader. 22 | /// 23 | /// When there is no exception loader having been found. 24 | [SuppressMessage("Design", "CA1065: Do not raise exceptions in properties", Justification = "Very rare scenario")] 25 | public static IBitmapLoader Current 26 | { 27 | get 28 | { 29 | var ret = _current; 30 | return ret switch 31 | { 32 | null => throw new BitmapLoaderException("Could not find a default bitmap loader. This should never happen, your dependency resolver is broken"), 33 | _ => ret 34 | }; 35 | } 36 | set => _current = value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Bitmaps/BitmapLoaderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat; 7 | 8 | /// 9 | /// A exception that occurs when there is a problem using or retrieving the . 10 | /// 11 | [Serializable] 12 | public class BitmapLoaderException : Exception 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public BitmapLoaderException() 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The message about the exception. 25 | public BitmapLoaderException(string message) 26 | : base(message) 27 | { 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The message about the exception. 34 | /// Any other internal exceptions we are mapping. 35 | public BitmapLoaderException(string message, Exception innerException) 36 | : base(message, innerException) 37 | { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Bitmaps/CompressedBitmapFormat.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat; 7 | 8 | /// 9 | /// Specifies that compressed bitmap format. 10 | /// 11 | public enum CompressedBitmapFormat 12 | { 13 | /// 14 | /// Store the bitmap as a PNG format. 15 | /// 16 | Png, 17 | 18 | /// 19 | /// Store the bitmap as a JPEG format. 20 | /// 21 | Jpeg, 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Bitmaps/IBitmap.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.IO; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Represents a bitmap image that was loaded via a ViewModel. Every platform 12 | /// provides FromNative and ToNative methods to convert this object to the 13 | /// platform-specific versions. 14 | /// 15 | public interface IBitmap : IDisposable 16 | { 17 | /// 18 | /// Gets the width in pixel units (depending on platform). 19 | /// 20 | float Width { get; } 21 | 22 | /// 23 | /// Gets the height in pixel units (depending on platform). 24 | /// 25 | float Height { get; } 26 | 27 | /// 28 | /// Saves an image to a target stream. 29 | /// 30 | /// The format to save the image in. 31 | /// If JPEG is specified, this is a quality 32 | /// factor between 0.0 and 1.0f where 1.0f is the best quality. 33 | /// The target stream to save to. 34 | /// A signal indicating the Save has completed. 35 | Task Save(CompressedBitmapFormat format, float quality, Stream target); 36 | } 37 | -------------------------------------------------------------------------------- /src/Splat.Drawing/IPlatformModeDetector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat; 7 | 8 | /// 9 | /// Detects properties about the current platform. 10 | /// 11 | public interface IPlatformModeDetector 12 | { 13 | /// 14 | /// Gets a value indicating whether the current library or application is running in a GUI design mode tool. 15 | /// 16 | /// If we are currently running in design mode. 17 | bool? InDesignMode(); 18 | } 19 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/Android/Bitmaps/DrawableBitmap.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Android.Graphics.Drawables; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The drawable bitmap to wrap. 14 | internal sealed class DrawableBitmap(Drawable inner) : IBitmap 15 | { 16 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Is Disposed using Interlocked method")] 17 | private Drawable? _inner = inner; 18 | 19 | /// 20 | public float Width => Inner.IntrinsicWidth; 21 | 22 | /// 23 | public float Height => Inner.IntrinsicHeight; 24 | 25 | /// 26 | /// Gets the internal Drawable we are wrapping. 27 | /// 28 | internal Drawable Inner => _inner ?? throw new InvalidOperationException("Attempting to retrieve a disposed bitmap"); 29 | 30 | public Task Save(CompressedBitmapFormat format, float quality, Stream target) => throw new NotSupportedException("You can't save resources"); 31 | 32 | public void Dispose() 33 | { 34 | var disp = Interlocked.Exchange(ref _inner, null); 35 | disp?.Dispose(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/Android/Colors/ColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Android.Graphics; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Provides extension methods for interacting with colors, to and from the android colors. 12 | /// 13 | public static class ColorExtensions 14 | { 15 | /// 16 | /// Converts a to a android native color. 17 | /// 18 | /// The System.Drawing.Color to convert. 19 | /// A native android color. 20 | public static Color ToNative(this System.Drawing.Color other) => new(other.R, other.G, other.B, other.A); 21 | 22 | /// 23 | /// Converts from a android native color to a . 24 | /// 25 | /// The android native color to convert. 26 | /// A System.Drawing.Color. 27 | public static System.Drawing.Color FromNative(this Color other) => System.Drawing.Color.FromArgb(other.A, other.R, other.G, other.B); 28 | } 29 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/Android/Colors/SplatColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Android.Graphics; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods associated with the struct. 12 | /// 13 | public static class SplatColorExtensions 14 | { 15 | /// 16 | /// Converts a into the android native . 17 | /// 18 | /// The color to convert. 19 | /// The generated. 20 | public static Color ToNative(this SplatColor value) => new(value.R, value.G, value.B, value.A); 21 | 22 | /// 23 | /// Converts a into the android native . 24 | /// 25 | /// The color to convert. 26 | /// The generated. 27 | public static SplatColor FromNative(this Color value) => SplatColor.FromArgb(value.A, value.R, value.G, value.B); 28 | } 29 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/BindingFlags.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Splat 13 | { 14 | internal enum BindingFlags 15 | { 16 | Public = 1, 17 | NonPublic = 1 << 1, 18 | Instance = 1 << 2, 19 | Static = 1 << 3, 20 | FlattenHierarchy = 1 << 4 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/Cocoa/Bitmaps/BitmapMixins.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | #if UIKIT 7 | using UIKit; 8 | #else 9 | using UIImage = AppKit.NSImage; 10 | #endif 11 | 12 | namespace Splat; 13 | 14 | /// 15 | /// Extension methods to assist with dealing with Bitmaps. 16 | /// 17 | public static class BitmapMixins 18 | { 19 | /// 20 | /// Converts to a native type. 21 | /// 22 | /// The bitmap to convert. 23 | /// A bitmap. 24 | public static UIImage ToNative(this IBitmap value) => value switch 25 | { 26 | null => throw new ArgumentNullException(nameof(value)), 27 | _ => ((CocoaBitmap)value).Inner 28 | }; 29 | 30 | /// 31 | /// Converts a to a splat . 32 | /// 33 | /// The native bitmap to convert from. 34 | /// Whether to copy the android bitmap or not. 35 | /// A bitmap. 36 | public static IBitmap FromNative(this UIImage value, bool copy = false) => value switch 37 | { 38 | null => throw new ArgumentNullException(nameof(value)), 39 | _ => copy ? new CocoaBitmap((UIImage)value.Copy()) : (IBitmap)new CocoaBitmap(value) 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/ServiceLocationDrawingInitialization.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Provides service location for the Splat.Drawing packages. 12 | /// 13 | public static class ServiceLocationDrawingInitialization 14 | { 15 | /// 16 | /// Registers the platform bitmap loader for the current platform. 17 | /// 18 | /// The resolver to register against. 19 | #if NET6_0_OR_GREATER 20 | [RequiresUnreferencedCode("Calls IMutableDependencyResolver.RegisterLazySingleton(Func)")] 21 | [RequiresDynamicCode("Calls IMutableDependencyResolver.RegisterLazySingleton(Func)")] 22 | #endif 23 | public static void RegisterPlatformBitmapLoader(this IMutableDependencyResolver resolver) 24 | { 25 | resolver.ThrowArgumentNullExceptionIfNull(nameof(resolver)); 26 | 27 | #if !IS_SHARED_NET 28 | // not supported in netstandard or NET6 library 29 | if (!resolver.HasRegistration(typeof(IBitmapLoader))) 30 | { 31 | resolver.RegisterLazySingleton(static () => new PlatformBitmapLoader(), typeof(IBitmapLoader)); 32 | } 33 | #endif 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/Tizen/Bitmaps/BitmapMixins.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Tizen.Multimedia.Util; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods to assist with dealing with Bitmaps. 12 | /// 13 | public static class BitmapMixins 14 | { 15 | /// 16 | /// Converts to a . 17 | /// 18 | /// The bitmap to convert. 19 | /// A bitmap. 20 | public static IBitmap FromNative(this BitmapFrame value) => new TizenBitmap(value); 21 | 22 | /// 23 | /// Converts to a . 24 | /// 25 | /// The bitmap to convert. 26 | /// A bitmap. 27 | public static BitmapFrame ToNative(this IBitmap value) => value switch 28 | { 29 | null => throw new ArgumentNullException(nameof(value)), 30 | _ => (value as TizenBitmap)?.Inner ?? throw new InvalidOperationException("Bitmap has been disposed") 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/TypeForwardedSystemDrawing.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Drawing; 7 | using System.Runtime.CompilerServices; 8 | 9 | #if !UIKIT 10 | [assembly: TypeForwardedTo(typeof(Color))] 11 | [assembly: TypeForwardedTo(typeof(KnownColor))] 12 | #endif 13 | 14 | [assembly: TypeForwardedTo(typeof(Point))] 15 | [assembly: TypeForwardedTo(typeof(PointF))] 16 | [assembly: TypeForwardedTo(typeof(Rectangle))] 17 | [assembly: TypeForwardedTo(typeof(RectangleF))] 18 | [assembly: TypeForwardedTo(typeof(Size))] 19 | [assembly: TypeForwardedTo(typeof(SizeF))] 20 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Bitmaps/BitmapMixins.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media.Imaging; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods to assist with dealing with Bitmaps. 12 | /// 13 | public static class BitmapMixins 14 | { 15 | /// 16 | /// Converts to a native type. 17 | /// 18 | /// The bitmap to convert. 19 | /// A bitmap. 20 | public static IBitmap FromNative(this BitmapSource value) => new BitmapSourceBitmap(value); 21 | 22 | /// 23 | /// Converts a to a splat . 24 | /// 25 | /// The native bitmap to convert from. 26 | /// A bitmap. 27 | public static BitmapSource ToNative(this IBitmap value) => value switch 28 | { 29 | null => throw new ArgumentNullException(nameof(value)), 30 | _ => ((BitmapSourceBitmap)value).Inner ?? throw new InvalidOperationException("There is not a valid bitmap") 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Bitmaps/BitmapSourceBitmap.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.IO; 7 | using System.Windows.Media.Imaging; 8 | 9 | namespace Splat; 10 | 11 | /// 12 | /// A bitmap that wraps a . 13 | /// 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The platform native bitmap we are wrapping. 18 | internal sealed class BitmapSourceBitmap(BitmapSource bitmap) : IBitmap 19 | { 20 | /// 21 | public float Width => (float)(Inner?.Width ?? 0f); 22 | 23 | /// 24 | public float Height => (float)(Inner?.Height ?? 0f); 25 | 26 | /// 27 | /// Gets the platform . 28 | /// 29 | public BitmapSource? Inner { get; private set; } = bitmap; 30 | 31 | /// 32 | public Task Save(CompressedBitmapFormat format, float quality, Stream target) => Inner switch 33 | { 34 | null => Task.CompletedTask, 35 | _ => Task.Run(() => 36 | { 37 | var encoder = format == CompressedBitmapFormat.Jpeg ? 38 | new JpegBitmapEncoder() { QualityLevel = (int)(quality * 100.0f) } : 39 | (BitmapEncoder)new PngBitmapEncoder(); 40 | 41 | encoder.Frames.Add(BitmapFrame.Create(Inner)); 42 | encoder.Save(target); 43 | }) 44 | }; 45 | 46 | /// 47 | public void Dispose() => Inner = null; 48 | } 49 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Colors/ColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Provides extension methods for interacting with colors, to and from the XAML colors. 12 | /// 13 | public static class ColorExtensions 14 | { 15 | /// 16 | /// Converts a to a XAML native color. 17 | /// 18 | /// The System.Drawing.Color to convert. 19 | /// A native XAML color. 20 | public static Color ToNative(this System.Drawing.Color value) => Color.FromArgb(value.A, value.R, value.G, value.B); 21 | 22 | /// 23 | /// Converts a into the cocoa native . 24 | /// 25 | /// The color to convert. 26 | /// The generated. 27 | public static SolidColorBrush ToNativeBrush(this System.Drawing.Color value) 28 | { 29 | var ret = new SolidColorBrush(value.ToNative()); 30 | ret.Freeze(); 31 | return ret; 32 | } 33 | 34 | /// 35 | /// Converts a into the XAML . 36 | /// 37 | /// The color to convert. 38 | /// The generated. 39 | public static System.Drawing.Color FromNative(this Color value) => System.Drawing.Color.FromArgb(value.A, value.R, value.G, value.B); 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Colors/SplatColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods associated with the struct. 12 | /// 13 | public static class SplatColorExtensions 14 | { 15 | /// 16 | /// Converts a into the XAML . 17 | /// 18 | /// The color to convert. 19 | /// The generated. 20 | public static Color ToNative(this SplatColor value) => Color.FromArgb(value.A, value.R, value.G, value.B); 21 | 22 | /// 23 | /// Converts a into the XAML . 24 | /// 25 | /// The color to convert. 26 | /// The generated. 27 | public static SolidColorBrush ToNativeBrush(this SplatColor value) 28 | { 29 | var ret = new SolidColorBrush(value.ToNative()); 30 | ret.Freeze(); 31 | return ret; 32 | } 33 | 34 | /// 35 | /// Converts a into the XAML . 36 | /// 37 | /// The color to convert. 38 | /// The generated. 39 | public static SplatColor FromNative(this Color value) => SplatColor.FromArgb(value.A, value.R, value.G, value.B); 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Maths/PointExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing point's and a native point classes. 12 | /// 13 | public static class PointExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Point ToNative(this System.Drawing.Point value) => new(value.X, value.Y); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Point ToNative(this System.Drawing.PointF value) => new(value.X, value.Y); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.PointF FromNative(this Point value) => new((float)value.X, (float)value.Y); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Maths/RectExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing rectangle's and a native rectangle classes. 12 | /// 13 | public static class RectExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Rect ToNative(this System.Drawing.Rectangle value) => new(value.X, value.Y, value.Width, value.Height); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Rect ToNative(this System.Drawing.RectangleF value) => new(value.X, value.Y, value.Width, value.Height); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.RectangleF FromNative(this Rect value) => new((float)value.X, (float)value.Y, (float)value.Width, (float)value.Height); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net4/Maths/SizeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing size's and a native size classes. 12 | /// 13 | public static class SizeExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Size ToNative(this System.Drawing.Size value) => new(value.Width, value.Height); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Size ToNative(this System.Drawing.SizeF value) => new(value.Width, value.Height); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.SizeF FromNative(this Size value) => new((float)value.Width, (float)value.Height); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Bitmaps/BitmapMixins.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media.Imaging; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods to assist with dealing with Bitmaps. 12 | /// 13 | public static class BitmapMixins 14 | { 15 | /// 16 | /// Converts to a native type. 17 | /// 18 | /// The bitmap to convert. 19 | /// A bitmap. 20 | public static IBitmap FromNative(this BitmapSource value) => new BitmapSourceBitmap(value); 21 | 22 | /// 23 | /// Converts a to a splat . 24 | /// 25 | /// The native bitmap to convert from. 26 | /// A bitmap. 27 | public static BitmapSource ToNative(this IBitmap value) 28 | { 29 | #if NET6_0_OR_GREATER 30 | ArgumentNullException.ThrowIfNull(value); 31 | #else 32 | if (value == null) 33 | { 34 | throw new System.ArgumentNullException(nameof(value)); 35 | } 36 | #endif 37 | 38 | return ((BitmapSourceBitmap)value).Inner ?? throw new InvalidOperationException("The bitmap is not longer valid"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Bitmaps/BitmapSourceBitmap.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.IO; 7 | using System.Windows.Media.Imaging; 8 | 9 | namespace Splat; 10 | 11 | /// 12 | /// A bitmap that wraps a . 13 | /// 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The platform native bitmap we are wrapping. 18 | internal sealed class BitmapSourceBitmap(BitmapSource bitmap) : IBitmap 19 | { 20 | /// 21 | public float Width => (float)(Inner?.Width ?? 0); 22 | 23 | /// 24 | public float Height => (float)(Inner?.Height ?? 0); 25 | 26 | /// 27 | /// Gets the platform . 28 | /// 29 | public BitmapSource? Inner { get; private set; } = bitmap; 30 | 31 | /// 32 | public Task Save(CompressedBitmapFormat format, float quality, Stream target) => target switch 33 | { 34 | null => throw new ArgumentNullException(nameof(target)), 35 | _ => Task.Run(() => 36 | { 37 | var encoder = format == CompressedBitmapFormat.Jpeg ? 38 | new JpegBitmapEncoder { QualityLevel = (int)(quality * 100.0f) } : 39 | (BitmapEncoder)new PngBitmapEncoder(); 40 | 41 | encoder.Frames.Add(BitmapFrame.Create(Inner)); 42 | encoder.Save(target); 43 | }) 44 | }; 45 | 46 | /// 47 | public void Dispose() => Inner = null; 48 | } 49 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Colors/ColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Provides extension methods for interacting with colors, to and from the XAML colors. 12 | /// 13 | public static class ColorExtensions 14 | { 15 | /// 16 | /// Converts a to a XAML native color. 17 | /// 18 | /// The System.Drawing.Color to convert. 19 | /// A native XAML color. 20 | public static Color ToNative(this System.Drawing.Color value) => Color.FromArgb(value.A, value.R, value.G, value.B); 21 | 22 | /// 23 | /// Converts a into the cocoa native . 24 | /// 25 | /// The color to convert. 26 | /// The generated. 27 | public static SolidColorBrush ToNativeBrush(this System.Drawing.Color value) 28 | { 29 | var ret = new SolidColorBrush(value.ToNative()); 30 | ret.Freeze(); 31 | return ret; 32 | } 33 | 34 | /// 35 | /// Converts a into the XAML . 36 | /// 37 | /// The color to convert. 38 | /// The generated. 39 | public static System.Drawing.Color FromNative(this Color value) => System.Drawing.Color.FromArgb(value.A, value.R, value.G, value.B); 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Colors/SplatColorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows.Media; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// Extension methods associated with the struct. 12 | /// 13 | public static class SplatColorExtensions 14 | { 15 | /// 16 | /// Converts a into the XAML . 17 | /// 18 | /// The color to convert. 19 | /// The generated. 20 | public static Color ToNative(this SplatColor value) => Color.FromArgb(value.A, value.R, value.G, value.B); 21 | 22 | /// 23 | /// Converts a into the XAML . 24 | /// 25 | /// The color to convert. 26 | /// The generated. 27 | public static SolidColorBrush ToNativeBrush(this SplatColor value) 28 | { 29 | var ret = new SolidColorBrush(value.ToNative()); 30 | ret.Freeze(); 31 | return ret; 32 | } 33 | 34 | /// 35 | /// Converts a into the XAML . 36 | /// 37 | /// The color to convert. 38 | /// The generated. 39 | public static SplatColor FromNative(this Color value) => SplatColor.FromArgb(value.A, value.R, value.G, value.B); 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Maths/PointExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing point's and a native point classes. 12 | /// 13 | public static class PointExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Point ToNative(this System.Drawing.Point value) => new(value.X, value.Y); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Point ToNative(this System.Drawing.PointF value) => new(value.X, value.Y); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.PointF FromNative(this Point value) => new((float)value.X, (float)value.Y); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Maths/RectExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing rectangle's and a native rectangle classes. 12 | /// 13 | public static class RectExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Rect ToNative(this System.Drawing.Rectangle value) => new(value.X, value.Y, value.Width, value.Height); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Rect ToNative(this System.Drawing.RectangleF value) => new(value.X, value.Y, value.Width, value.Height); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.RectangleF FromNative(this Rect value) => new((float)value.X, (float)value.Y, (float)value.Width, (float)value.Height); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/net6/Maths/SizeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat; 9 | 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing size's and a native size classes. 12 | /// 13 | public static class SizeExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Size ToNative(this System.Drawing.Size value) => new(value.Width, value.Height); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Size ToNative(this System.Drawing.SizeF value) => new(value.Width, value.Height); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.SizeF FromNative(this Size value) => new((float)value.Width, (float)value.Height); 35 | } 36 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/netcoreapp3/Bitmaps/BitmapMixins.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System; 7 | using System.Windows.Media.Imaging; 8 | 9 | namespace Splat 10 | { 11 | /// 12 | /// Extension methods to assist with dealing with Bitmaps. 13 | /// 14 | public static class BitmapMixins 15 | { 16 | /// 17 | /// Converts to a native type. 18 | /// 19 | /// The bitmap to convert. 20 | /// A bitmap. 21 | public static IBitmap FromNative(this BitmapSource value) => new BitmapSourceBitmap(value); 22 | 23 | /// 24 | /// Converts a to a splat . 25 | /// 26 | /// The native bitmap to convert from. 27 | /// A bitmap. 28 | public static BitmapSource ToNative(this IBitmap value) 29 | { 30 | if (value is null) 31 | { 32 | throw new System.ArgumentNullException(nameof(value)); 33 | } 34 | 35 | return ((BitmapSourceBitmap)value).Inner ?? throw new InvalidOperationException("The bitmap has been disposed"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/netcoreapp3/Maths/PointExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat 9 | { 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing point's and a native point classes. 12 | /// 13 | public static class PointExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Point ToNative(this System.Drawing.Point value) => new(value.X, value.Y); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Point ToNative(this System.Drawing.PointF value) => new(value.X, value.Y); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.PointF FromNative(this Point value) => new((float)value.X, (float)value.Y); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Platforms/netcoreapp3/Maths/SizeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Windows; 7 | 8 | namespace Splat 9 | { 10 | /// 11 | /// A set of extension methods which will convert between System.Drawing size's and a native size classes. 12 | /// 13 | public static class SizeExtensions 14 | { 15 | /// 16 | /// Convert a to the android native . 17 | /// 18 | /// The value to convert. 19 | /// A of the value. 20 | public static Size ToNative(this System.Drawing.Size value) => new(value.Width, value.Height); 21 | 22 | /// 23 | /// Convert a to the android native . 24 | /// 25 | /// The value to convert. 26 | /// A of the value. 27 | public static Size ToNative(this System.Drawing.SizeF value) => new(value.Width, value.Height); 28 | 29 | /// 30 | /// Converts a to a . 31 | /// 32 | /// The value to convert. 33 | /// A of the value. 34 | public static System.Drawing.SizeF FromNative(this Size value) => new((float)value.Width, (float)value.Height); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Resources; 7 | using System.Runtime.CompilerServices; 8 | 9 | [assembly: NeutralResourcesLanguage("en-US")] 10 | [assembly: InternalsVisibleTo("Splat.Tests")] 11 | [assembly: InternalsVisibleTo("Splat.Drawing.Tests")] 12 | [assembly: InternalsVisibleTo("Splat.TestRunner.Android")] 13 | [assembly: InternalsVisibleTo("Splat.TestRunner.Uwp")] 14 | -------------------------------------------------------------------------------- /src/Splat.Drawing/Resources/Resource.designer.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable 1591 2 | //------------------------------------------------------------------------------ 3 | // 4 | // This code was generated by a tool. 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: global::Android.Runtime.ResourceDesignerAttribute("Splat.Resource", IsApplication=false)] 12 | 13 | namespace Splat 14 | { 15 | 16 | 17 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] 18 | public partial class Resource 19 | { 20 | 21 | static Resource() 22 | { 23 | global::Android.Runtime.ResourceIdManager.UpdateIdValues(); 24 | } 25 | 26 | public partial class Attribute 27 | { 28 | 29 | static Attribute() 30 | { 31 | global::Android.Runtime.ResourceIdManager.UpdateIdValues(); 32 | } 33 | 34 | private Attribute() 35 | { 36 | } 37 | } 38 | } 39 | } 40 | #pragma warning restore 1591 41 | -------------------------------------------------------------------------------- /src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | $(NoWarn);1591;CA1707;SA1633;CA2000 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Always 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Splat.DryIoc/README.md: -------------------------------------------------------------------------------- 1 | # Splat.DryIoc 2 | 3 | ## Using DryIoc 4 | 5 | Splay.DryIoc is an adapter for `IMutableDependencyResolver`. It allows you to register your application dependencies in a DryIoc `Container`. You can then use the container as Splat's internal dependency resolver. 6 | 7 | ### Register the Container 8 | 9 | ```cs 10 | var container = new Container(); 11 | container.Register, MainPage>(); 12 | container.Register, SecondaryPage>(); 13 | container.Register(); 14 | container.Register(); 15 | ``` 16 | 17 | ### Register the Adapter to Splat 18 | 19 | ```cs 20 | container.UseDryIocDependencyResolver(); 21 | ``` 22 | 23 | ### Use the Locator 24 | 25 | Now, when registering or resolving services using Locator.Current, or via ReactiveUI, they will be directed to the DryIoc DI container. 26 | -------------------------------------------------------------------------------- /src/Splat.DryIoc/Splat.DryIoc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | $(NoWarn);CA1801 6 | DryIoc adapter for Splat 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Splat.DryIoc/SplatDryIocExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using DryIoc; 7 | 8 | namespace Splat.DryIoc; 9 | 10 | /// 11 | /// Extension methods for the DryIoc adapter. 12 | /// 13 | public static class SplatDryIocExtensions 14 | { 15 | /// 16 | /// Initializes an instance of that overrides the default . 17 | /// 18 | /// The container. 19 | #pragma warning disable CA2000 // Dispose objects before losing scope 20 | public static void UseDryIocDependencyResolver(this IContainer container) => 21 | Locator.SetLocator(new DryIocDependencyResolver(container)); 22 | #pragma warning restore CA2000 // Dispose objects before losing scope 23 | } 24 | -------------------------------------------------------------------------------- /src/Splat.Exceptionless/ExceptionlessViewTracking.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Exceptionless; 7 | 8 | using Splat.ApplicationPerformanceMonitoring; 9 | 10 | namespace Splat; 11 | 12 | /// 13 | /// Exceptionless View Tracking integration. 14 | /// 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The exceptionless client to use. 19 | public sealed class ExceptionlessViewTracking(ExceptionlessClient exceptionlessClient) : IViewTracking 20 | { 21 | private readonly ExceptionlessClient _exceptionlessClient = exceptionlessClient ?? throw new ArgumentNullException(nameof(exceptionlessClient)); 22 | 23 | /// 24 | /// Track a view navigation using just a name. 25 | /// 26 | /// Name of the view. 27 | public void OnViewNavigation(string name) 28 | { 29 | // need to consider whether to just use feature event 30 | // and tag it with view specific properties. 31 | var eventBuilder = _exceptionlessClient 32 | .CreateEvent() 33 | .SetType("PageView") 34 | .SetMessage(name); 35 | 36 | eventBuilder.Submit(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Splat.Exceptionless/MutableDependencyResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Exceptionless; 7 | 8 | namespace Splat.Exceptionless; 9 | 10 | /// 11 | /// Exceptionless specific extensions for the Mutable Dependency Resolver. 12 | /// 13 | public static class MutableDependencyResolverExtensions 14 | { 15 | /// 16 | /// Simple helper to initialize Exceptionless within Splat with the Wrapping Full Logger. 17 | /// 18 | /// 19 | /// You should configure Exceptionless prior to calling this method. 20 | /// 21 | /// 22 | /// An instance of Mutable Dependency Resolver. 23 | /// 24 | /// The exceptionless client instance to use. 25 | /// 26 | /// 27 | /// Locator.CurrentMutable.UseExceptionlessWithWrappingFullLogger(exception); 28 | /// 29 | /// 30 | public static void UseExceptionlessWithWrappingFullLogger(this IMutableDependencyResolver instance, ExceptionlessClient exceptionlessClient) 31 | { 32 | var funcLogManager = new FuncLogManager(type => 33 | { 34 | var miniLoggingWrapper = new ExceptionlessSplatLogger(type, exceptionlessClient); 35 | return new WrappingFullLogger(miniLoggingWrapper); 36 | }); 37 | 38 | instance.RegisterConstant(funcLogManager); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Splat.Exceptionless/Splat.Exceptionless.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.Exceptionless 6 | Splat 7 | .NET Foundation and Contributors 8 | Exceptionless integrations for Splat 9 | Splat.Exceptionless 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Splat.Log4Net/LogResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Log4Net; 7 | 8 | /// 9 | /// Resolves a logger to the specified type. 10 | /// 11 | internal static class LogResolver 12 | { 13 | private const int MaxCacheSize = 16; 14 | private static readonly MemoizingMRUCache _loggerCache = new( 15 | (type, _) => global::log4net.LogManager.GetLogger(type), 16 | MaxCacheSize); 17 | 18 | public static global::log4net.ILog Resolve(Type type) => _loggerCache.Get(type, null); 19 | } 20 | -------------------------------------------------------------------------------- /src/Splat.Log4Net/MutableDependencyResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.Log4Net; 7 | 8 | /// 9 | /// Log4net specific extensions for the Mutable Dependency Resolver. 10 | /// 11 | public static class MutableDependencyResolverExtensions 12 | { 13 | /// 14 | /// Simple helper to initialize Log4Net within Splat with the Wrapping Full Logger. 15 | /// 16 | /// 17 | /// You should configure Log4Net prior to calling this method. 18 | /// 19 | /// 20 | /// An instance of Mutable Dependency Resolver. 21 | /// 22 | /// 23 | /// 24 | /// Locator.CurrentMutable.UseLog4NetWithWrappingFullLogger(); 25 | /// 26 | /// 27 | public static void UseLog4NetWithWrappingFullLogger(this IMutableDependencyResolver instance) 28 | { 29 | var funcLogManager = new FuncLogManager(type => new WrappingFullLogger(new Log4NetLogger(LogResolver.Resolve(type)))); 30 | 31 | instance.RegisterConstant(funcLogManager); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Splat.Log4Net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Resources; 7 | using System.Runtime.CompilerServices; 8 | 9 | [assembly: NeutralResourcesLanguage("en-US")] 10 | [assembly: InternalsVisibleTo("Splat.Tests")] 11 | -------------------------------------------------------------------------------- /src/Splat.Microsoft.Extensions.DependencyInjection.Tests/ContainerWrapper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Splat.Microsoft.Extensions.DependencyInjection.Tests; 4 | 5 | internal sealed class ContainerWrapper 6 | { 7 | private IServiceProvider _serviceProvider; 8 | 9 | #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 10 | public ContainerWrapper() => ServiceCollection.UseMicrosoftDependencyResolver(); 11 | #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 12 | 13 | public IServiceCollection ServiceCollection { get; } = new ServiceCollection(); 14 | 15 | public IServiceProvider ServiceProvider => _serviceProvider ??= ServiceCollection.BuildServiceProvider(); 16 | 17 | public void BuildAndUse() => ServiceProvider.UseMicrosoftDependencyResolver(); 18 | } 19 | -------------------------------------------------------------------------------- /src/Splat.Microsoft.Extensions.DependencyInjection.Tests/Splat.Microsoft.Extensions.DependencyInjection.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | $(NoWarn);1591;CA1707;SA1633;CA2000 6 | false 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Splat.Microsoft.Extensions.DependencyInjection/Splat.Microsoft.Extensions.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Splat.Microsoft.Extensions.Logging/MsLoggingHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Collections.Immutable; 7 | 8 | namespace Splat.Microsoft.Extensions.Logging; 9 | 10 | internal static class MsLoggingHelpers 11 | { 12 | public static KeyValuePair[] Mappings { get; } = 13 | [ 14 | new(LogLevel.Debug, global::Microsoft.Extensions.Logging.LogLevel.Debug), 15 | new(LogLevel.Info, global::Microsoft.Extensions.Logging.LogLevel.Information), 16 | new(LogLevel.Warn, global::Microsoft.Extensions.Logging.LogLevel.Warning), 17 | new(LogLevel.Error, global::Microsoft.Extensions.Logging.LogLevel.Error), 18 | new(LogLevel.Fatal, global::Microsoft.Extensions.Logging.LogLevel.Critical), 19 | ]; 20 | 21 | public static ImmutableDictionary Splat2MsLogDictionary { get; } = Mappings.ToImmutableDictionary(); 22 | 23 | public static ImmutableDictionary MsLog2SplatDictionary { get; } = Mappings.ToImmutableDictionary(x => x.Value, x => x.Key); 24 | } 25 | -------------------------------------------------------------------------------- /src/Splat.Microsoft.Extensions.Logging/Splat.Microsoft.Extensions.Logging.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.Microsoft.Extensions.Logging 6 | Splat 7 | .NET Foundation and Contributors 8 | Microsoft Logging Extensions integrations for Splat 9 | Splat.Microsoft.Extensions.Logging 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Splat.NLog/LogResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.NLog; 7 | 8 | /// 9 | /// Resolves a type to a NLog instance. 10 | /// 11 | internal static class LogResolver 12 | { 13 | private const int MaxCacheSize = 16; 14 | private static readonly MemoizingMRUCache _loggerCache = new( 15 | (type, _) => global::NLog.LogManager.GetLogger(type.ToString()), 16 | MaxCacheSize); 17 | 18 | public static global::NLog.Logger Resolve(Type type) => _loggerCache.Get(type, null); 19 | } 20 | -------------------------------------------------------------------------------- /src/Splat.NLog/MutableDependencyResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | namespace Splat.NLog; 7 | 8 | /// 9 | /// NLog specific extensions for the Mutable Dependency Resolver. 10 | /// 11 | public static class MutableDependencyResolverExtensions 12 | { 13 | /// 14 | /// Simple helper to initialize NLog within Splat with the Wrapping Full Logger. 15 | /// 16 | /// 17 | /// You should configure NLog prior to calling this method. 18 | /// 19 | /// 20 | /// An instance of Mutable Dependency Resolver. 21 | /// 22 | /// 23 | /// 24 | /// Locator.CurrentMutable.UseNLogWithWrappingFullLogger(); 25 | /// 26 | /// 27 | public static void UseNLogWithWrappingFullLogger(this IMutableDependencyResolver instance) 28 | { 29 | var funcLogManager = new FuncLogManager(type => new NLogLogger(LogResolver.Resolve(type))); 30 | 31 | instance.RegisterConstant(funcLogManager); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Splat.NLog/Splat.NLog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.NLog 6 | Splat 7 | .NET Foundation and Contributors 8 | NLog integrations for Splat 9 | Splat.NLog 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Splat.Ninject.Tests/Splat.Ninject.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | $(NoWarn);1591;CA1707;SA1633;CA2000 6 | false 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Splat.Ninject/README.md: -------------------------------------------------------------------------------- 1 | # Splat.Ninject 2 | 3 | ## Using Ninject 4 | 5 | Splat.Ninject is an adapter for `IMutableDependencyResolver`. It allows you to register your application dependencies in a Ninject `IKernel`. You can then use the container as Splat's internal dependency resolver. 6 | 7 | ### Register the Kernel 8 | 9 | ```cs 10 | var kernel = new StandardKernel(); 11 | kernel.Bind>().To(); 12 | kernel.Bind>().To(); 13 | kernel.Bind().ToSelf(); 14 | kernel.Bind().ToSelf(); 15 | ``` 16 | 17 | ### Register the Adapter to Splat 18 | 19 | ```cs 20 | container.UseNinjectDependencyResolver(); 21 | ``` 22 | 23 | ### Use the Locator 24 | 25 | Now, when registering or resolving services using Locator.Current, or via ReactiveUI, they will be directed to the Ninject DI container. 26 | -------------------------------------------------------------------------------- /src/Splat.Ninject/Splat.Ninject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Autofac adapter for Splat 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Splat.Ninject/SplatNinjectExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using Ninject; 7 | 8 | namespace Splat.Ninject; 9 | 10 | /// 11 | /// Extension methods for the Ninject adapter. 12 | /// 13 | public static class SplatNinjectExtensions 14 | { 15 | /// 16 | /// Initializes an instance of that overrides the default . 17 | /// 18 | /// The kernel. 19 | public static void UseNinjectDependencyResolver(this IKernel kernel) => 20 | Locator.SetLocator(new NinjectDependencyResolver(kernel)); 21 | } 22 | -------------------------------------------------------------------------------- /src/Splat.Prism.Forms/PrismApplication.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | [assembly: Xamarin.Forms.XmlnsDefinition("http://prismlibrary.com", "Splat.Prism.Forms")] 7 | 8 | namespace Splat.Prism.Forms; 9 | 10 | /// 11 | /// A application instance which supports Prism types. 12 | /// 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// An initializer for initializing the platform. 17 | public abstract class PrismApplication(IPlatformInitializer? initializer = null) : PrismApplicationBase(initializer) 18 | { 19 | /// 20 | protected override IContainerExtension CreateContainerExtension() => new SplatContainerExtension(); 21 | } 22 | -------------------------------------------------------------------------------- /src/Splat.Prism.Forms/Splat.Prism.Forms.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Prism adapter for Splat including Xamarin Forms adapters. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Splat.Prism.Tests/Splat.Prism.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | $(NoWarn);CA1707;CS1574 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Splat.Prism/Splat.Prism.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Prism adapter for Splat 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Splat.Raygun/Splat.Raygun.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.Raygun 6 | Splat 7 | .NET Foundation and Contributors 8 | Raygun integrations for Splat 9 | Splat.Raygun 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Splat.Serilog/Registration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.ComponentModel; 7 | 8 | namespace Splat.Serilog; 9 | 10 | /// 11 | /// Provides a legacy interface for registrations that was compatible with the old 12 | /// Serilog interfaces provided by Joel Weiss. 13 | /// 14 | [EditorBrowsable(EditorBrowsableState.Never)] 15 | public static class Registration 16 | { 17 | /// 18 | /// Registers a serilog logger with Splat. 19 | /// 20 | /// The logger to register. 21 | [EditorBrowsable(EditorBrowsableState.Never)] 22 | [Obsolete("This method will be removed in the future, Use Splat.Locator.CurrentMutable.UseSerilogWithWrappingFullLogger() instead.")] 23 | public static void Register(global::Serilog.ILogger logger) => Locator.CurrentMutable.UseSerilogFullLogger(logger); 24 | } 25 | -------------------------------------------------------------------------------- /src/Splat.Serilog/SerilogHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Collections.Immutable; 7 | 8 | using Serilog.Events; 9 | 10 | namespace Splat; 11 | 12 | internal static class SerilogHelper 13 | { 14 | /// 15 | /// Gets a list of mappings of Serilog levels and equivalent Splat log levels. 16 | /// 17 | public static KeyValuePair[] Mappings { get; } = 18 | [ 19 | new(LogLevel.Debug, LogEventLevel.Debug), 20 | new(LogLevel.Info, LogEventLevel.Information), 21 | new(LogLevel.Warn, LogEventLevel.Warning), 22 | new(LogLevel.Error, LogEventLevel.Error), 23 | new(LogLevel.Fatal, LogEventLevel.Fatal), 24 | ]; 25 | 26 | /// 27 | /// Gets a dictionary which maps Splat log levels to Serilogs. 28 | /// 29 | public static ImmutableDictionary MappingsDictionary { get; } = Mappings.ToImmutableDictionary(); 30 | } 31 | -------------------------------------------------------------------------------- /src/Splat.Serilog/Splat.Serilog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | Splat.Serilog 6 | Splat 7 | .NET Foundation and Contributors 8 | Serilog integrations for Splat 9 | Splat.Serilog 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | $(NoWarn);1591;CA1707;SA1633;CA2000 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Always 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector.Tests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "shadowCopy": false 3 | } 4 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector/README.md: -------------------------------------------------------------------------------- 1 | # Splat.SimpleInjector 2 | 3 | ## Using SimpleInjector 4 | 5 | Splat.SimpleInjector is an adapter for `IMutableDependencyResolver`. It allows you to register your application dependencies in a SimpleInjector `Container`. You can then use the container as Splat's internal dependency resolver. 6 | 7 | ### Register the Container 8 | 9 | Because of internal SimpleInjector behaviours in order to register it as a container intermediate "dummy" container has to be used - `SimpleInjectorInitializer`. 10 | 11 | ```cs 12 | SimpleInjectorInitializer initializer = new SimpleInjectorInitializer(); 13 | Locator.SetLocator(initializer); 14 | 15 | // Register ReactiveUI dependencies 16 | Locator.CurrentMutable.InitializeSplat(); 17 | Locator.CurrentMutable.InitializeReactiveUI(); 18 | 19 | // Registering Views 20 | Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly()); 21 | 22 | // Register SimpleInjector 23 | Container container = new Container(); 24 | 25 | // Actual SimpleInjector registration 26 | container.UseSimpleInjectorDependencyResolver(initializer); 27 | 28 | // SimpleInjector dependency registrations 29 | container.Register(); 30 | container.Register(); 31 | 32 | // SimpleInjector by default only allows a single registration of a service. 33 | // Splat would typically allow multiple registrations and by default return the 34 | // last registration. 35 | // If you set AllowOverridingRegistrations on SimpleInjector it REPLACES the last 36 | // registration so BE AWARE. 37 | // For more details see: https://simpleinjector.readthedocs.io/en/latest/howto.html#override-existing-registrations 38 | // We may produce a workaround in Splat in future, but for now keep the limitation 39 | // in mind. 40 | container.Options.AllowOverridingRegistrations = true; 41 | container.Register(); 42 | 43 | ``` 44 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector/Splat.SimpleInjector.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(SplatTargetFrameworks) 4 | $(TargetFrameworks);net462 5 | SimpleInjector adapter for Splat 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector/SplatSimpleInjectorExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using SimpleInjector; 7 | 8 | namespace Splat.SimpleInjector; 9 | 10 | /// 11 | /// Extension methods for the SimpleInjector adapter. 12 | /// 13 | public static class SplatSimpleInjectorExtensions 14 | { 15 | /// 16 | /// Initializes an instance of that overrides the default . 17 | /// 18 | /// Simple Injector container. 19 | /// Initializer. 20 | public static void UseSimpleInjectorDependencyResolver(this Container container, SimpleInjectorInitializer initializer) => 21 | Locator.SetLocator(new SimpleInjectorDependencyResolver(container, initializer)); 22 | } 23 | -------------------------------------------------------------------------------- /src/Splat.SimpleInjector/TransientSimpleInjectorRegistration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 ReactiveUI. All rights reserved. 2 | // Licensed to ReactiveUI under one or more agreements. 3 | // ReactiveUI licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Linq.Expressions; 7 | using SimpleInjector; 8 | 9 | namespace Splat.SimpleInjector; 10 | 11 | internal sealed class TransientSimpleInjectorRegistration(Container container, Type implementationType, Func? instanceCreator = null) : Registration(Lifestyle.Transient, container, implementationType, instanceCreator!) 12 | { 13 | public override Expression BuildExpression() => BuildTransientExpression(); 14 | } 15 | -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with your package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System; 7 | 8 | using Android.App; 9 | using Android.OS; 10 | 11 | using Xunit.Runners.UI; 12 | using Xunit.Sdk; 13 | 14 | namespace Splat.TestRunner.Android 15 | { 16 | /// 17 | /// Unit Test Runner Activity. 18 | /// 19 | // ReSharper disable UnusedMember.Global 20 | [Activity(Label = "xUnit Android Runner", MainLauncher = true, Theme = "@android:style/Theme.Material.Light")] 21 | public class MainActivity : RunnerActivity 22 | 23 | // ReSharper restore UnusedMember.Global 24 | { 25 | /// 26 | protected override void OnCreate(Bundle bundle) 27 | { 28 | Locator.CurrentMutable.RegisterPlatformBitmapLoader(); 29 | AddTestAssembly(typeof(Splat.Tests.LocatorTests).Assembly); 30 | AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly); 31 | 32 | // you cannot add more assemblies once calling base 33 | base.OnCreate(bundle); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for full license information. 5 | 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("Splat.TestRunner.Android")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Splat.TestRunner.Android")] 17 | [assembly: AssemblyCopyright("Copyright © .NET Foundation 2021")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | [assembly: ComVisible(false)] 21 | -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.xml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable/ 12 | icon.png 13 | 14 | layout/ 15 | main.xml 16 | 17 | values/ 18 | strings.xml 19 | 20 | In order to get the build system to recognize Android resources, set the build action to 21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 22 | instead operate on resource IDs. When you compile an Android application that uses resources, 23 | the build system will package the resources for distribution and generate a class called "R" 24 | (this is an Android convention) that contains the tokens for each one of the resources 25 | included. For example, for the above Resources layout, this is what the R class would expose: 26 | 27 | public class R { 28 | public class drawable { 29 | public const int icon = 0x123; 30 | } 31 | 32 | public class layout { 33 | public const int main = 0x456; 34 | } 35 | 36 | public class strings { 37 | public const int first_string = 0xabc; 38 | public const int second_string = 0xbcd; 39 | } 40 | } 41 | 42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 43 | to reference the layout/main.xml file, or R.strings.first_string to reference the first 44 | string in the dictionary file values/strings.xml. -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Resources/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/Splat.TestRunner.Android/Resources/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |