Browse Source

Avoid "using system" because

pull/7565/head
Max Katz 4 years ago
parent
commit
34b4f970e9
  1. 2
      src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs
  2. 17
      src/iOS/Avalonia.iOS/AvaloniaView.cs
  3. 9
      src/iOS/Avalonia.iOS/ClipboardImpl.cs
  4. 5
      src/iOS/Avalonia.iOS/DisplayLinkTimer.cs
  5. 11
      src/iOS/Avalonia.iOS/EaglDisplay.cs
  6. 10
      src/iOS/Avalonia.iOS/EaglLayerSurface.cs
  7. 1
      src/iOS/Avalonia.iOS/Extensions.cs
  8. 14
      src/iOS/Avalonia.iOS/LayerFbo.cs
  9. 6
      src/iOS/Avalonia.iOS/Platform.cs
  10. 9
      src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs
  11. 5
      src/iOS/Avalonia.iOS/Stubs.cs

2
src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs

@ -12,7 +12,7 @@ namespace Avalonia.iOS
[Export("window")]
public UIWindow Window { get; set; }
[Export("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{

17
src/iOS/Avalonia.iOS/AvaloniaView.cs

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Controls.Embedding;
@ -94,14 +93,14 @@ namespace Avalonia.iOS
public Size? FrameSize => null;
public double RenderScaling => _view.ContentScaleFactor;
public IEnumerable<object> Surfaces { get; set; }
public Action<RawInputEventArgs> Input { get; set; }
public Action<Rect> Paint { get; set; }
public Action<Size, PlatformResizeReason> Resized { get; set; }
public Action<double> ScalingChanged { get; set; }
public Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; }
public Action Closed { get; set; }
public Action LostFocus { get; set; }
public System.Action<RawInputEventArgs> Input { get; set; }
public System.Action<Rect> Paint { get; set; }
public System.Action<Size, PlatformResizeReason> Resized { get; set; }
public System.Action<double> ScalingChanged { get; set; }
public System.Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; }
public System.Action Closed { get; set; }
public System.Action LostFocus { get; set; }
// legacy no-op
public IMouseDevice MouseDevice { get; } = new MouseDevice();

9
src/iOS/Avalonia.iOS/ClipboardImpl.cs

@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using Avalonia.Input;
using Avalonia.Input.Platform;
@ -25,10 +24,10 @@ namespace Avalonia.iOS
return Task.FromResult(0);
}
public Task SetDataObjectAsync(IDataObject data) => throw new PlatformNotSupportedException();
public Task SetDataObjectAsync(IDataObject data) => throw new System.PlatformNotSupportedException();
public Task<string[]> GetFormatsAsync() => throw new PlatformNotSupportedException();
public Task<string[]> GetFormatsAsync() => throw new System.PlatformNotSupportedException();
public Task<object> GetDataAsync(string format) => throw new PlatformNotSupportedException();
public Task<object> GetDataAsync(string format) => throw new System.PlatformNotSupportedException();
}
}
}

5
src/iOS/Avalonia.iOS/DisplayLinkTimer.cs

@ -1,4 +1,3 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,7 @@ namespace Avalonia.iOS
{
class DisplayLinkTimer : IRenderTimer
{
public event Action<TimeSpan> Tick;
public event System.Action<System.TimeSpan> Tick;
private Stopwatch _st = Stopwatch.StartNew();
public DisplayLinkTimer()
@ -34,4 +33,4 @@ namespace Avalonia.iOS
Tick?.Invoke(_st.Elapsed);
}
}
}
}

11
src/iOS/Avalonia.iOS/EaglDisplay.cs

@ -1,4 +1,3 @@
using System;
using System.Reactive.Disposables;
using Avalonia.OpenGL;
using OpenGLES;
@ -8,7 +7,7 @@ namespace Avalonia.iOS
class EaglFeature : IPlatformOpenGlInterface
{
public IGlContext PrimaryContext => Context;
public IGlContext CreateSharedContext() => throw new NotSupportedException();
public IGlContext CreateSharedContext() => throw new System.NotSupportedException();
public bool CanShareContexts => false;
public bool CanCreateContexts => false;
public IGlContext CreateContext() => throw new System.NotSupportedException();
@ -23,7 +22,7 @@ namespace Avalonia.iOS
{
const string path = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
var libGl = ObjCRuntime.Dlfcn.dlopen(path, 1);
if (libGl == IntPtr.Zero)
if (libGl == System.IntPtr.Zero)
throw new OpenGlException("Unable to load " + path);
GlInterface = new GlInterface(Version, proc => ObjCRuntime.Dlfcn.dlsym(libGl, proc));
Context = new EAGLContext(EAGLRenderingAPI.OpenGLES3);
@ -35,7 +34,7 @@ namespace Avalonia.iOS
Context = null;
}
class ResetContext : IDisposable
class ResetContext : System.IDisposable
{
private EAGLContext _old;
private bool _disposed;
@ -55,7 +54,7 @@ namespace Avalonia.iOS
}
}
public IDisposable MakeCurrent()
public System.IDisposable MakeCurrent()
{
var old = EAGLContext.CurrentContext;
if (!EAGLContext.SetCurrentContext(Context))
@ -63,7 +62,7 @@ namespace Avalonia.iOS
return new ResetContext(old);
}
public IDisposable EnsureCurrent()
public System.IDisposable EnsureCurrent()
{
if(EAGLContext.CurrentContext == Context)
return Disposable.Empty;

10
src/iOS/Avalonia.iOS/EaglLayerSurface.cs

@ -1,5 +1,3 @@
using System;
using System.Threading;
using Avalonia.OpenGL;
using Avalonia.OpenGL.Surfaces;
@ -19,10 +17,10 @@ namespace Avalonia.iOS
class RenderSession : IGlPlatformSurfaceRenderingSession
{
private readonly GlContext _ctx;
private readonly IDisposable _restoreContext;
private readonly System.IDisposable _restoreContext;
private readonly SizeSynchronizedLayerFbo _fbo;
public RenderSession(GlContext ctx, IDisposable restoreContext, SizeSynchronizedLayerFbo fbo)
public RenderSession(GlContext ctx, System.IDisposable restoreContext, SizeSynchronizedLayerFbo fbo)
{
_ctx = ctx;
_restoreContext = restoreContext;
@ -75,7 +73,7 @@ namespace Avalonia.iOS
static void CheckThread()
{
if (Platform.Timer.TimerThread != Thread.CurrentThread)
throw new InvalidOperationException("Invalid thread, go away");
throw new System.InvalidOperationException("Invalid thread, go away");
}
public IGlPlatformSurfaceRenderTarget CreateGlRenderTarget()
@ -86,7 +84,7 @@ namespace Avalonia.iOS
{
var fbo = new SizeSynchronizedLayerFbo(ctx.Context, ctx.GlInterface, _layer);
if (!fbo.Sync())
throw new InvalidOperationException("Unable to create render target");
throw new System.InvalidOperationException("Unable to create render target");
return new RenderTarget(ctx, fbo);
}
}

1
src/iOS/Avalonia.iOS/Extensions.cs

@ -1,4 +1,3 @@
using System;
using Avalonia.Media;
using CoreGraphics;
using UIKit;

14
src/iOS/Avalonia.iOS/LayerFbo.cs

@ -1,8 +1,12 @@
using System;
using Avalonia.OpenGL;
using CoreAnimation;
using OpenGLES;
// We can't import System because System has a type called nint on iOS and Mac Catalyst.
// As such, throughout this file System is fully qualified.
// See https://github.com/xamarin/xamarin-macios/issues/10508
// And https://github.com/dotnet/Silk.NET/blob/main/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs
namespace Avalonia.iOS
{
public class LayerFbo
@ -92,11 +96,11 @@ namespace Avalonia.iOS
_gl.DeleteRenderbuffers(1, _depthBuffer);
_gl.DeleteRenderbuffers(1, _renderbuffer);
if (_context != EAGLContext.CurrentContext)
throw new InvalidOperationException("Associated EAGLContext is not current");
throw new System.InvalidOperationException("Associated EAGLContext is not current");
}
}
class SizeSynchronizedLayerFbo : IDisposable
class SizeSynchronizedLayerFbo : System.IDisposable
{
private readonly EAGLContext _context;
private readonly GlInterface _gl;
@ -130,7 +134,7 @@ namespace Avalonia.iOS
public void Dispose()
{
if (_context != EAGLContext.CurrentContext)
throw new InvalidOperationException("Associated EAGLContext is not current");
throw new System.InvalidOperationException("Associated EAGLContext is not current");
_fbo?.Dispose();
_fbo = null;
}
@ -138,7 +142,7 @@ namespace Avalonia.iOS
public void Bind()
{
if(!Sync())
throw new InvalidOperationException("Unable to create a render target");
throw new System.InvalidOperationException("Unable to create a render target");
_fbo.Bind();
}

6
src/iOS/Avalonia.iOS/Platform.cs

@ -1,5 +1,3 @@
using System;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Platform;
@ -32,11 +30,11 @@ namespace Avalonia.iOS
public Size TouchDoubleClickSize => new Size(10, 10);
/// <inheritdoc cref="IPlatformSettings.TouchDoubleClickTime"/>
public TimeSpan TouchDoubleClickTime => TimeSpan.FromMilliseconds(500);
public System.TimeSpan TouchDoubleClickTime => System.TimeSpan.FromMilliseconds(500);
public Size DoubleClickSize => new Size(4, 4);
public TimeSpan DoubleClickTime => TouchDoubleClickTime;
public System.TimeSpan DoubleClickTime => TouchDoubleClickTime;
}
public static void Register()

9
src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs

@ -1,4 +1,3 @@
using System;
using System.Threading;
using Avalonia.Platform;
using Avalonia.Threading;
@ -13,14 +12,14 @@ namespace Avalonia.iOS
public static PlatformThreadingInterface Instance { get; } = new PlatformThreadingInterface();
public bool CurrentThreadIsLoopThread => NSThread.Current.IsMainThread;
public event Action<DispatcherPriority?> Signaled;
public event System.Action<DispatcherPriority?> Signaled;
public void RunLoop(CancellationToken cancellationToken)
{
//Mobile platforms are using external main loop
throw new NotSupportedException();
throw new System.NotSupportedException();
}
public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
public System.IDisposable StartTimer(DispatcherPriority priority, System.TimeSpan interval, System.Action tick)
=> NSTimer.CreateRepeatingScheduledTimer(interval, _ => tick());
public void Signal(DispatcherPriority prio)
@ -40,4 +39,4 @@ namespace Avalonia.iOS
});
}
}
}
}

5
src/iOS/Avalonia.iOS/Stubs.cs

@ -1,4 +1,3 @@
using System;
using System.IO;
using Avalonia.Input;
using Avalonia.Platform;
@ -18,9 +17,9 @@ namespace Avalonia.iOS
class WindowingPlatformStub : IWindowingPlatform
{
public IWindowImpl CreateWindow() => throw new NotSupportedException();
public IWindowImpl CreateWindow() => throw new System.NotSupportedException();
public IWindowImpl CreateEmbeddableWindow() => throw new NotSupportedException();
public IWindowImpl CreateEmbeddableWindow() => throw new System.NotSupportedException();
public ITrayIconImpl CreateTrayIcon() => null;
}

Loading…
Cancel
Save