diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs
index 892e320afc..adcf844552 100644
--- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs
+++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs
@@ -228,13 +228,8 @@ namespace ControlCatalog.Pages
try
{
// Sync disposal of StreamWriter is not supported on WASM
-#if NET6_0_OR_GREATER
await using var stream = await file.OpenWriteAsync();
await using var writer = new System.IO.StreamWriter(stream);
-#else
- using var stream = await file.OpenWriteAsync();
- using var writer = new System.IO.StreamWriter(stream);
-#endif
await writer.WriteLineAsync(openedFileContent.Text);
SetFolder(await file.GetParentAsync());
@@ -265,13 +260,8 @@ namespace ControlCatalog.Pages
if (result.File is { } file)
{
// Sync disposal of StreamWriter is not supported on WASM
-#if NET6_0_OR_GREATER
await using var stream = await file.OpenWriteAsync();
await using var writer = new System.IO.StreamWriter(stream);
-#else
- using var stream = await file.OpenWriteAsync();
- using var writer = new System.IO.StreamWriter(stream);
-#endif
if (result.SelectedFileType == FilePickerFileTypes.Xml)
{
await writer.WriteLineAsync("Test");
@@ -431,11 +421,7 @@ namespace ControlCatalog.Pages
internal static async Task ReadTextFromFile(IStorageFile file, int length)
{
-#if NET6_0_OR_GREATER
await using var stream = await file.OpenReadAsync();
-#else
- using var stream = await file.OpenReadAsync();
-#endif
using var reader = new System.IO.StreamReader(stream);
// 4GB file test, shouldn't load more than 10000 chars into a memory.
diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj
index ffaac716b9..99524857a7 100644
--- a/src/Avalonia.Base/Avalonia.Base.csproj
+++ b/src/Avalonia.Base/Avalonia.Base.csproj
@@ -16,11 +16,7 @@
-
-
-
-
@@ -65,8 +61,6 @@
-
+
diff --git a/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs b/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs
deleted file mode 100644
index e22288a74d..0000000000
--- a/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-
-namespace System;
-
-#if !NET6_0_OR_GREATER
-internal static class CollectionCompatibilityExtensions
-{
- public static bool Remove(
- this Dictionary o,
- TKey key,
- [MaybeNullWhen(false)] out TValue value)
- where TKey : notnull
- {
- if (o.TryGetValue(key, out value))
- return o.Remove(key);
- return false;
- }
-
- public static bool TryAdd(this Dictionary o, TKey key, TValue value)
- where TKey : notnull
- {
- if (!o.ContainsKey(key))
- {
- o.Add(key, value);
- return true;
- }
-
- return false;
- }
-}
-#endif
diff --git a/src/Avalonia.Base/Compatibility/NativeLibrary.cs b/src/Avalonia.Base/Compatibility/NativeLibrary.cs
deleted file mode 100644
index 7627c095bc..0000000000
--- a/src/Avalonia.Base/Compatibility/NativeLibrary.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using Avalonia.Compatibility;
-using Avalonia.Platform.Interop;
-
-namespace Avalonia.Compatibility
-{
- internal class NativeLibraryEx
- {
-#if NET6_0_OR_GREATER
- public static IntPtr Load(string dll, Assembly assembly) => NativeLibrary.Load(dll, assembly, null);
- public static IntPtr Load(string dll) => NativeLibrary.Load(dll);
- public static bool TryGetExport(IntPtr handle, string name, out IntPtr address) =>
- NativeLibrary.TryGetExport(handle, name, out address);
-#else
- public static IntPtr Load(string dll, Assembly assembly) => Load(dll);
- public static IntPtr Load(string dll)
- {
- var handle = DlOpen!(dll);
- if (handle != IntPtr.Zero)
- return handle;
- throw new InvalidOperationException("Unable to load " + dll, DlError!());
- }
-
- public static bool TryGetExport(IntPtr handle, string name, out IntPtr address)
- {
- try
- {
- address = DlSym!(handle, name);
- return address != default;
- }
- catch (Exception)
- {
- address = default;
- return false;
- }
- }
-
- static NativeLibraryEx()
- {
- if (OperatingSystemEx.IsWindows())
- {
- Win32Imports.Init();
- }
- else if (OperatingSystemEx.IsLinux() || OperatingSystemEx.IsMacOS())
- {
- var buffer = Marshal.AllocHGlobal(0x1000);
- uname(buffer);
- var unixName = Marshal.PtrToStringAnsi(buffer);
- Marshal.FreeHGlobal(buffer);
- if (unixName == "Darwin")
- OsXImports.Init();
- else
- LinuxImports.Init();
- }
- }
-
- private static Func? DlOpen;
- private static Func? DlSym;
- private static Func? DlError;
-
- [DllImport("libc")]
- static extern int uname(IntPtr buf);
-
- static class Win32Imports
- {
- [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
- private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
-
- [DllImport("kernel32", EntryPoint = "LoadLibraryW", SetLastError = true, CharSet = CharSet.Unicode)]
- private static extern IntPtr LoadLibrary(string lpszLib);
-
- public static void Init()
- {
- DlOpen = LoadLibrary;
- DlSym = GetProcAddress;
- DlError = () => new Win32Exception(Marshal.GetLastWin32Error());
- }
- }
-
- static class LinuxImports
- {
- [DllImport("libdl.so.2")]
- private static extern IntPtr dlopen(string path, int flags);
-
- [DllImport("libdl.so.2")]
- private static extern IntPtr dlsym(IntPtr handle, string symbol);
-
- [DllImport("libdl.so.2")]
- private static extern IntPtr dlerror();
-
- public static void Init()
- {
- DlOpen = s => dlopen(s, 1);
- DlSym = dlsym;
- DlError = () => new InvalidOperationException(Marshal.PtrToStringAnsi(dlerror()));
- }
- }
-
- static class OsXImports
- {
- [DllImport("/usr/lib/libSystem.dylib")]
- private static extern IntPtr dlopen(string path, int flags);
-
- [DllImport("/usr/lib/libSystem.dylib")]
- private static extern IntPtr dlsym(IntPtr handle, string symbol);
-
- [DllImport("/usr/lib/libSystem.dylib")]
- private static extern IntPtr dlerror();
-
- public static void Init()
- {
- DlOpen = s => dlopen(s, 1);
- DlSym = dlsym;
- DlError = () => new InvalidOperationException(Marshal.PtrToStringAnsi(dlerror()));
- }
- }
-#endif
- }
-}
diff --git a/src/Avalonia.Base/Compatibility/OperatingSystem.cs b/src/Avalonia.Base/Compatibility/OperatingSystem.cs
deleted file mode 100644
index ad5fe0246a..0000000000
--- a/src/Avalonia.Base/Compatibility/OperatingSystem.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace Avalonia.Compatibility
-{
- internal sealed class OperatingSystemEx
- {
-#if NET6_0_OR_GREATER
- public static bool IsWindows() => OperatingSystem.IsWindows();
- public static bool IsMacOS() => OperatingSystem.IsMacOS();
- public static bool IsMacCatalyst() => OperatingSystem.IsMacCatalyst();
- public static bool IsLinux() => OperatingSystem.IsLinux();
- public static bool IsFreeBSD() => OperatingSystem.IsFreeBSD();
- public static bool IsAndroid() => OperatingSystem.IsAndroid();
- public static bool IsIOS() => OperatingSystem.IsIOS();
- public static bool IsTvOS() => OperatingSystem.IsTvOS();
- public static bool IsBrowser() => OperatingSystem.IsBrowser();
- public static bool IsOSPlatform(string platform) => OperatingSystem.IsOSPlatform(platform);
-#else
- public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
- public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
- public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
- public static bool IsFreeBSD() => false;
- public static bool IsAndroid() => false;
- public static bool IsIOS() => false;
- public static bool IsMacCatalyst() => false;
- public static bool IsTvOS() => false;
- public static bool IsBrowser() => false;
- public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform));
-#endif
- }
-}
diff --git a/src/Avalonia.Base/Compatibility/StringSyntaxAttribute.cs b/src/Avalonia.Base/Compatibility/StringSyntaxAttribute.cs
deleted file mode 100644
index 2b3585fbe4..0000000000
--- a/src/Avalonia.Base/Compatibility/StringSyntaxAttribute.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma warning disable MA0048 // File name must match type name
-// https://github.com/dotnet/runtime/blob/v8.0.4/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs
-
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// ReSharper disable once CheckNamespace
-namespace System.Diagnostics.CodeAnalysis
-{
-#if !NET7_0_OR_GREATER
- /// Specifies the syntax used in a string.
- [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
- internal sealed class StringSyntaxAttribute : Attribute
- {
- /// Initializes the with the identifier of the syntax used.
- /// The syntax identifier.
- public StringSyntaxAttribute(string syntax)
- {
- Syntax = syntax;
- Arguments = Array.Empty