Browse Source

Remove JetBrains.Annotations from the repo

Max Katz 3 years ago
parent
commit
8a78f134c5
45 changed files with 60 additions and 141 deletions
  1. 0 1
      Avalonia.sln
  2. 0 5
      build/JetBrains.Annotations.props
  3. 0 1
      nukebuild/DotNetConfigHelper.cs
  4. 0 1
      src/Avalonia.Base/Animation/AnimationInstance`1.cs
  5. 0 1
      src/Avalonia.Base/Avalonia.Base.csproj
  6. 0 34
      src/Avalonia.Base/Contract.cs
  7. 1 3
      src/Avalonia.Base/Data/InstancedBinding.cs
  8. 2 4
      src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs
  9. 0 6
      src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs
  10. 4 3
      src/Avalonia.Base/Media/DrawingGroup.cs
  11. 1 2
      src/Avalonia.Base/Media/Typeface.cs
  12. 0 2
      src/Avalonia.Base/PixelVector.cs
  13. 4 1
      src/Avalonia.Base/Visual.cs
  14. 0 1
      src/Avalonia.Controls.ColorPicker/Avalonia.Controls.ColorPicker.csproj
  15. 0 1
      src/Avalonia.Controls.DataGrid/Avalonia.Controls.DataGrid.csproj
  16. 2 2
      src/Avalonia.Controls.DataGrid/DataGridColumn.cs
  17. 0 1
      src/Avalonia.Controls.DataGrid/DataGridRows.cs
  18. 0 2
      src/Avalonia.Controls.DataGrid/Primitives/DataGridFrozenGrid.cs
  19. 0 1
      src/Avalonia.Controls/Avalonia.Controls.csproj
  20. 0 1
      src/Avalonia.Controls/Utils/BorderRenderHelper.cs
  21. 0 1
      src/Avalonia.Controls/WindowBase.cs
  22. 1 2
      src/Avalonia.FreeDesktop/LinuxMountedVolumeInfoProvider.cs
  23. 13 10
      src/Avalonia.Native/AvaloniaNativePlatform.cs
  24. 0 1
      src/Avalonia.Native/Helpers.cs
  25. 0 1
      src/Avalonia.Native/MacOSMountedVolumeInfoProvider.cs
  26. 0 1
      src/Avalonia.X11/NativeDialogs/Gtk.cs
  27. 0 1
      src/Avalonia.X11/X11Info.cs
  28. 0 1
      src/Avalonia.X11/X11Screens.cs
  29. 1 2
      src/Avalonia.X11/X11Window.Ime.cs
  30. 0 1
      src/Linux/Avalonia.LinuxFramebuffer/DrmOutputOptions.cs
  31. 16 16
      src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs
  32. 1 2
      src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
  33. 1 3
      src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CommandAccessorPlugin.cs
  34. 4 10
      src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/PropertyInfoAccessorFactory.cs
  35. 3 3
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  36. 2 2
      src/Skia/Avalonia.Skia/GlyphRunImpl.cs
  37. 0 1
      src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
  38. 3 2
      src/Windows/Avalonia.Win32/Win32Platform.cs
  39. 0 1
      src/Windows/Avalonia.Win32/WindowsMountedVolumeInfoProvider.cs
  40. 0 1
      src/iOS/Avalonia.iOS/AvaloniaView.Text.cs
  41. 0 1
      tests/Avalonia.Base.UnitTests/Rendering/CompositorTestsBase.cs
  42. 0 1
      tests/Avalonia.Benchmarks/Data/AccessorTestObject.cs
  43. 1 1
      tests/Avalonia.Benchmarks/Utilities/AvaloniaPropertyDictionaryBenchmarks.cs
  44. 0 1
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs
  45. 0 2
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs

+ 0 - 1
Avalonia.sln

@@ -100,7 +100,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1
 		build\EmbedXaml.props = build\EmbedXaml.props
 		build\HarfBuzzSharp.props = build\HarfBuzzSharp.props
 		build\ImageSharp.props = build\ImageSharp.props
-		build\JetBrains.Annotations.props = build\JetBrains.Annotations.props
 		build\JetBrains.dotMemoryUnit.props = build\JetBrains.dotMemoryUnit.props
 		build\Microsoft.CSharp.props = build\Microsoft.CSharp.props
 		build\Microsoft.Reactive.Testing.props = build\Microsoft.Reactive.Testing.props

+ 0 - 5
build/JetBrains.Annotations.props

@@ -1,5 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <PackageReference Include="JetBrains.Annotations" Version="10.3.0" />
-  </ItemGroup>
-</Project>

+ 0 - 1
nukebuild/DotNetConfigHelper.cs

@@ -1,5 +1,4 @@
 using System.Globalization;
-using JetBrains.Annotations;
 using Nuke.Common.Tools.DotNet;
 // ReSharper disable ReturnValueOfPureMethodIsNotUsed
 

+ 0 - 1
src/Avalonia.Base/Animation/AnimationInstance`1.cs

@@ -5,7 +5,6 @@ using Avalonia.Animation.Animators;
 using Avalonia.Animation.Utils;
 using Avalonia.Data;
 using Avalonia.Reactive;
-using JetBrains.Annotations;
 
 namespace Avalonia.Animation
 {

+ 0 - 1
src/Avalonia.Base/Avalonia.Base.csproj

@@ -15,7 +15,6 @@
   <Import Project="..\..\build\Base.props" />
   <Import Project="..\..\build\Binding.props" />
   <Import Project="..\..\build\Rx.props" />
-  <Import Project="..\..\build\JetBrains.Annotations.props" />
   <Import Project="..\..\build\System.Memory.props" />
   <Import Project="..\..\build\ApiDiff.props" />
   <Import Project="..\..\build\NullableEnable.props" />

+ 0 - 34
src/Avalonia.Base/Contract.cs

@@ -1,34 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-using JetBrains.Annotations;
-
-namespace Avalonia
-{
-    /// <summary>
-    /// A stub of Code Contract's Contract class.
-    /// </summary>
-    /// <remarks>
-    /// It would be nice to use Code Contracts on Avalonia but last time I tried it slowed things
-    /// to a crawl and often crashed. Instead use the same signature for checking preconditions
-    /// in the hope that it might become usable at some point.
-    /// </remarks>
-    public static class Contract
-    {
-        /// <summary>
-        /// Specifies a precondition.
-        /// </summary>
-        /// <typeparam name="TException">
-        /// The exception to throw if <paramref name="condition"/> is false.
-        /// </typeparam>
-        /// <param name="condition">The precondition.</param>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        [ContractAnnotation("condition:false=>stop")]
-        public static void Requires<TException>(bool condition) where TException : Exception, new()
-        {
-            if (!condition)
-            {
-                throw new TException();
-            }
-        }
-    }
-}

+ 1 - 3
src/Avalonia.Base/Data/InstancedBinding.cs

@@ -28,11 +28,9 @@ namespace Avalonia.Data
         /// </remarks>
         public InstancedBinding(ISubject<object?> subject, BindingMode mode, BindingPriority priority)
         {
-            Contract.Requires<ArgumentNullException>(subject != null);
-
             Mode = mode;
             Priority = priority;
-            Value = subject;
+            Value = subject ?? throw new ArgumentNullException(nameof(subject));
         }
 
         private InstancedBinding(object? value, BindingMode mode, BindingPriority priority)

+ 2 - 4
src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs

@@ -21,11 +21,9 @@ namespace Avalonia.Input.Raw
         /// <param name="root">The root from which the event originates.</param>
         public RawInputEventArgs(IInputDevice device, ulong timestamp, IInputRoot root)
         {
-            device = device ?? throw new ArgumentNullException(nameof(device));
-
-            Device = device;
+            Device = device ?? throw new ArgumentNullException(nameof(device));
             Timestamp = timestamp;
-            Root = root;
+            Root = root ?? throw new ArgumentNullException(nameof(root));
         }
 
         /// <summary>

+ 0 - 6
src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs

@@ -53,9 +53,6 @@ namespace Avalonia.Input.Raw
             RawInputModifiers inputModifiers)
             : base(device, timestamp, root)
         {
-            Contract.Requires<ArgumentNullException>(device != null);
-            Contract.Requires<ArgumentNullException>(root != null);
-
             Point = new RawPointerPoint();
             Position = position;
             Type = type;
@@ -80,9 +77,6 @@ namespace Avalonia.Input.Raw
             RawInputModifiers inputModifiers)
             : base(device, timestamp, root)
         {
-            Contract.Requires<ArgumentNullException>(device != null);
-            Contract.Requires<ArgumentNullException>(root != null);
-
             Point = point;
             Type = type;
             InputModifiers = inputModifiers;

+ 4 - 3
src/Avalonia.Base/Media/DrawingGroup.cs

@@ -461,9 +461,10 @@ namespace Avalonia.Media
 
                 if (_rootDrawing == null)
                 {
-                    // When a DrawingGroup is set, it should be made the root if
-                    // a root drawing didnt exist.
-                    Contract.Requires<NotSupportedException>(_currentDrawingGroup == null);
+                    if (_currentDrawingGroup != null)
+                    {
+                        throw new NotSupportedException("When a DrawingGroup is set, it should be made the root if a root drawing didnt exist.");
+                    }
 
                     // If this is the first Drawing being added, avoid creating a DrawingGroup
                     // and set this drawing as the root drawing.  This optimizes the common

+ 1 - 2
src/Avalonia.Base/Media/Typeface.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Diagnostics;
-using JetBrains.Annotations;
 
 namespace Avalonia.Media
 {
@@ -17,7 +16,7 @@ namespace Avalonia.Media
         /// <param name="style">The font style.</param>
         /// <param name="weight">The font weight.</param>
         /// <param name="stretch">The font stretch.</param>
-        public Typeface([NotNull] FontFamily fontFamily,
+        public Typeface(FontFamily fontFamily,
             FontStyle style = FontStyle.Normal,
             FontWeight weight = FontWeight.Normal,
             FontStretch stretch = FontStretch.Normal)

+ 0 - 2
src/Avalonia.Base/PixelVector.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Globalization;
 using Avalonia.Animation.Animators;
-using JetBrains.Annotations;
 
 namespace Avalonia
 {
@@ -135,7 +134,6 @@ namespace Avalonia
         /// </summary>
         /// <param name="other">The other vector.</param>
         /// <returns>True if vectors are nearly equal.</returns>
-        [Pure]
         public bool NearlyEquals(PixelVector other)
         {
             const float tolerance = float.Epsilon;

+ 4 - 1
src/Avalonia.Base/Visual.cs

@@ -367,7 +367,10 @@ namespace Avalonia
         /// <param name="context">The drawing context.</param>
         public virtual void Render(DrawingContext context)
         {
-            Contract.Requires<ArgumentNullException>(context != null);
+            if (context is null)
+            {
+                throw new ArgumentNullException(nameof(context));
+            }
         }
 
         /// <summary>

+ 0 - 1
src/Avalonia.Controls.ColorPicker/Avalonia.Controls.ColorPicker.csproj

@@ -17,7 +17,6 @@
   </ItemGroup>
   <Import Project="..\..\build\Rx.props" />
   <Import Project="..\..\build\EmbedXaml.props" />
-  <Import Project="..\..\build\JetBrains.Annotations.props" />
   <Import Project="..\..\build\BuildTargets.targets" />
   <!--<Import Project="..\..\build\ApiDiff.props" />-->
   <Import Project="..\..\build\NullableEnable.props" />

+ 0 - 1
src/Avalonia.Controls.DataGrid/Avalonia.Controls.DataGrid.csproj

@@ -14,7 +14,6 @@
   </ItemGroup>
   <Import Project="..\..\build\Rx.props" />
   <Import Project="..\..\build\EmbedXaml.props" />
-  <Import Project="..\..\build\JetBrains.Annotations.props" />
   <Import Project="..\..\build\BuildTargets.targets" />
   <Import Project="..\..\build\ApiDiff.props" />
   <Import Project="..\..\build\DevAnalyzers.props" />

+ 2 - 2
src/Avalonia.Controls.DataGrid/DataGridColumn.cs

@@ -641,7 +641,7 @@ namespace Avalonia.Controls
 
         public Control GetCellContent(DataGridRow dataGridRow)
         {
-            Contract.Requires<ArgumentNullException>(dataGridRow != null);
+            dataGridRow = dataGridRow ?? throw new ArgumentNullException(nameof(dataGridRow));
             if (OwningGrid == null)
             {
                 throw DataGridError.DataGrid.NoOwningGrid(GetType());
@@ -659,7 +659,7 @@ namespace Avalonia.Controls
 
         public Control GetCellContent(object dataItem)
         {
-            Contract.Requires<ArgumentNullException>(dataItem != null);
+            dataItem = dataItem ?? throw new ArgumentNullException(nameof(dataItem));
             if (OwningGrid == null)
             {
                 throw DataGridError.DataGrid.NoOwningGrid(GetType());

+ 0 - 1
src/Avalonia.Controls.DataGrid/DataGridRows.cs

@@ -16,7 +16,6 @@ using System.Diagnostics;
 using System.Linq;
 using Avalonia.Data;
 using Avalonia.Styling;
-using JetBrains.Annotations;
 
 namespace Avalonia.Controls
 {

+ 0 - 2
src/Avalonia.Controls.DataGrid/Primitives/DataGridFrozenGrid.cs

@@ -26,7 +26,6 @@ namespace Avalonia.Controls.Primitives
         /// <returns>true if the grid is frozen; otherwise, false. The default is true.</returns>
         public static bool GetIsFrozen(Control element)
         {
-            Contract.Requires<ArgumentNullException>(element != null);
             return element.GetValue(IsFrozenProperty);
         }
 
@@ -38,7 +37,6 @@ namespace Avalonia.Controls.Primitives
         /// <exception cref="T:System.ArgumentNullException"><paramref name="element" /> is null.</exception>
         public static void SetIsFrozen(Control element, bool value)
         {
-            Contract.Requires<ArgumentNullException>(element != null);
             element.SetValue(IsFrozenProperty, value);
         }
     }

+ 0 - 1
src/Avalonia.Controls/Avalonia.Controls.csproj

@@ -7,7 +7,6 @@
     <ProjectReference Include="..\Avalonia.Remote.Protocol\Avalonia.Remote.Protocol.csproj" />
   </ItemGroup>
   <Import Project="..\..\build\Rx.props" />
-  <Import Project="..\..\build\JetBrains.Annotations.props" />
   <Import Project="..\..\build\ApiDiff.props" />
   <Import Project="..\..\build\NullableEnable.props" />
   <Import Project="..\..\build\TrimmingEnable.props" />

+ 0 - 1
src/Avalonia.Controls/Utils/BorderRenderHelper.cs

@@ -4,7 +4,6 @@ using Avalonia.Media;
 using Avalonia.Media.Immutable;
 using Avalonia.Platform;
 using Avalonia.Utilities;
-using JetBrains.Annotations;
 
 namespace Avalonia.Controls.Utils
 {

+ 0 - 1
src/Avalonia.Controls/WindowBase.cs

@@ -8,7 +8,6 @@ using Avalonia.Controls.Primitives;
 using Avalonia.Input;
 using Avalonia.Layout;
 using Avalonia.Platform;
-using JetBrains.Annotations;
 
 namespace Avalonia.Controls
 {

+ 1 - 2
src/Avalonia.FreeDesktop/LinuxMountedVolumeInfoProvider.cs

@@ -9,8 +9,7 @@ namespace Avalonia.FreeDesktop
     {
         public IDisposable Listen(ObservableCollection<MountedVolumeInfo> mountedDrives)
         {
-            Contract.Requires<ArgumentNullException>(mountedDrives != null);
-            return new LinuxMountedVolumeInfoListener(ref mountedDrives!);
+            return new LinuxMountedVolumeInfoListener(ref mountedDrives);
         }
     }
 }

+ 13 - 10
src/Avalonia.Native/AvaloniaNativePlatform.cs

@@ -9,23 +9,23 @@ using Avalonia.OpenGL;
 using Avalonia.Platform;
 using Avalonia.Rendering;
 using Avalonia.Rendering.Composition;
-using JetBrains.Annotations;
 using MicroCom.Runtime;
+#nullable enable
 
 namespace Avalonia.Native
 {
     class AvaloniaNativePlatform : IWindowingPlatform
     {
         private readonly IAvaloniaNativeFactory _factory;
-        private AvaloniaNativePlatformOptions _options;
-        private AvaloniaNativeGlPlatformGraphics _platformGl;
+        private AvaloniaNativePlatformOptions? _options;
+        private AvaloniaNativeGlPlatformGraphics? _platformGl;
 
         [DllImport("libAvaloniaNative")]
         static extern IntPtr CreateAvaloniaNative();
 
         internal static readonly KeyboardDevice KeyboardDevice = new KeyboardDevice();
-        [CanBeNull] internal static Compositor Compositor { get; private set; }
-        [CanBeNull] internal static PlatformRenderInterfaceContextManager RenderInterface { get; private set; }
+        internal static Compositor? Compositor { get; private set; }
+        internal static PlatformRenderInterfaceContextManager? RenderInterface { get; private set; }
 
         public static AvaloniaNativePlatform Initialize(IntPtr factory, AvaloniaNativePlatformOptions options)
         {
@@ -63,7 +63,7 @@ namespace Avalonia.Native
 
         public void SetupApplicationName()
         {
-            if (!string.IsNullOrWhiteSpace(Application.Current.Name))
+            if (!string.IsNullOrWhiteSpace(Application.Current!.Name))
             {
                 _factory.MacOptions.SetApplicationTitle(Application.Current.Name);
             }
@@ -118,10 +118,13 @@ namespace Avalonia.Native
             AvaloniaLocator.CurrentMutable.Bind<IRenderLoop>().ToConstant(renderLoop);
 
             var hotkeys = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
-            hotkeys.MoveCursorToTheStartOfLine.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers));
-            hotkeys.MoveCursorToTheStartOfLineWithSelection.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers | hotkeys.SelectionModifiers));
-            hotkeys.MoveCursorToTheEndOfLine.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers));
-            hotkeys.MoveCursorToTheEndOfLineWithSelection.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers | hotkeys.SelectionModifiers));
+            if (hotkeys is not null)
+            {
+                hotkeys.MoveCursorToTheStartOfLine.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers));
+                hotkeys.MoveCursorToTheStartOfLineWithSelection.Add(new KeyGesture(Key.Left, hotkeys.CommandModifiers | hotkeys.SelectionModifiers));
+                hotkeys.MoveCursorToTheEndOfLine.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers));
+                hotkeys.MoveCursorToTheEndOfLineWithSelection.Add(new KeyGesture(Key.Right, hotkeys.CommandModifiers | hotkeys.SelectionModifiers));
+            }
             
             if (_options.UseGpu)
             {

+ 0 - 1
src/Avalonia.Native/Helpers.cs

@@ -1,5 +1,4 @@
 using Avalonia.Native.Interop;
-using JetBrains.Annotations;
 
 namespace Avalonia.Native
 {

+ 0 - 1
src/Avalonia.Native/MacOSMountedVolumeInfoProvider.cs

@@ -72,7 +72,6 @@ namespace Avalonia.Native
     {
         public IDisposable Listen(ObservableCollection<MountedVolumeInfo> mountedDrives)
         {
-            Contract.Requires<ArgumentNullException>(mountedDrives != null);
             return new MacOSMountedVolumeInfoListener(mountedDrives);
         }
     }

+ 0 - 1
src/Avalonia.X11/NativeDialogs/Gtk.cs

@@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading.Tasks;
 using Avalonia.Platform.Interop;
-using JetBrains.Annotations;
 
 // ReSharper disable IdentifierTypo
 namespace Avalonia.X11.NativeDialogs

+ 0 - 1
src/Avalonia.X11/X11Info.cs

@@ -2,7 +2,6 @@ using System;
 using System.Linq;
 using System.Reflection;
 using System.Runtime.InteropServices;
-using JetBrains.Annotations;
 using static Avalonia.X11.XLib;
 // ReSharper disable UnusedAutoPropertyAccessor.Local
 namespace Avalonia.X11

+ 0 - 1
src/Avalonia.X11/X11Screens.cs

@@ -5,7 +5,6 @@ using System.Linq;
 using System.Runtime.InteropServices;
 using Avalonia.Platform;
 using static Avalonia.X11.XLib;
-using JetBrains.Annotations;
 
 namespace Avalonia.X11
 {

+ 1 - 2
src/Avalonia.X11/X11Window.Ime.cs

@@ -7,7 +7,6 @@ using Avalonia.Input;
 using Avalonia.Input.Raw;
 using Avalonia.Input.TextInput;
 using Avalonia.Platform.Interop;
-using JetBrains.Annotations;
 using static Avalonia.X11.XLib;
 
 namespace Avalonia.X11
@@ -206,7 +205,7 @@ namespace Avalonia.X11
         // This class is used to attach the text value of the key to an asynchronously dispatched KeyDown event
         class RawKeyEventArgsWithText : RawKeyEventArgs
         {
-            public RawKeyEventArgsWithText([NotNull] IKeyboardDevice device, ulong timestamp, [NotNull] IInputRoot root,
+            public RawKeyEventArgsWithText(IKeyboardDevice device, ulong timestamp, IInputRoot root,
                 RawKeyEventType type, Key key, RawInputModifiers modifiers, string text) :
                 base(device, timestamp, root, type, key, modifiers)
             {

+ 0 - 1
src/Linux/Avalonia.LinuxFramebuffer/DrmOutputOptions.cs

@@ -1,6 +1,5 @@
 using Avalonia.LinuxFramebuffer.Output;
 using Avalonia.Media;
-using JetBrains.Annotations;
 
 namespace Avalonia.LinuxFramebuffer
 {

+ 16 - 16
src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs

@@ -17,7 +17,7 @@ using Avalonia.Platform;
 using Avalonia.Rendering;
 using Avalonia.Rendering.Composition;
 using Avalonia.Threading;
-using JetBrains.Annotations;
+#nullable enable
 
 namespace Avalonia.LinuxFramebuffer
 {
@@ -26,9 +26,9 @@ namespace Avalonia.LinuxFramebuffer
         IOutputBackend _fb;
         private static readonly Stopwatch St = Stopwatch.StartNew();
         internal static uint Timestamp => (uint)St.ElapsedTicks;
-        public static InternalPlatformThreadingInterface Threading;
+        public static InternalPlatformThreadingInterface? Threading;
         
-        internal static Compositor Compositor { get; private set; }
+        internal static Compositor? Compositor { get; private set; }
         
         
         LinuxFramebufferPlatform(IOutputBackend backend)
@@ -60,7 +60,7 @@ namespace Avalonia.LinuxFramebuffer
         }
 
 
-        internal static LinuxFramebufferLifetime Initialize<T>(T builder, IOutputBackend outputBackend, IInputBackend inputBackend) where T : AppBuilderBase<T>, new()
+        internal static LinuxFramebufferLifetime Initialize<T>(T builder, IOutputBackend outputBackend, IInputBackend? inputBackend) where T : AppBuilderBase<T>, new()
         {
             var platform = new LinuxFramebufferPlatform(outputBackend);
             builder.UseSkia().UseWindowingSubsystem(platform.Initialize, "fbdev");
@@ -71,8 +71,8 @@ namespace Avalonia.LinuxFramebuffer
     class LinuxFramebufferLifetime : IControlledApplicationLifetime, ISingleViewApplicationLifetime
     {
         private readonly IOutputBackend _fb;
-        [CanBeNull] private readonly IInputBackend _inputBackend;
-        private TopLevel _topLevel;
+        private readonly IInputBackend? _inputBackend;
+        private TopLevel? _topLevel;
         private readonly CancellationTokenSource _cts = new CancellationTokenSource();
         public CancellationToken Token => _cts.Token;
 
@@ -81,15 +81,15 @@ namespace Avalonia.LinuxFramebuffer
             _fb = fb;
         }
 
-        public LinuxFramebufferLifetime(IOutputBackend fb, IInputBackend input)
+        public LinuxFramebufferLifetime(IOutputBackend fb, IInputBackend? input)
         {
             _fb = fb;
             _inputBackend = input;
         }
 
-        public Control MainView
+        public Control? MainView
         {
-            get => (Control)_topLevel?.Content;
+            get => (Control?)_topLevel?.Content;
             set
             {
                 if (_topLevel == null)
@@ -119,8 +119,8 @@ namespace Avalonia.LinuxFramebuffer
         }
 
         public int ExitCode { get; private set; }
-        public event EventHandler<ControlledApplicationLifetimeStartupEventArgs> Startup;
-        public event EventHandler<ControlledApplicationLifetimeExitEventArgs> Exit;
+        public event EventHandler<ControlledApplicationLifetimeStartupEventArgs>? Startup;
+        public event EventHandler<ControlledApplicationLifetimeExitEventArgs>? Exit;
 
         public void Start(string[] args)
         {
@@ -140,19 +140,19 @@ namespace Avalonia.LinuxFramebuffer
 
 public static class LinuxFramebufferPlatformExtensions
 {
-    public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev = null, double scaling = 1, IInputBackend inputBackend = default)
+    public static int StartLinuxFbDev<T>(this T builder, string[] args, string? fbdev = null, double scaling = 1, IInputBackend? inputBackend = default)
         where T : AppBuilderBase<T>, new() =>
         StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: null) { Scaling = scaling }, inputBackend);
-    public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev, PixelFormat? format, double scaling, IInputBackend inputBackend = default)
+    public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev, PixelFormat? format, double scaling, IInputBackend? inputBackend = default)
         where T : AppBuilderBase<T>, new() =>
         StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: format) { Scaling = scaling }, inputBackend);
 
-    public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, double scaling = 1, IInputBackend inputBackend = default)
+    public static int StartLinuxDrm<T>(this T builder, string[] args, string? card = null, double scaling = 1, IInputBackend? inputBackend = default)
         where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card) { Scaling = scaling }, inputBackend);
-    public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, bool connectorsForceProbe = false, [CanBeNull] DrmOutputOptions options = null, IInputBackend inputBackend = default)
+    public static int StartLinuxDrm<T>(this T builder, string[] args, string? card = null, bool connectorsForceProbe = false, DrmOutputOptions? options = null, IInputBackend? inputBackend = default)
         where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card, connectorsForceProbe, options), inputBackend);
 
-    public static int StartLinuxDirect<T>(this T builder, string[] args, IOutputBackend outputBackend, IInputBackend inputBackend = default)
+    public static int StartLinuxDirect<T>(this T builder, string[] args, IOutputBackend outputBackend, IInputBackend? inputBackend = default)
         where T : AppBuilderBase<T>, new()
     {
         var lifetime = LinuxFramebufferPlatform.Initialize(builder, outputBackend, inputBackend);

+ 1 - 2
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs

@@ -8,7 +8,6 @@ using Avalonia.OpenGL.Egl;
 using Avalonia.OpenGL.Surfaces;
 using Avalonia.Platform;
 using Avalonia.Platform.Interop;
-using JetBrains.Annotations;
 using static Avalonia.LinuxFramebuffer.NativeUnsafeMethods;
 using static Avalonia.LinuxFramebuffer.Output.LibDrm;
 using static Avalonia.LinuxFramebuffer.Output.LibDrm.GbmColorFormats;
@@ -50,7 +49,7 @@ namespace Avalonia.LinuxFramebuffer.Output
                 _outputOptions = options;
             Init(card, resources, connector, modeInfo);
         }
-        public DrmOutput(string path = null, bool connectorsForceProbe = false, [CanBeNull] DrmOutputOptions options = null)
+        public DrmOutput(string path = null, bool connectorsForceProbe = false, DrmOutputOptions? options = null)
         {
             if(options != null) 
                 _outputOptions = options;

+ 1 - 3
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CommandAccessorPlugin.cs

@@ -44,9 +44,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
 
             public CommandAccessor(WeakReference<object> reference, Action<object, object> execute, Func<object, object, bool> canExecute, ISet<string> dependsOnProperties)
             {
-                Contract.Requires<ArgumentNullException>(reference != null);
-
-                _reference = reference;
+                _reference = reference ?? throw new ArgumentNullException(nameof(reference));
                 _dependsOnProperties = dependsOnProperties;
                 _command = new Command(reference, execute, canExecute);
 

+ 4 - 10
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/PropertyInfoAccessorFactory.cs

@@ -28,11 +28,8 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
 
         public AvaloniaPropertyAccessor(WeakReference<AvaloniaObject> reference, AvaloniaProperty property)
         {
-            Contract.Requires<ArgumentNullException>(reference != null);
-            Contract.Requires<ArgumentNullException>(property != null);
-
-            _reference = reference;
-            _property = property;
+            _reference = reference ?? throw new ArgumentNullException(nameof(reference));;
+            _property = property ?? throw new ArgumentNullException(nameof(property));;
         }
 
         public AvaloniaObject Instance
@@ -77,11 +74,8 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings
 
         public InpcPropertyAccessor(WeakReference<object> reference, IPropertyInfo property)
         {
-            Contract.Requires<ArgumentNullException>(reference != null);
-            Contract.Requires<ArgumentNullException>(property != null);
-
-            _reference = reference;
-            _property = property;
+            _reference = reference ?? throw new ArgumentNullException(nameof(reference));
+            _property = property ?? throw new ArgumentNullException(nameof(property));
         }
 
         public override Type PropertyType => _property.PropertyType;

+ 3 - 3
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@@ -10,7 +10,6 @@ using Avalonia.Rendering.SceneGraph;
 using Avalonia.Rendering.Utilities;
 using Avalonia.Utilities;
 using Avalonia.Media.Imaging;
-using JetBrains.Annotations;
 using SkiaSharp;
 
 namespace Avalonia.Skia
@@ -675,13 +674,14 @@ namespace Avalonia.Skia
             }
         }
 
-        [CanBeNull]
-        public object GetFeature(Type t)
+#nullable enable
+        public object? GetFeature(Type t)
         {
             if (t == typeof(ISkiaSharpApiLeaseFeature))
                 return new SkiaLeaseFeature(this);
             return null;
         }
+#nullable restore
 
         /// <summary>
         /// Configure paint wrapper for using gradient brush.

+ 2 - 2
src/Skia/Avalonia.Skia/GlyphRunImpl.cs

@@ -1,8 +1,8 @@
 using System;
 using Avalonia.Metadata;
 using Avalonia.Platform;
-using JetBrains.Annotations;
 using SkiaSharp;
+#nullable enable
 
 namespace Avalonia.Skia
 {
@@ -10,7 +10,7 @@ namespace Avalonia.Skia
     [Unstable]
     public class GlyphRunImpl : IGlyphRunImpl
     {
-        public GlyphRunImpl([NotNull] SKTextBlob textBlob)
+        public GlyphRunImpl(SKTextBlob textBlob)
         {
             TextBlob = textBlob ?? throw new ArgumentNullException (nameof (textBlob));
         }

+ 0 - 1
src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj

@@ -17,7 +17,6 @@
   <Import Project="..\..\..\build\Rx.props" />
   <Import Project="..\..\..\build\SharpDX.props" />
   <Import Project="..\..\..\build\HarfBuzzSharp.props" />
-  <Import Project="..\..\..\build\JetBrains.Annotations.props" />
   <Import Project="..\..\..\build\DevAnalyzers.props" />
   <Import Project="..\..\..\build\TrimmingEnable.props" />
 

+ 3 - 2
src/Windows/Avalonia.Win32/Win32Platform.cs

@@ -19,11 +19,11 @@ using Avalonia.Threading;
 using Avalonia.Utilities;
 using Avalonia.Win32.Input;
 using Avalonia.Win32.Interop;
-using JetBrains.Annotations;
 using static Avalonia.Win32.Interop.UnmanagedMethods;
 
 namespace Avalonia
 {
+#nullable enable
     public static class Win32ApplicationExtensions
     {
         public static T UseWin32<T>(
@@ -106,9 +106,10 @@ namespace Avalonia
         /// <summary>
         /// Provides a way to use a custom-implemented graphics context such as a custom ISkiaGpu
         /// </summary>
-        [CanBeNull] public IPlatformGraphics CustomPlatformGraphics { get; set; }
+        public IPlatformGraphics? CustomPlatformGraphics { get; set; }
     }
 }
+#nullable restore
 
 namespace Avalonia.Win32
 {

+ 0 - 1
src/Windows/Avalonia.Win32/WindowsMountedVolumeInfoProvider.cs

@@ -8,7 +8,6 @@ namespace Avalonia.Win32
     {
         public IDisposable Listen(ObservableCollection<MountedVolumeInfo> mountedDrives)
         {
-            Contract.Requires<ArgumentNullException>(mountedDrives != null);
             return new WindowsMountedVolumeInfoListener(mountedDrives);
         }
     }

+ 0 - 1
src/iOS/Avalonia.iOS/AvaloniaView.Text.cs

@@ -1,6 +1,5 @@
 #nullable enable
 using Avalonia.Input.TextInput;
-using JetBrains.Annotations;
 using UIKit;
 
 namespace Avalonia.iOS;

+ 0 - 1
tests/Avalonia.Base.UnitTests/Rendering/CompositorTestsBase.cs

@@ -18,7 +18,6 @@ using Avalonia.Rendering.Composition;
 using Avalonia.Threading;
 using Avalonia.UnitTests;
 using Avalonia.VisualTree;
-using JetBrains.Annotations;
 using Xunit;
 
 namespace Avalonia.Base.UnitTests.Rendering;

+ 0 - 1
tests/Avalonia.Benchmarks/Data/AccessorTestObject.cs

@@ -1,6 +1,5 @@
 using System.ComponentModel;
 using System.Runtime.CompilerServices;
-using JetBrains.Annotations;
 
 namespace Avalonia.Benchmarks.Data
 {

+ 1 - 1
tests/Avalonia.Benchmarks/Utilities/AvaloniaPropertyDictionaryBenchmarks.cs

@@ -172,7 +172,7 @@ internal sealed class AvaloniaPropertyValueStoreOld<TValue>
 
 internal class MockProperty : StyledProperty<int>
 {
-    public MockProperty([JetBrains.Annotations.NotNull] string name) : base(name, typeof(object), new StyledPropertyMetadata<int>())
+    public MockProperty(string name) : base(name, typeof(object), new StyledPropertyMetadata<int>())
     {
     }
 }

+ 0 - 1
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@@ -17,7 +17,6 @@ using Avalonia.Interactivity;
 using Avalonia.LogicalTree;
 using Avalonia.Styling;
 using Avalonia.UnitTests;
-using JetBrains.Annotations;
 using Moq;
 using Xunit;
 

+ 0 - 2
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs

@@ -15,7 +15,6 @@ using Avalonia.Styling;
 using Avalonia.Threading;
 using Avalonia.UnitTests;
 using Avalonia.VisualTree;
-using JetBrains.Annotations;
 using Xunit;
 
 namespace Avalonia.Markup.Xaml.UnitTests
@@ -389,7 +388,6 @@ namespace Avalonia.Markup.Xaml.UnitTests
         public bool IsPressed { get; set; }
         public event PropertyChangedEventHandler PropertyChanged;
 
-        [NotifyPropertyChangedInvocator]
         protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));