From 7fa2c8495690b0af1699b87ed62cd273fbd91e59 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 31 Jul 2020 20:28:04 +0300 Subject: [PATCH 001/314] Add handling mouse events in webapp --- .../webapp/src/FramePresenter.tsx | 25 ++++++++++++- .../src/Models/Input/InputEventMessageBase.ts | 11 ++++++ .../webapp/src/Models/Input/InputModifiers.ts | 9 +++++ .../webapp/src/Models/Input/MouseButton.ts | 6 +++ .../src/Models/Input/MouseEventHelpers.ts | 37 +++++++++++++++++++ .../Models/Input/PointerEventMessageBase.ts | 13 +++++++ .../Models/Input/PointerMovedEventMessage.ts | 12 ++++++ .../Input/PointerPressedEventMessage.ts | 17 +++++++++ .../Input/PointerReleasedEventMessage.ts | 17 +++++++++ 9 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index 0059cfe683..ce43822dd8 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -1,5 +1,8 @@ -import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConnection"; import * as React from "react"; +import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConnection"; +import {PointerPressedEventMessage} from "src/Models/Input/PointerPressedEventMessage"; +import {PointerReleasedEventMessage} from "src/Models/Input/PointerReleasedEventMessage"; +import {PointerMovedEventMessage} from "src/Models/Input/PointerMovedEventMessage"; interface PreviewerPresenterProps { conn: PreviewerServerConnection; @@ -51,7 +54,25 @@ export class PreviewerPresenter extends React.Component } } + handleMouseDown(e: React.MouseEvent) { + const pointerPressedEventMessage = new PointerPressedEventMessage(e); + // TODO: Send message to server + } + + handleMouseUp(e: React.MouseEvent) { + const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); + // TODO: Send message to server + } + + handleMouseMove(e: React.MouseEvent) { + const pointerMovedEventMessage = new PointerMovedEventMessage(e); + // TODO: Send message to server + } + render() { - return + return } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts new file mode 100644 index 0000000000..2da7424e2a --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts @@ -0,0 +1,11 @@ +import * as React from "react"; +import {InputModifiers} from "src/Models/Input/InputModifiers"; +import {getModifiers} from "src/Models/Input/MouseEventHelpers"; + +export abstract class InputEventMessageBase { + public readonly modifiers : Array; + + protected constructor(e: React.MouseEvent) { + this.modifiers = getModifiers(e); + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts new file mode 100644 index 0000000000..483b4c02d0 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers.ts @@ -0,0 +1,9 @@ +export enum InputModifiers { + Alt, + Control, + Shift, + Windows, + LeftMouseButton, + RightMouseButton, + MiddleMouseButton, +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts new file mode 100644 index 0000000000..880f8fb5ce --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton.ts @@ -0,0 +1,6 @@ +export enum MouseButton { + None, + Left, + Right, + Middle, +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts new file mode 100644 index 0000000000..783bacad38 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -0,0 +1,37 @@ +import * as React from "react"; +import {InputModifiers} from "src/Models/Input/InputModifiers"; +import {MouseButton} from "src/Models/Input/MouseButton"; + +export function getModifiers(e: React.MouseEvent): Array { + + let modifiers : Array = []; + + if (e.altKey) + modifiers.push(InputModifiers.Alt); + if (e.ctrlKey) + modifiers.push(InputModifiers.Control); + if (e.shiftKey) + modifiers.push(InputModifiers.Shift); + if (e.metaKey) + modifiers.push(InputModifiers.Windows); + if ((e.buttons & 1) != 0) + modifiers.push(InputModifiers.LeftMouseButton); + if ((e.buttons & 2) != 0) + modifiers.push(InputModifiers.RightMouseButton); + if ((e.buttons & 4) != 0) + modifiers.push(InputModifiers.MiddleMouseButton); + + return modifiers; +} + +export function getMouseButton(e: React.MouseEvent) : MouseButton { + if (e.button == 1) { + return MouseButton.Left; + } else if (e.button == 2) { + return MouseButton.Right; + } else if (e.button == 4) { + return MouseButton.Middle + } else { + return MouseButton.None; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts new file mode 100644 index 0000000000..e43362ac1c --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -0,0 +1,13 @@ +import * as React from "react"; +import {InputEventMessageBase} from "src/Models/Input/InputEventMessageBase"; + +export abstract class PointerEventMessageBase extends InputEventMessageBase { + public readonly x: number; + public readonly y: number; + + protected constructor(e: React.MouseEvent) { + super(e) + this.x = e.clientX; + this.y = e.clientY; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts new file mode 100644 index 0000000000..3ca8e91b8d --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -0,0 +1,12 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; + +export class PointerMovedEventMessage extends PointerEventMessageBase { + constructor(e: React.MouseEvent) { + super(e) + } + + public toString = () : string => { + return `pointer-moved:${this.modifiers}:${this.x}:${this.y}`; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts new file mode 100644 index 0000000000..712ec64a14 --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {MouseButton} from "src/Models/Input/MouseButton"; +import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; + +export class PointerPressedEventMessage extends PointerEventMessageBase { + public readonly button: MouseButton + + constructor(e: React.MouseEvent) { + super(e) + this.button = getMouseButton(e); + } + + public toString = () : string => { + return `pointer-pressed:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + } +} diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts new file mode 100644 index 0000000000..46234263db --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {MouseButton} from "src/Models/Input/MouseButton"; +import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; + +export class PointerReleasedEventMessage extends PointerEventMessageBase { + public readonly button: MouseButton + + constructor(e: React.MouseEvent) { + super(e) + this.button = getMouseButton(e); + } + + public toString = () : string => { + return `pointer-released:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + } +} From 23d29d445c316df9718d598f5439951d2fb993c7 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sun, 9 Aug 2020 19:54:13 +0300 Subject: [PATCH 002/314] Add message sending and server processing --- .../Remote/HtmlTransport/HtmlTransport.cs | 71 +++++++++++++++++-- .../webapp/src/FramePresenter.tsx | 10 ++- .../webapp/src/PreviewerServerConnection.ts | 6 ++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 55e2df8890..eb64f83d35 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Viewport; +using InputProtocol = Avalonia.Remote.Protocol.Input; namespace Avalonia.DesignerSupport.Remote.HtmlTransport { @@ -117,10 +118,55 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport return; if (msg.IsText) { - var s = Encoding.UTF8.GetString(msg.Data); - var parts = s.Split(':'); - if (parts[0] == "frame-received") - _onMessage?.Invoke(this, new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + var parts = msg.AsString().Split(':'); + switch (parts[0]) + { + case "frame-received": + { + _onMessage?.Invoke( + this, + new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + break; + } + case "pointer-released": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + Button = ParseMouseButton(parts[2]), + X = double.Parse(parts[3]), + Y = double.Parse(parts[4]), + }); + break; + } + case "pointer-pressed": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + Button = ParseMouseButton(parts[2]), + X = double.Parse(parts[3]), + Y = double.Parse(parts[4]), + }); + break; + } + case "pointer-moved": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + }); + break; + } + } } } } @@ -262,5 +308,22 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport _onException?.Invoke(this, ex); } #endregion + + private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) + { + var enumTexts = modifiersText.Split(','); + if (string.IsNullOrEmpty(enumTexts[0])) + return new InputProtocol.InputModifiers[0]; + return enumTexts + .Select(x => (InputProtocol.InputModifiers)Enum.Parse( + typeof(InputProtocol.InputModifiers), x)) + .ToArray(); + } + + private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => + string.IsNullOrEmpty(buttonText) + ? InputProtocol.MouseButton.None + : (InputProtocol.MouseButton)Enum.Parse( + typeof(InputProtocol.MouseButton), buttonText); } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index ce43822dd8..b35e611c95 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -18,6 +18,10 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); + + this.handleMouseDown = this.handleMouseDown.bind(this); + this.handleMouseUp = this.handleMouseUp.bind(this); + this.handleMouseMove = this.handleMouseMove.bind(this); } componentDidMount(): void { @@ -56,17 +60,17 @@ export class PreviewerPresenter extends React.Component handleMouseDown(e: React.MouseEvent) { const pointerPressedEventMessage = new PointerPressedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerPressedEventMessage); } handleMouseUp(e: React.MouseEvent) { const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerReleasedEventMessage); } handleMouseMove(e: React.MouseEvent) { const pointerMovedEventMessage = new PointerMovedEventMessage(e); - // TODO: Send message to server + this.props.conn.sendMouseEvent(pointerMovedEventMessage); } render() { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts index 891c5094e7..7f1ab84f99 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/PreviewerServerConnection.ts @@ -1,3 +1,5 @@ +import { InputEventMessageBase } from "src/Models/Input/InputEventMessageBase"; + export interface PreviewerFrame { data: ImageData; dpiX: number; @@ -28,6 +30,10 @@ export class PreviewerServerConnection { this.handlers.delete(listener); } + public sendMouseEvent(message: InputEventMessageBase) { + this.conn.send(message.toString()); + } + constructor(uri: string) { this.currentFrame = null; var conn = this.conn = new WebSocket(uri); From 851c03fa70d53675edc2693ed23299ca8c407bef Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Mon, 10 Aug 2020 17:08:53 +0300 Subject: [PATCH 003/314] Add handling wheel --- .../Remote/HtmlTransport/HtmlTransport.cs | 26 ++++++++++++++----- .../webapp/src/FramePresenter.tsx | 11 +++++++- .../Models/Input/PointerEventMessageBase.ts | 2 +- .../Models/Input/PointerMovedEventMessage.ts | 2 +- .../Input/PointerPressedEventMessage.ts | 4 +-- .../Input/PointerReleasedEventMessage.ts | 4 +-- .../src/Models/Input/ScrollEventMessage.ts | 17 ++++++++++++ 7 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index eb64f83d35..c32aefe308 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -135,9 +135,9 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerReleasedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - Button = ParseMouseButton(parts[2]), - X = double.Parse(parts[3]), - Y = double.Parse(parts[4]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), }); break; } @@ -148,9 +148,9 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerPressedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - Button = ParseMouseButton(parts[2]), - X = double.Parse(parts[3]), - Y = double.Parse(parts[4]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), }); break; } @@ -166,6 +166,20 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport }); break; } + case "scroll": + { + _onMessage?.Invoke( + this, + new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + DeltaX = double.Parse(parts[4]), + DeltaY = double.Parse(parts[5]), + }); + break; + } } } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index b35e611c95..5182a087e7 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -3,6 +3,7 @@ import {PreviewerFrame, PreviewerServerConnection} from "src/PreviewerServerConn import {PointerPressedEventMessage} from "src/Models/Input/PointerPressedEventMessage"; import {PointerReleasedEventMessage} from "src/Models/Input/PointerReleasedEventMessage"; import {PointerMovedEventMessage} from "src/Models/Input/PointerMovedEventMessage"; +import {ScrollEventMessage} from "src/Models/Input/ScrollEventMessage"; interface PreviewerPresenterProps { conn: PreviewerServerConnection; @@ -22,6 +23,7 @@ export class PreviewerPresenter extends React.Component this.handleMouseDown = this.handleMouseDown.bind(this); this.handleMouseUp = this.handleMouseUp.bind(this); this.handleMouseMove = this.handleMouseMove.bind(this); + this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -73,10 +75,17 @@ export class PreviewerPresenter extends React.Component this.props.conn.sendMouseEvent(pointerMovedEventMessage); } + handleWheel(e: React.WheelEvent) { + e.preventDefault(); + const scrollEventMessage = new ScrollEventMessage(e); + this.props.conn.sendMouseEvent(scrollEventMessage); + } + render() { return + onMouseMove={this.handleMouseMove} + onWheel={this.handleWheel} /> } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts index e43362ac1c..fc304c2965 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -6,7 +6,7 @@ export abstract class PointerEventMessageBase extends InputEventMessageBase { public readonly y: number; protected constructor(e: React.MouseEvent) { - super(e) + super(e); this.x = e.clientX; this.y = e.clientY; } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts index 3ca8e91b8d..cd135dfa39 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -3,7 +3,7 @@ import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase" export class PointerMovedEventMessage extends PointerEventMessageBase { constructor(e: React.MouseEvent) { - super(e) + super(e); } public toString = () : string => { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts index 712ec64a14..e75551e0b3 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -7,11 +7,11 @@ export class PointerPressedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton constructor(e: React.MouseEvent) { - super(e) + super(e); this.button = getMouseButton(e); } public toString = () : string => { - return `pointer-pressed:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + return `pointer-pressed:${this.modifiers}:${this.x}:${this.y}:${this.button}`; } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts index 46234263db..c2bc368323 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -7,11 +7,11 @@ export class PointerReleasedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton constructor(e: React.MouseEvent) { - super(e) + super(e); this.button = getMouseButton(e); } public toString = () : string => { - return `pointer-released:${this.modifiers}:${this.button}:${this.x}:${this.y}`; + return `pointer-released:${this.modifiers}:${this.x}:${this.y}:${this.button}`; } } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts new file mode 100644 index 0000000000..427ccc5e5e --- /dev/null +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts @@ -0,0 +1,17 @@ +import * as React from "react"; +import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; + +export class ScrollEventMessage extends PointerEventMessageBase { + public readonly deltaX: number; + public readonly deltaY: number; + + constructor(e: React.WheelEvent) { + super(e); + this.deltaX = -e.deltaX; + this.deltaY = -e.deltaY; + } + + public toString = () : string => { + return `scroll:${this.modifiers}:${this.x}:${this.y}:${this.deltaX}:${this.deltaY}`; + } +} From 27f289e2bffb3ad0ecbc00eb0b327e41c14d520c Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Mon, 10 Aug 2020 23:21:59 +0300 Subject: [PATCH 004/314] Refactor --- .../Remote/HtmlTransport/HtmlTransport.cs | 141 +++++++++--------- .../webapp/src/FramePresenter.tsx | 13 +- 2 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index c32aefe308..51d266f11a 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -118,69 +118,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport return; if (msg.IsText) { - var parts = msg.AsString().Split(':'); - switch (parts[0]) - { - case "frame-received": - { - _onMessage?.Invoke( - this, - new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); - break; - } - case "pointer-released": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; - } - case "pointer-pressed": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; - } - case "pointer-moved": - { - _onMessage?.Invoke( - this, - new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - }); - break; - } - case "scroll": - { - _onMessage?.Invoke( - this, - new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - DeltaX = double.Parse(parts[4]), - DeltaY = double.Parse(parts[5]), - }); - break; - } - } + ProcessingReceiveMessage(msg.AsString()); } } } @@ -323,16 +261,81 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } #endregion - private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) + private void ProcessingReceiveMessage(string message) { - var enumTexts = modifiersText.Split(','); - if (string.IsNullOrEmpty(enumTexts[0])) - return new InputProtocol.InputModifiers[0]; - return enumTexts + var parts = message.Split(':'); + switch (parts[0]) + { + case "frame-received": + { + _onMessage?.Invoke( + this, + new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); + break; + } + case "pointer-released": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), + }); + break; + } + case "pointer-pressed": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + Button = ParseMouseButton(parts[4]), + }); + break; + } + case "pointer-moved": + { + _onMessage?.Invoke( + this, + new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + }); + break; + } + case "scroll": + { + _onMessage?.Invoke( + this, + new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = double.Parse(parts[2]), + Y = double.Parse(parts[3]), + DeltaX = double.Parse(parts[4]), + DeltaY = double.Parse(parts[5]), + }); + break; + } + } + } + + private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => + string.IsNullOrEmpty(modifiersText) + ? new InputProtocol.InputModifiers[0] + : modifiersText + .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( typeof(InputProtocol.InputModifiers), x)) .ToArray(); - } private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => string.IsNullOrEmpty(buttonText) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index 5182a087e7..ec8a1bab68 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -19,11 +19,6 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); - - this.handleMouseDown = this.handleMouseDown.bind(this); - this.handleMouseUp = this.handleMouseUp.bind(this); - this.handleMouseMove = this.handleMouseMove.bind(this); - this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -83,9 +78,9 @@ export class PreviewerPresenter extends React.Component render() { return + onMouseDown={this.handleMouseDown.bind(this)} + onMouseUp={this.handleMouseUp.bind(this)} + onMouseMove={this.handleMouseMove.bind(this)} + onWheel={this.handleWheel.bind(this)} /> } } From 162d6f8cedf4f06e49846bd6f182e86af5d5f27e Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 00:29:33 +0300 Subject: [PATCH 005/314] Return null instead of empty array --- .../Remote/HtmlTransport/HtmlTransport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 51d266f11a..361d35c0b7 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -330,7 +330,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => string.IsNullOrEmpty(modifiersText) - ? new InputProtocol.InputModifiers[0] + ? null : modifiersText .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( From f3718a5d034ab710e8416f9b76883f4f154c2a1b Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 01:52:33 +0300 Subject: [PATCH 006/314] revert bind and preventdefault --- .../HtmlTransport/webapp/src/FramePresenter.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx index ec8a1bab68..96d2f45fdc 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/FramePresenter.tsx @@ -19,6 +19,11 @@ export class PreviewerPresenter extends React.Component this.componentDidUpdate({ conn: null! }, this.state); + + this.handleMouseDown = this.handleMouseDown.bind(this); + this.handleMouseUp = this.handleMouseUp.bind(this); + this.handleMouseMove = this.handleMouseMove.bind(this); + this.handleWheel = this.handleWheel.bind(this); } componentDidMount(): void { @@ -56,16 +61,19 @@ export class PreviewerPresenter extends React.Component } handleMouseDown(e: React.MouseEvent) { + e.preventDefault(); const pointerPressedEventMessage = new PointerPressedEventMessage(e); this.props.conn.sendMouseEvent(pointerPressedEventMessage); } handleMouseUp(e: React.MouseEvent) { + e.preventDefault(); const pointerReleasedEventMessage = new PointerReleasedEventMessage(e); this.props.conn.sendMouseEvent(pointerReleasedEventMessage); } handleMouseMove(e: React.MouseEvent) { + e.preventDefault(); const pointerMovedEventMessage = new PointerMovedEventMessage(e); this.props.conn.sendMouseEvent(pointerMovedEventMessage); } @@ -78,9 +86,9 @@ export class PreviewerPresenter extends React.Component render() { return + onMouseDown={this.handleMouseDown} + onMouseUp={this.handleMouseUp} + onMouseMove={this.handleMouseMove} + onWheel={this.handleWheel} /> } } From 1cfa116cc325461c041c2ed2c17a367a2f759795 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 11 Aug 2020 14:46:54 +0300 Subject: [PATCH 007/314] Fix typo in detect mouse button --- .../webapp/src/Models/Input/MouseEventHelpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts index 783bacad38..3f85959d6f 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -25,12 +25,12 @@ export function getModifiers(e: React.MouseEvent): Array { } export function getMouseButton(e: React.MouseEvent) : MouseButton { - if (e.button == 1) { + if (e.button == 0) { return MouseButton.Left; + } else if (e.button == 1) { + return MouseButton.Middle; } else if (e.button == 2) { return MouseButton.Right; - } else if (e.button == 4) { - return MouseButton.Middle } else { return MouseButton.None; } From 138404de4e0706b9e3dc4ba50b5ce296540745b3 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 29 Aug 2020 14:21:32 +0300 Subject: [PATCH 008/314] Fix double parse with InvariantCulture --- .../Remote/HtmlTransport/HtmlTransport.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 361d35c0b7..5946e2681c 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; @@ -280,8 +281,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerReleasedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), Button = ParseMouseButton(parts[4]), }); break; @@ -293,8 +294,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerPressedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), Button = ParseMouseButton(parts[4]), }); break; @@ -306,8 +307,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.PointerMovedEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), }); break; } @@ -318,10 +319,10 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport new InputProtocol.ScrollEventMessage { Modifiers = ParseInputModifiers(parts[1]), - X = double.Parse(parts[2]), - Y = double.Parse(parts[3]), - DeltaX = double.Parse(parts[4]), - DeltaY = double.Parse(parts[5]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), }); break; } @@ -334,13 +335,16 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport : modifiersText .Split(',') .Select(x => (InputProtocol.InputModifiers)Enum.Parse( - typeof(InputProtocol.InputModifiers), x)) + typeof(InputProtocol.InputModifiers), x, true)) .ToArray(); private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => string.IsNullOrEmpty(buttonText) ? InputProtocol.MouseButton.None : (InputProtocol.MouseButton)Enum.Parse( - typeof(InputProtocol.MouseButton), buttonText); + typeof(InputProtocol.MouseButton), buttonText, true); + + private static double ParseDouble(string text) => + double.Parse(text, CultureInfo.InvariantCulture); } } From 26ae25d28dee5bd278da14c3a51800b8628d6037 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 29 Aug 2020 14:35:05 +0300 Subject: [PATCH 009/314] Refactor parsing message --- .../Remote/HtmlTransport/HtmlTransport.cs | 88 ++++++++----------- 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 5946e2681c..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -115,11 +115,11 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport while (true) { var msg = await socket.ReceiveMessage().ConfigureAwait(false); - if(msg == null) - return; - if (msg.IsText) + if(msg != null && msg.IsText) { - ProcessingReceiveMessage(msg.AsString()); + var message = ParseMessage(msg.AsString()); + if (message != null) + _onMessage?.Invoke(this, message); } } } @@ -178,7 +178,6 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport _pendingSocket?.Dispose(); _simpleServer.Dispose(); } - public Task Send(object data) { @@ -262,70 +261,57 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } #endregion - private void ProcessingReceiveMessage(string message) + private static object ParseMessage(string message) { var parts = message.Split(':'); switch (parts[0]) { case "frame-received": { - _onMessage?.Invoke( - this, - new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }); - break; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } case "pointer-released": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; } case "pointer-pressed": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }); - break; + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; } case "pointer-moved": { - _onMessage?.Invoke( - this, - new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }); - break; + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; } case "scroll": { - _onMessage?.Invoke( - this, - new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }); - break; + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; } + default: + return null; } } @@ -345,6 +331,6 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport typeof(InputProtocol.MouseButton), buttonText, true); private static double ParseDouble(string text) => - double.Parse(text, CultureInfo.InvariantCulture); + double.Parse(text, NumberStyles.Float, CultureInfo.InvariantCulture); } } From cf42bc3bd0899545149d947127a1fa0bef8c97d9 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:12:44 +0300 Subject: [PATCH 010/314] Fix comparing strings with InvariantCultureIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..1d7fd91756 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,55 +264,53 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0]; + if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) { - case "frame-received": - { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - case "pointer-released": - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-pressed": - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-moved": - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - case "scroll": - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; - } - default: - return null; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } + else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + + return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From 4df6d86e0321f712177937ed5f7d82224f91c685 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:24:23 +0300 Subject: [PATCH 011/314] Revert "Fix comparing strings with InvariantCultureIgnoreCase" This reverts commit cf42bc3bd0899545149d947127a1fa0bef8c97d9. --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 1d7fd91756..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,53 +264,55 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - var key = parts[0]; - if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) + switch (parts[0]) { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; + case "frame-received": + { + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; + } + case "pointer-released": + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + case "pointer-pressed": + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + case "pointer-moved": + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + case "scroll": + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + default: + return null; } - - return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From c019f3a3f9ca84850aa24de75d111da7d87acf5a Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:27:30 +0300 Subject: [PATCH 012/314] Fix API key to lower invariant --- .../Remote/HtmlTransport/HtmlTransport.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..920f155cfd 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,7 +264,8 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0].ToLowerInvariant(); + switch (key) { case "frame-received": { From fe1a847847df1179201709db1a11d35e09abc54a Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:42:50 +0300 Subject: [PATCH 013/314] Revert "Fix API key to lower invariant" This reverts commit c019f3a3f9ca84850aa24de75d111da7d87acf5a. --- .../Remote/HtmlTransport/HtmlTransport.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 920f155cfd..ded9ad6b11 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,8 +264,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - var key = parts[0].ToLowerInvariant(); - switch (key) + switch (parts[0]) { case "frame-received": { From 5f4f52f78d4075731f878526632a30ffbd664c68 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Tue, 1 Sep 2020 09:43:43 +0300 Subject: [PATCH 014/314] Fix comparing strings with InvariantCultureIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index ded9ad6b11..1d7fd91756 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -264,55 +264,53 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport private static object ParseMessage(string message) { var parts = message.Split(':'); - switch (parts[0]) + var key = parts[0]; + if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) { - case "frame-received": - { - return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; - } - case "pointer-released": - { - return new InputProtocol.PointerReleasedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-pressed": - { - return new InputProtocol.PointerPressedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - Button = ParseMouseButton(parts[4]), - }; - } - case "pointer-moved": - { - return new InputProtocol.PointerMovedEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - }; - } - case "scroll": - { - return new InputProtocol.ScrollEventMessage - { - Modifiers = ParseInputModifiers(parts[1]), - X = ParseDouble(parts[2]), - Y = ParseDouble(parts[3]), - DeltaX = ParseDouble(parts[4]), - DeltaY = ParseDouble(parts[5]), - }; - } - default: - return null; + return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } + else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerReleasedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerPressedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + Button = ParseMouseButton(parts[4]), + }; + } + else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.PointerMovedEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + }; + } + else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + { + return new InputProtocol.ScrollEventMessage + { + Modifiers = ParseInputModifiers(parts[1]), + X = ParseDouble(parts[2]), + Y = ParseDouble(parts[3]), + DeltaX = ParseDouble(parts[4]), + DeltaY = ParseDouble(parts[5]), + }; + } + + return null; } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => From 1025b1240247793e19415e797100882952dc4043 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 00:27:05 +0500 Subject: [PATCH 015/314] Add tests --- .editorconfig | 3 + .../src/Models/Input/InputEventMessageBase.ts | 4 +- .../src/Models/Input/MouseEventHelpers.ts | 18 +- .../Models/Input/PointerEventMessageBase.ts | 2 +- .../Models/Input/PointerMovedEventMessage.ts | 2 +- .../Input/PointerPressedEventMessage.ts | 6 +- .../Input/PointerReleasedEventMessage.ts | 6 +- .../src/Models/Input/ScrollEventMessage.ts | 2 +- .../Remote/HtmlTransport/webapp/.gitignore | 2 + .../webapp/Models/InputEventTests.ts | 73 + .../HtmlTransport/webapp/package-lock.json | 2414 +++++++++++++++++ .../Remote/HtmlTransport/webapp/package.json | 26 + .../Remote/HtmlTransport/webapp/tsconfig.json | 12 + 13 files changed, 2551 insertions(+), 19 deletions(-) create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json create mode 100644 tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json diff --git a/.editorconfig b/.editorconfig index f6bce9cb76..c7a381b730 100644 --- a/.editorconfig +++ b/.editorconfig @@ -156,6 +156,9 @@ indent_size = 2 [*.{props,targets,config,nuspec}] indent_size = 2 +[*.json] +indent_size = 2 + # Shell scripts [*.sh] end_of_line = lf diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts index 2da7424e2a..bfe5aad093 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputEventMessageBase.ts @@ -1,6 +1,6 @@ import * as React from "react"; -import {InputModifiers} from "src/Models/Input/InputModifiers"; -import {getModifiers} from "src/Models/Input/MouseEventHelpers"; +import {InputModifiers} from "./InputModifiers"; +import {getModifiers} from "./MouseEventHelpers"; export abstract class InputEventMessageBase { public readonly modifiers : Array; diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts index 3f85959d6f..f2cd1f4d46 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers.ts @@ -1,6 +1,6 @@ import * as React from "react"; -import {InputModifiers} from "src/Models/Input/InputModifiers"; -import {MouseButton} from "src/Models/Input/MouseButton"; +import {InputModifiers} from "./InputModifiers"; +import {MouseButton} from "./MouseButton"; export function getModifiers(e: React.MouseEvent): Array { @@ -14,12 +14,14 @@ export function getModifiers(e: React.MouseEvent): Array { modifiers.push(InputModifiers.Shift); if (e.metaKey) modifiers.push(InputModifiers.Windows); - if ((e.buttons & 1) != 0) - modifiers.push(InputModifiers.LeftMouseButton); - if ((e.buttons & 2) != 0) - modifiers.push(InputModifiers.RightMouseButton); - if ((e.buttons & 4) != 0) - modifiers.push(InputModifiers.MiddleMouseButton); + if (e.buttons != 0) { + if ((e.buttons & 1) != 0) + modifiers.push(InputModifiers.LeftMouseButton); + if ((e.buttons & 2) != 0) + modifiers.push(InputModifiers.RightMouseButton); + if ((e.buttons & 4) != 0) + modifiers.push(InputModifiers.MiddleMouseButton); + } return modifiers; } diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts index fc304c2965..c9de132ff4 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerEventMessageBase.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {InputEventMessageBase} from "src/Models/Input/InputEventMessageBase"; +import {InputEventMessageBase} from "./InputEventMessageBase"; export abstract class PointerEventMessageBase extends InputEventMessageBase { public readonly x: number; diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts index cd135dfa39..3f782d1d46 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; export class PointerMovedEventMessage extends PointerEventMessageBase { constructor(e: React.MouseEvent) { diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts index e75551e0b3..0ae06cc064 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage.ts @@ -1,7 +1,7 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; -import {MouseButton} from "src/Models/Input/MouseButton"; -import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; +import {MouseButton} from "./MouseButton"; +import {getMouseButton} from "./MouseEventHelpers"; export class PointerPressedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts index c2bc368323..fb1477b554 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage.ts @@ -1,7 +1,7 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; -import {MouseButton} from "src/Models/Input/MouseButton"; -import {getMouseButton} from "src/Models/Input/MouseEventHelpers"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; +import {MouseButton} from "./MouseButton"; +import {getMouseButton} from "./MouseEventHelpers"; export class PointerReleasedEventMessage extends PointerEventMessageBase { public readonly button: MouseButton diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts index 427ccc5e5e..b11be19d82 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import {PointerEventMessageBase} from "src/Models/Input/PointerEventMessageBase"; +import {PointerEventMessageBase} from "./PointerEventMessageBase"; export class ScrollEventMessage extends PointerEventMessageBase { public readonly deltaX: number; diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore new file mode 100644 index 0000000000..e3fbd98336 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore @@ -0,0 +1,2 @@ +build +node_modules diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts new file mode 100644 index 0000000000..061bb74be7 --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts @@ -0,0 +1,73 @@ +import {describe} from 'mocha'; +import {expect} from 'chai'; +import {Mock} from "moq.ts"; +import {MouseEvent, WheelEvent} from "react"; +import {InputModifiers} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; +import {MouseButton} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; +import {PointerMovedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; +import {PointerPressedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; +import {PointerReleasedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; +import {ScrollEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; + +const x = .3 +const y = .42 +const modifiers = [ + InputModifiers.Alt, + InputModifiers.Control, + InputModifiers.Shift, + InputModifiers.Windows, + InputModifiers.LeftMouseButton, + InputModifiers.RightMouseButton, + InputModifiers.MiddleMouseButton +] + +const button = MouseButton.Left + +const deltaX = -3. +const deltaY = -3. + +const mouseEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.button).returns(0) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .object() + +const wheelEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .setup(x => x.deltaX).returns(-deltaX) + .setup(x => x.deltaY).returns(-deltaY) + .object() + +describe("Input event tests", () => { + it("PointerMovedEventMessage", () => { + const message = new PointerMovedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-moved:${modifiers}:${x}:${y}`) + }) + it("PointerPressedEventMessage", () => { + const message = new PointerPressedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) + }) + it("PointerReleasedEventMessage", () => { + const message = new PointerReleasedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) + }) + it("ScrollEventMessage", () => { + const message = new ScrollEventMessage(wheelEvent) + expect(message.toString()) + .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + }) +}) diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json new file mode 100644 index 0000000000..eb707cb73f --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package-lock.json @@ -0,0 +1,2414 @@ +{ + "name": "simple-test", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, + "@babel/core": { + "version": "7.11.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.6.tgz", + "integrity": "sha512-Wpcv03AGnmkgm6uS6k8iwhIwTrcP0m17TL1n1sy7qD0qelDu4XNeW0dN0mHfa+Gei211yDaLoEe/VlbXQzM4Bg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.11.6", + "@babel/helper-module-transforms": "^7.11.0", + "@babel/helpers": "^7.10.4", + "@babel/parser": "^7.11.5", + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.11.5", + "@babel/types": "^7.11.5", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", + "json5": "^2.1.2", + "lodash": "^4.17.19", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.11.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.6.tgz", + "integrity": "sha512-DWtQ1PV3r+cLbySoHrwn9RWEgKMBLLma4OBQloPRyDYvc5msJM9kvTLo1YnlJd1P/ZuKbdli3ijr5q3FvAF3uA==", + "dev": true, + "requires": { + "@babel/types": "^7.11.5", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz", + "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.4", + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz", + "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.11.0.tgz", + "integrity": "sha512-JbFlKHFntRV5qKw3YC0CvQnDZ4XMwgzzBbld7Ly4Mj4cbFy3KywcR8NtNctRToMWJOVvLINJv525Gd6wwVEx/Q==", + "dev": true, + "requires": { + "@babel/types": "^7.11.0" + } + }, + "@babel/helper-module-imports": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz", + "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-module-transforms": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.11.0.tgz", + "integrity": "sha512-02EVu8COMuTRO1TAzdMtpBPbe6aQ1w/8fePD2YgQmxZU4gpNWaL9gK3Jp7dxlkUlUCJOTaSeA+Hrm1BRQwqIhg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.10.4", + "@babel/helper-replace-supers": "^7.10.4", + "@babel/helper-simple-access": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.11.0", + "@babel/template": "^7.10.4", + "@babel/types": "^7.11.0", + "lodash": "^4.17.19" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz", + "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-replace-supers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz", + "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.10.4", + "@babel/helper-optimise-call-expression": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-simple-access": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz", + "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz", + "integrity": "sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg==", + "dev": true, + "requires": { + "@babel/types": "^7.11.0" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", + "dev": true + }, + "@babel/helpers": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz", + "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==", + "dev": true, + "requires": { + "@babel/template": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/highlight": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@babel/parser": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.5.tgz", + "integrity": "sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==", + "dev": true + }, + "@babel/template": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz", + "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/parser": "^7.10.4", + "@babel/types": "^7.10.4" + } + }, + "@babel/traverse": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.11.5.tgz", + "integrity": "sha512-EjiPXt+r7LiCZXEfRpSJd+jUMnBd4/9OUv7Nx3+0u9+eimMwJmG0Q98lw4/289JCoxSE8OolDMNZaaF/JZ69WQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "@babel/generator": "^7.11.5", + "@babel/helper-function-name": "^7.10.4", + "@babel/helper-split-export-declaration": "^7.11.0", + "@babel/parser": "^7.11.5", + "@babel/types": "^7.11.5", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.19" + } + }, + "@babel/types": { + "version": "7.11.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.11.5.tgz", + "integrity": "sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "lodash": "^4.17.19", + "to-fast-properties": "^2.0.0" + } + }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", + "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", + "dev": true + }, + "@types/chai": { + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.12.tgz", + "integrity": "sha512-aN5IAC8QNtSUdQzxu7lGBgYAOuU1tmRU4c9dIq5OKGf/SBVjXo+ffM2wEjudAWbgpOhy60nLoAGH1xm8fpCKFQ==", + "dev": true + }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, + "@types/mocha": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.3.tgz", + "integrity": "sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg==", + "dev": true + }, + "@types/prop-types": { + "version": "15.7.3", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", + "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==", + "dev": true + }, + "@types/react": { + "version": "16.9.49", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.49.tgz", + "integrity": "sha512-DtLFjSj0OYAdVLBbyjhuV9CdGVHCkHn2R+xr3XkBvK2rS1Y1tkc14XSGjYgm5Fjjr90AxH9tiSzc1pCFMGO06g==", + "dev": true, + "requires": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, + "aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "requires": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "requires": { + "default-require-extensions": "^3.0.0" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "array.prototype.map": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array.prototype.map/-/array.prototype.map-1.0.2.tgz", + "integrity": "sha512-Az3OYxgsa1g7xDYp86l0nnN4bcmuEITGe1rbdEBVkrqkzMgDcbdQ2R7r41pNzti+4NMces3H8gMmuioZUilLgw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "es-array-method-boxes-properly": "^1.0.0", + "is-string": "^1.0.4" + } + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "binary-extensions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", + "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "requires": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "chokidar": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz", + "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.4.0" + } + }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "csstype": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.3.tgz", + "integrity": "sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "default-require-extensions": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", + "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", + "dev": true, + "requires": { + "strip-bom": "^4.0.0" + } + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-array-method-boxes-properly": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", + "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", + "dev": true + }, + "es-get-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz", + "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==", + "dev": true, + "requires": { + "es-abstract": "^1.17.4", + "has-symbols": "^1.0.1", + "is-arguments": "^1.0.4", + "is-map": "^2.0.1", + "is-set": "^2.0.1", + "is-string": "^1.0.5", + "isarray": "^2.0.5" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-cache-dir": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, + "foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + } + }, + "fromentries": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.2.1.tgz", + "integrity": "sha512-Xu2Qh8yqYuDhQGOhD5iJGninErSfI9A3FrriD3tjUgV5VbJFeH8vfgZ9HnC6jWN80QDVNQK5vmxRAmEAp7Mevw==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gensync": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", + "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "hasha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.0.tgz", + "integrity": "sha512-2W+jKdQbAdSIrggA8Q35Br8qKadTrqCTC8+XZvBWepKDK6m9XkX6Iz1a2yh2KP01kzAR/dpuMeUnocoLYDcskw==", + "dev": true, + "requires": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true + }, + "is-callable": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz", + "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==", + "dev": true + }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz", + "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-set": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz", + "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==", + "dev": true + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "requires": { + "append-transform": "^2.0.0" + } + }, + "istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + } + }, + "istanbul-lib-processinfo": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", + "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.0", + "istanbul-lib-coverage": "^3.0.0-alpha.1", + "make-dir": "^3.0.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^3.3.3" + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", + "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "iterate-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.1.tgz", + "integrity": "sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw==", + "dev": true + }, + "iterate-value": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/iterate-value/-/iterate-value-1.0.2.tgz", + "integrity": "sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==", + "dev": true, + "requires": { + "es-get-iterator": "^1.0.2", + "iterate-iterator": "^1.0.1" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "dev": true + }, + "log-symbols": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "dev": true, + "requires": { + "chalk": "^4.0.0" + } + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mocha": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.1.3.tgz", + "integrity": "sha512-ZbaYib4hT4PpF4bdSO2DohooKXIn4lDeiYqB+vTmCdr6l2woW0b6H3pf5x4sM5nwQMru9RvjjHYWVGltR50ZBw==", + "dev": true, + "requires": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.4.2", + "debug": "4.1.1", + "diff": "4.0.2", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.6", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.14.0", + "log-symbols": "4.0.0", + "minimatch": "3.0.4", + "ms": "2.1.2", + "object.assign": "4.1.0", + "promise.allsettled": "1.0.2", + "serialize-javascript": "4.0.0", + "strip-json-comments": "3.0.1", + "supports-color": "7.1.0", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.0.0", + "yargs": "13.3.2", + "yargs-parser": "13.1.2", + "yargs-unparser": "1.6.1" + } + }, + "moq.ts": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/moq.ts/-/moq.ts-6.4.0.tgz", + "integrity": "sha512-g9siyKOvYGVhfDCl9mpLptch93egRC3yXIbPLssxukOROl368XBB+6M7YjLTkjVRHbKbpJBD6P7od+Ky/0xWIw==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "requires": { + "process-on-spawn": "^1.0.0" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "nyc": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", + "integrity": "sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==", + "dev": true, + "requires": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^2.0.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^4.0.0", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-inspect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz", + "integrity": "sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } + } + }, + "process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dev": true, + "requires": { + "fromentries": "^1.2.0" + } + }, + "promise.allsettled": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", + "integrity": "sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg==", + "dev": true, + "requires": { + "array.prototype.map": "^1.0.1", + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "iterate-value": "^1.0.0" + } + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "react": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", + "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2" + } + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "readdirp": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", + "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "dev": true, + "requires": { + "es6-error": "^4.0.1" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "requires": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "ts-node": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz", + "integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", + "dev": true + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "typescript": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz", + "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==", + "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "workerpool": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz", + "integrity": "sha512-fU2OcNA/GVAJLLyKUoHkAgIhKb0JoCpSjLC/G2vYKxUjVmQwGbRVeoPJ1a8U4pnVofz4AQV5Y/NEw8oKqxEBtA==", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.1.tgz", + "integrity": "sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "decamelize": "^1.2.0", + "flat": "^4.1.0", + "is-plain-obj": "^1.1.0", + "yargs": "^14.2.3" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "yargs": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz", + "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.1" + } + }, + "yargs-parser": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz", + "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json new file mode 100644 index 0000000000..dbb12e192a --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/package.json @@ -0,0 +1,26 @@ +{ + "name": "simple-test", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "mocha -r ts-node/register ./**/*Tests.ts", + "coverage": "nyc -r text -e .ts -x \"./*Tests.ts\" npm run test" + }, + "type": "module", + "keywords": [], + "author": "", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "@types/chai": "4.2.12", + "@types/mocha": "8.0.3", + "@types/react": "^16.3.14", + "chai": "^4.2.0", + "mocha": "^8.1.3", + "moq.ts": "^6.4.0", + "nyc": "^15.1.0", + "react": "^16.3.2", + "ts-node": "^9.0.0", + "typescript": "^4.0.2" + } +} diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json new file mode 100644 index 0000000000..fdb82879fc --- /dev/null +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "sourceMap": true, + "strict": true, + "esModuleInterop": true + }, + "exclude": [ + "node_modules" + ] +} From a52464ebb9b31c1e03e89b0c39705f5c942e61d7 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 20:19:58 +0500 Subject: [PATCH 016/314] Add html previewer tests to nuke --- build.ps1 | 4 ++-- nukebuild/Build.cs | 16 ++++++++++++++++ nukebuild/BuildParameters.cs | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 57e2f80075..98a9c9afee 100644 --- a/build.ps1 +++ b/build.ps1 @@ -43,7 +43,7 @@ if (Test-Path $DotNetGlobalFile) { } # If dotnet is installed locally, and expected version is not set or installation matches the expected version -if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and ` +if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { $env:DOTNET_EXE = (Get-Command "dotnet").Path } @@ -53,7 +53,7 @@ else { # Download install script $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - md -force $TempDirectory > $null + mkdir -force $TempDirectory > $null (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) # Install by channel or version diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index 24398accbb..c56703f9cc 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -223,6 +223,21 @@ partial class Build : NukeBuild } } + Target RunHtmlPreviewerTests => _ => _ + .DependsOn(CompileHtmlPreviewer) + .OnlyWhenStatic(() => !(Parameters.SkipPreviewer || Parameters.SkipTests)) + .Executes(() => + { + var webappTestDir = RootDirectory / "tests" / "Avalonia.DesignerSupport.Tests" / "Remote" / "HtmlTransport" / "webapp"; + + NpmTasks.NpmInstall(c => c + .SetWorkingDirectory(webappTestDir) + .SetArgumentConfigurator(a => a.Add("--silent"))); + NpmTasks.NpmRun(c => c + .SetWorkingDirectory(webappTestDir) + .SetCommand("test")); + }); + Target RunCoreLibsTests => _ => _ .OnlyWhenStatic(() => !Parameters.SkipTests) .DependsOn(Compile) @@ -323,6 +338,7 @@ partial class Build : NukeBuild .DependsOn(RunCoreLibsTests) .DependsOn(RunRenderTests) .DependsOn(RunDesignerTests) + .DependsOn(RunHtmlPreviewerTests) .DependsOn(RunLeakTests); Target Package => _ => _ diff --git a/nukebuild/BuildParameters.cs b/nukebuild/BuildParameters.cs index a167e9d892..c76019d9eb 100644 --- a/nukebuild/BuildParameters.cs +++ b/nukebuild/BuildParameters.cs @@ -62,7 +62,7 @@ public partial class Build public AbsolutePath ZipTargetControlCatalogDesktopDir { get; } - public BuildParameters(Build b) + public BuildParameters(Build b) { // ARGUMENTS Configuration = b.Configuration ?? "Release"; From 8fd50dd15aa569b2f41583a64c690d0233d3d237 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 20:49:27 +0500 Subject: [PATCH 017/314] Add some tests --- .../Remote/HtmlTransport/webapp/.gitignore | 1 + .../webapp/Models/InputEventTests.ts | 151 ++++++++++-------- 2 files changed, 87 insertions(+), 65 deletions(-) diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore index e3fbd98336..dc33b94747 100644 --- a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/.gitignore @@ -1,2 +1,3 @@ build node_modules +.nyc_output \ No newline at end of file diff --git a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts index 061bb74be7..e96c4d4731 100644 --- a/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts +++ b/tests/Avalonia.DesignerSupport.Tests/Remote/HtmlTransport/webapp/Models/InputEventTests.ts @@ -1,73 +1,94 @@ -import {describe} from 'mocha'; -import {expect} from 'chai'; -import {Mock} from "moq.ts"; -import {MouseEvent, WheelEvent} from "react"; -import {InputModifiers} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; -import {MouseButton} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; -import {PointerMovedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; -import {PointerPressedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; -import {PointerReleasedEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; -import {ScrollEventMessage} from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; +import { describe } from 'mocha'; +import { expect } from 'chai'; +import { Mock } from "moq.ts"; +import { MouseEvent, WheelEvent } from "react"; +import { InputModifiers } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/InputModifiers"; +import { MouseButton } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseButton"; +import { PointerMovedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerMovedEventMessage"; +import { PointerPressedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerPressedEventMessage"; +import { PointerReleasedEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/PointerReleasedEventMessage"; +import { ScrollEventMessage } from "../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/ScrollEventMessage"; +import { getModifiers, getMouseButton } from '../../../../../../src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/src/Models/Input/MouseEventHelpers'; -const x = .3 -const y = .42 -const modifiers = [ - InputModifiers.Alt, - InputModifiers.Control, - InputModifiers.Shift, - InputModifiers.Windows, - InputModifiers.LeftMouseButton, - InputModifiers.RightMouseButton, - InputModifiers.MiddleMouseButton -] +describe("Input event tests", () => { + describe("Helpers", () => { + it("getModifiers", () => { + const event = new Mock() + .setup(x => x.altKey).returns(false) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(false) + .setup(x => x.metaKey).returns(false) + .setup(x => x.buttons).returns(1) + .object() + var actual = getModifiers(event) -const button = MouseButton.Left + expect(actual) + .eql([InputModifiers.Control, InputModifiers.LeftMouseButton]) + }) + it("getMouseButton", () => { + const event = new Mock() + .setup(x => x.button).returns(1) + .object() + var actual = getMouseButton(event) -const deltaX = -3. -const deltaY = -3. + expect(actual) + .equal(MouseButton.Middle) + }) + }) -const mouseEvent = new Mock() - .setup(x => x.altKey).returns(true) - .setup(x => x.ctrlKey).returns(true) - .setup(x => x.shiftKey).returns(true) - .setup(x => x.metaKey).returns(true) - .setup(x => x.buttons).returns(7) - .setup(x => x.button).returns(0) - .setup(x => x.clientX).returns(x) - .setup(x => x.clientY).returns(y) - .object() + describe("Messages", () => { + const x = .3 + const y = .42 + const modifiers = "0,1,2,3,4,5,6" -const wheelEvent = new Mock() - .setup(x => x.altKey).returns(true) - .setup(x => x.ctrlKey).returns(true) - .setup(x => x.shiftKey).returns(true) - .setup(x => x.metaKey).returns(true) - .setup(x => x.buttons).returns(7) - .setup(x => x.clientX).returns(x) - .setup(x => x.clientY).returns(y) - .setup(x => x.deltaX).returns(-deltaX) - .setup(x => x.deltaY).returns(-deltaY) - .object() + const button = "1" -describe("Input event tests", () => { - it("PointerMovedEventMessage", () => { - const message = new PointerMovedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-moved:${modifiers}:${x}:${y}`) - }) - it("PointerPressedEventMessage", () => { - const message = new PointerPressedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) - }) - it("PointerReleasedEventMessage", () => { - const message = new PointerReleasedEventMessage(mouseEvent) - expect(message.toString()) - .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) - }) - it("ScrollEventMessage", () => { - const message = new ScrollEventMessage(wheelEvent) - expect(message.toString()) - .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + const deltaX = -3. + const deltaY = -3. + + const mouseEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.button).returns(0) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .object() + + it("PointerMovedEventMessage", () => { + const message = new PointerMovedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-moved:${modifiers}:${x}:${y}`) + }) + it("PointerPressedEventMessage", () => { + const message = new PointerPressedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-pressed:${modifiers}:${x}:${y}:${button}`) + }) + it("PointerReleasedEventMessage", () => { + const message = new PointerReleasedEventMessage(mouseEvent) + expect(message.toString()) + .equal(`pointer-released:${modifiers}:${x}:${y}:${button}`) + }) + + it("ScrollEventMessage", () => { + const wheelEvent = new Mock() + .setup(x => x.altKey).returns(true) + .setup(x => x.ctrlKey).returns(true) + .setup(x => x.shiftKey).returns(true) + .setup(x => x.metaKey).returns(true) + .setup(x => x.buttons).returns(7) + .setup(x => x.clientX).returns(x) + .setup(x => x.clientY).returns(y) + .setup(x => x.deltaX).returns(-deltaX) + .setup(x => x.deltaY).returns(-deltaY) + .object() + const message = new ScrollEventMessage(wheelEvent) + + expect(message.toString()) + .equal(`scroll:${modifiers}:${x}:${y}:${deltaX}:${deltaY}`) + }) }) }) From 79a53846c8bb7dbb789a3d08fe8179e8ada37b72 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 18 Sep 2020 22:35:59 +0500 Subject: [PATCH 018/314] InvariantCultureIgnoreCase -> OrdinalIgnoreCase --- .../Remote/HtmlTransport/HtmlTransport.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index de7da4985c..0996431b1f 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -267,11 +267,11 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport { var parts = message.Split(':'); var key = parts[0]; - if (key.Equals("frame-received", StringComparison.InvariantCultureIgnoreCase)) + if (key.Equals("frame-received", StringComparison.OrdinalIgnoreCase)) { return new FrameReceivedMessage { SequenceId = long.Parse(parts[1]) }; } - else if (key.Equals("pointer-released", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-released", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerReleasedEventMessage { @@ -281,7 +281,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Button = ParseMouseButton(parts[4]), }; } - else if (key.Equals("pointer-pressed", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-pressed", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerPressedEventMessage { @@ -291,7 +291,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Button = ParseMouseButton(parts[4]), }; } - else if (key.Equals("pointer-moved", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("pointer-moved", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.PointerMovedEventMessage { @@ -300,7 +300,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport Y = ParseDouble(parts[3]), }; } - else if (key.Equals("scroll", StringComparison.InvariantCultureIgnoreCase)) + else if (key.Equals("scroll", StringComparison.OrdinalIgnoreCase)) { return new InputProtocol.ScrollEventMessage { @@ -316,7 +316,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport } private static InputProtocol.InputModifiers[] ParseInputModifiers(string modifiersText) => - string.IsNullOrEmpty(modifiersText) + string.IsNullOrWhiteSpace(modifiersText) ? null : modifiersText .Split(',') From 9ce5a98277e7c33f8ec3e298a1669dd27485e1fd Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Fri, 18 Sep 2020 22:39:22 +0500 Subject: [PATCH 019/314] IsNullOrEmpty -> IsNullOrWhiteSpace --- .../Remote/HtmlTransport/HtmlTransport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 0996431b1f..804bb09510 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -325,7 +325,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport .ToArray(); private static InputProtocol.MouseButton ParseMouseButton(string buttonText) => - string.IsNullOrEmpty(buttonText) + string.IsNullOrWhiteSpace(buttonText) ? InputProtocol.MouseButton.None : (InputProtocol.MouseButton)Enum.Parse( typeof(InputProtocol.MouseButton), buttonText, true); From 24b2615dd0378e0688d0dc2cc5bba8828a4ee40a Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Mon, 28 Sep 2020 18:13:23 +0200 Subject: [PATCH 020/314] Fiexes issue #4657 --- src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml index 3623e95597..7dd4ed0832 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml @@ -12,6 +12,9 @@ + From 640bddf5cabf5f6a8bf4cb07fefe341549c62c03 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 24 Sep 2020 14:59:29 +0200 Subject: [PATCH 021/314] Add interface ICommandSource --- src/Avalonia.Input/ICommandSource.cs | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Avalonia.Input/ICommandSource.cs diff --git a/src/Avalonia.Input/ICommandSource.cs b/src/Avalonia.Input/ICommandSource.cs new file mode 100644 index 0000000000..b0dd75e12e --- /dev/null +++ b/src/Avalonia.Input/ICommandSource.cs @@ -0,0 +1,31 @@ +using System.Windows.Input; + +namespace Avalonia.Input +{ + /// + /// An interface for classes that know how to invoke a Command. + /// + public interface ICommandSource + { + /// + /// The command that will be executed when the class is "invoked." + /// Classes that implement this interface should enable or disable based on the command's CanExecute return value. + /// The property may be implemented as read-write if desired. + /// + ICommand Command { get; } + + /// + /// The parameter that will be passed to the command when executing the command. + /// The property may be implemented as read-write if desired. + /// + object CommandParameter { get; } + + + /// + /// Bor the bheavior CanExecuteChanged + /// + /// + /// + void CanExecuteChanged(object sender, System.EventArgs e); + } +} From ef385675470f347aee079f3c9517f88014aa3789 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 24 Sep 2020 15:48:10 +0200 Subject: [PATCH 022/314] Implemented ICommandSource --- src/Avalonia.Controls/Button.cs | 4 +++- src/Avalonia.Controls/MenuItem.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index e94d00b2ff..91eef3947b 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -30,7 +30,7 @@ namespace Avalonia.Controls /// A button control. /// [PseudoClasses(":pressed")] - public class Button : ContentControl + public class Button : ContentControl, ICommandSource { /// /// Defines the property. @@ -492,5 +492,7 @@ namespace Avalonia.Controls { PseudoClasses.Set(":pressed", isPressed); } + + void ICommandSource.CanExecuteChanged(object sender, EventArgs e) => this.CanExecuteChanged(sender, e); } } diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 7d4fef009d..d034f54df2 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -22,7 +22,7 @@ namespace Avalonia.Controls /// A menu item control. /// [PseudoClasses(":separator", ":icon", ":open", ":pressed", ":selected")] - public class MenuItem : HeaderedSelectingItemsControl, IMenuItem, ISelectable + public class MenuItem : HeaderedSelectingItemsControl, IMenuItem, ISelectable, ICommandSource { /// /// Defines the property. @@ -609,6 +609,8 @@ namespace Avalonia.Controls SelectedItem = null; } + void ICommandSource.CanExecuteChanged(object sender, EventArgs e) => this.CanExecuteChanged(sender, e); + /// /// A dependency resolver which returns a . /// From fa1476a6622101c383a19e499eb44ad352306e14 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 24 Sep 2020 16:05:59 +0200 Subject: [PATCH 023/314] Fix Hotkey CommandParameter --- src/Avalonia.Controls/HotkeyManager.cs | 17 +++++++++++------ src/Avalonia.Controls/NativeMenuItem.cs | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/HotkeyManager.cs b/src/Avalonia.Controls/HotkeyManager.cs index 95752e7875..b104b7a9a8 100644 --- a/src/Avalonia.Controls/HotkeyManager.cs +++ b/src/Avalonia.Controls/HotkeyManager.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Input; using Avalonia.Controls.Utils; +using Avalonia.Data.Core; using Avalonia.Input; namespace Avalonia.Controls @@ -12,14 +13,14 @@ namespace Avalonia.Controls class HotkeyCommandWrapper : ICommand { - public HotkeyCommandWrapper(IControl control) + public HotkeyCommandWrapper(ICommandSource control) { - Control = control; + CommandSource = control; } - public readonly IControl Control; + public readonly ICommandSource CommandSource; - private ICommand GetCommand() => Control.GetValue(Button.CommandProperty); + private ICommand GetCommand() => CommandSource.Command; public bool CanExecute(object parameter) => GetCommand()?.CanExecute(parameter) ?? false; @@ -37,6 +38,7 @@ namespace Avalonia.Controls private TopLevel _root; private IDisposable _parentSub; private IDisposable _hotkeySub; + private IDisposable _commandParameterChangedSubscriber; private KeyGesture _hotkey; private readonly HotkeyCommandWrapper _wrapper; private KeyBinding _binding; @@ -44,7 +46,7 @@ namespace Avalonia.Controls public Manager(IControl control) { _control = control; - _wrapper = new HotkeyCommandWrapper(_control); + _wrapper = new HotkeyCommandWrapper(_control as ICommandSource); } public void Init() @@ -77,6 +79,7 @@ namespace Avalonia.Controls { if (_root != null && _binding != null) _root.KeyBindings.Remove(_binding); + _commandParameterChangedSubscriber?.Dispose(); _binding = null; } @@ -85,6 +88,8 @@ namespace Avalonia.Controls if (_root != null && _hotkey != null) { _binding = new KeyBinding() {Gesture = _hotkey, Command = _wrapper}; + _commandParameterChangedSubscriber = _binding.Bind(KeyBinding.CommandParameterProperty + , ExpressionObserver.Create(((ICommandSource)_control), o => o.CommandParameter)); _root.KeyBindings.Add(_binding); } } @@ -102,7 +107,7 @@ namespace Avalonia.Controls HotKeyProperty.Changed.Subscribe(args => { var control = args.Sender as IControl; - if (args.OldValue != null|| control == null) + if (args.OldValue != null || control == null || !(control is ICommandSource)) return; new Manager(control).Init(); }); diff --git a/src/Avalonia.Controls/NativeMenuItem.cs b/src/Avalonia.Controls/NativeMenuItem.cs index a0fec9e677..d1adda3b0d 100644 --- a/src/Avalonia.Controls/NativeMenuItem.cs +++ b/src/Avalonia.Controls/NativeMenuItem.cs @@ -148,7 +148,7 @@ namespace Avalonia.Controls void CanExecuteChanged() { - IsEnabled = _command?.CanExecute(null) ?? true; + IsEnabled = _command?.CanExecute(CommandParameter) ?? true; } public bool HasClickHandlers => Clicked != null; From 9ffd78a3baa31772de40dd3aad018451486927e7 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 24 Sep 2020 16:29:51 +0200 Subject: [PATCH 024/314] Add Test --- .../Utils/HotKeyManagerTests.cs | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs b/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs index 9f2712c93c..a29eb0f0c7 100644 --- a/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs @@ -5,6 +5,9 @@ using Avalonia.Input; using Avalonia.Platform; using Avalonia.Styling; using Xunit; +using System; +using Avalonia.Input.Raw; +using Factory = System.Func, Avalonia.Controls.Window, Avalonia.AvaloniaObject>; namespace Avalonia.Controls.UnitTests.Utils { @@ -54,6 +57,84 @@ namespace Avalonia.Controls.UnitTests.Utils } } + [Theory] + [MemberData(nameof(ElementsFactory))] + public void HotKeyManager_Should_Use_CommandParameter(string factoryName, Factory factory) + { + using (AvaloniaLocator.EnterScope()) + { + var styler = new Mock(); + var target = new KeyboardDevice(); + var commandResult = 0; + var expectedParameter = 1; + AvaloniaLocator.CurrentMutable + .Bind().ToConstant(new WindowingPlatformMock()) + .Bind().ToConstant(styler.Object); + + var gesture = new KeyGesture(Key.A, KeyModifiers.Control); + + var action = new Action(parameter => + { + if (parameter is int value) + { + commandResult = value; + } + }); + + var root = new Window(); + var element = factory(expectedParameter, action, root); + + root.Template = CreateWindowTemplate(); + root.ApplyTemplate(); + root.Presenter.ApplyTemplate(); + + HotKeyManager.SetHotKey(element, gesture); + + target.ProcessRawEvent(new RawKeyEventArgs(target, + 0, + root, + RawKeyEventType.KeyDown, + Key.A, + RawInputModifiers.Control)); + + Assert.True(expectedParameter == commandResult, $"{factoryName} HotKey did not carry the CommandParameter."); + } + } + + public static TheoryData ElementsFactory => + new TheoryData() + { + {nameof(Button), MakeButton}, + {nameof(MenuItem),MakeMenu}, + }; + + private static AvaloniaObject MakeMenu(int expectedParameter, Action action, Window root) + { + var menuitem = new MenuItem() + { + Command = new Command(action), + CommandParameter = expectedParameter, + }; + var rootMenu = new Menu(); + + rootMenu.Items = new[] { menuitem }; + + root.Content = rootMenu; + return menuitem; + } + + private static AvaloniaObject MakeButton(int expectedParameter, Action action, Window root) + { + var button = new Button() + { + Command = new Command(action), + CommandParameter = expectedParameter, + }; + + root.Content = button; + return button; + } + private FuncControlTemplate CreateWindowTemplate() { return new FuncControlTemplate((parent, scope) => @@ -65,5 +146,22 @@ namespace Avalonia.Controls.UnitTests.Utils }.RegisterInNameScope(scope); }); } + + class Command : System.Windows.Input.ICommand + { + private readonly Action _execeute; + +#pragma warning disable 67 // Event not used + public event EventHandler CanExecuteChanged; +#pragma warning restore 67 // Event not used + + public Command(Action execeute) + { + _execeute = execeute; + } + public bool CanExecute(object parameter) => true; + + public void Execute(object parameter) => _execeute?.Invoke(parameter); + } } } From f1f2df8dd48d42ddc7cc669235988b38cf24b259 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 25 Sep 2020 17:32:26 +0200 Subject: [PATCH 025/314] Fixes Issue #4734 : HotKeys trigger command when control is disabled --- src/Avalonia.Controls/HotkeyManager.cs | 2 +- src/Avalonia.Input/ICommandSource.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/HotkeyManager.cs b/src/Avalonia.Controls/HotkeyManager.cs index b104b7a9a8..f210ecfdaf 100644 --- a/src/Avalonia.Controls/HotkeyManager.cs +++ b/src/Avalonia.Controls/HotkeyManager.cs @@ -22,7 +22,7 @@ namespace Avalonia.Controls private ICommand GetCommand() => CommandSource.Command; - public bool CanExecute(object parameter) => GetCommand()?.CanExecute(parameter) ?? false; + public bool CanExecute(object parameter) => CommandSource.IsEffectivelyEnabled; public void Execute(object parameter) => GetCommand()?.Execute(parameter); diff --git a/src/Avalonia.Input/ICommandSource.cs b/src/Avalonia.Input/ICommandSource.cs index b0dd75e12e..ba2e8eed4e 100644 --- a/src/Avalonia.Input/ICommandSource.cs +++ b/src/Avalonia.Input/ICommandSource.cs @@ -27,5 +27,10 @@ namespace Avalonia.Input /// /// void CanExecuteChanged(object sender, System.EventArgs e); + + /// + /// Gets a value indicating whether this control and all its parents are enabled. + /// + bool IsEffectivelyEnabled { get; } } } From f0efe9aef0d2e4953f5ed034e21359c95dcc4499 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 25 Sep 2020 17:33:13 +0200 Subject: [PATCH 026/314] Add test Issue #4734 --- .../Utils/HotKeyManagerTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs b/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs index a29eb0f0c7..151c3070f4 100644 --- a/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs @@ -101,6 +101,49 @@ namespace Avalonia.Controls.UnitTests.Utils } } + + [Theory] + [MemberData(nameof(ElementsFactory))] + public void HotKeyManager_Should_Do_Not_Executed_When_IsEnabled_False(string factoryName, Factory factory) + { + using (AvaloniaLocator.EnterScope()) + { + var styler = new Mock(); + var target = new KeyboardDevice(); + var isExecuted = false; + AvaloniaLocator.CurrentMutable + .Bind().ToConstant(new WindowingPlatformMock()) + .Bind().ToConstant(styler.Object); + + var gesture = new KeyGesture(Key.A, KeyModifiers.Control); + + var action = new Action(parameter => + { + isExecuted = true; + }); + + var root = new Window(); + var element = factory(0, action, root) as InputElement; + + element.IsEnabled = false; + + root.Template = CreateWindowTemplate(); + root.ApplyTemplate(); + root.Presenter.ApplyTemplate(); + + HotKeyManager.SetHotKey(element, gesture); + + target.ProcessRawEvent(new RawKeyEventArgs(target, + 0, + root, + RawKeyEventType.KeyDown, + Key.A, + RawInputModifiers.Control)); + + Assert.True(isExecuted == false, $"{factoryName} Execution raised when IsEnabled is false."); + } + } + public static TheoryData ElementsFactory => new TheoryData() { From c7a21d7268aad472e9022777b626120cdc6b29e3 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 9 Oct 2020 09:51:54 +0200 Subject: [PATCH 027/314] Removed CommandParameter Binding --- src/Avalonia.Controls/HotkeyManager.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Controls/HotkeyManager.cs b/src/Avalonia.Controls/HotkeyManager.cs index f210ecfdaf..dabc35dd24 100644 --- a/src/Avalonia.Controls/HotkeyManager.cs +++ b/src/Avalonia.Controls/HotkeyManager.cs @@ -1,7 +1,6 @@ using System; using System.Windows.Input; using Avalonia.Controls.Utils; -using Avalonia.Data.Core; using Avalonia.Input; namespace Avalonia.Controls @@ -22,9 +21,12 @@ namespace Avalonia.Controls private ICommand GetCommand() => CommandSource.Command; - public bool CanExecute(object parameter) => CommandSource.IsEffectivelyEnabled; + public bool CanExecute(object parameter) => + CommandSource.Command?.CanExecute(CommandSource.CommandParameter) == true + && CommandSource.IsEffectivelyEnabled; - public void Execute(object parameter) => GetCommand()?.Execute(parameter); + public void Execute(object parameter) => + GetCommand()?.Execute(CommandSource.CommandParameter); #pragma warning disable 67 // Event not used public event EventHandler CanExecuteChanged; @@ -38,7 +40,6 @@ namespace Avalonia.Controls private TopLevel _root; private IDisposable _parentSub; private IDisposable _hotkeySub; - private IDisposable _commandParameterChangedSubscriber; private KeyGesture _hotkey; private readonly HotkeyCommandWrapper _wrapper; private KeyBinding _binding; @@ -79,7 +80,6 @@ namespace Avalonia.Controls { if (_root != null && _binding != null) _root.KeyBindings.Remove(_binding); - _commandParameterChangedSubscriber?.Dispose(); _binding = null; } @@ -87,9 +87,7 @@ namespace Avalonia.Controls { if (_root != null && _hotkey != null) { - _binding = new KeyBinding() {Gesture = _hotkey, Command = _wrapper}; - _commandParameterChangedSubscriber = _binding.Bind(KeyBinding.CommandParameterProperty - , ExpressionObserver.Create(((ICommandSource)_control), o => o.CommandParameter)); + _binding = new KeyBinding() { Gesture = _hotkey, Command = _wrapper }; _root.KeyBindings.Add(_binding); } } From b8728c8f8ccf08a95f68114d0c3f2f00bb7ff0d3 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 9 Oct 2020 09:53:54 +0200 Subject: [PATCH 028/314] Add warning when HotKey is attached to a control that does not support ICommandSource. --- src/Avalonia.Controls/HotkeyManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/HotkeyManager.cs b/src/Avalonia.Controls/HotkeyManager.cs index dabc35dd24..baae37e022 100644 --- a/src/Avalonia.Controls/HotkeyManager.cs +++ b/src/Avalonia.Controls/HotkeyManager.cs @@ -105,8 +105,13 @@ namespace Avalonia.Controls HotKeyProperty.Changed.Subscribe(args => { var control = args.Sender as IControl; - if (args.OldValue != null || control == null || !(control is ICommandSource)) + if (args.OldValue != null || control == null || !(control is ICommandSource)) + { + Logging.Logger.TryGet(Logging.LogEventLevel.Warning, Logging.LogArea.Control)?. + Log(control, $"The element {args.Sender.GetType().Name} do not support HotKey({args.NewValue})."); return; + } + new Manager(control).Init(); }); } From abff848c8d844eebd32a8a61062a471ccc807db7 Mon Sep 17 00:00:00 2001 From: workgroupengineering Date: Tue, 13 Oct 2020 17:01:37 +0200 Subject: [PATCH 029/314] Update warning message Co-authored-by: Steven Kirk --- src/Avalonia.Controls/HotkeyManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/HotkeyManager.cs b/src/Avalonia.Controls/HotkeyManager.cs index baae37e022..b76b7fbed5 100644 --- a/src/Avalonia.Controls/HotkeyManager.cs +++ b/src/Avalonia.Controls/HotkeyManager.cs @@ -108,7 +108,7 @@ namespace Avalonia.Controls if (args.OldValue != null || control == null || !(control is ICommandSource)) { Logging.Logger.TryGet(Logging.LogEventLevel.Warning, Logging.LogArea.Control)?. - Log(control, $"The element {args.Sender.GetType().Name} do not support HotKey({args.NewValue})."); + Log(control, $"The element {args.Sender.GetType().Name} does not support binding a HotKey ({args.NewValue})."); return; } From de8edba8ad12b7952805b86e72814e52625d1f67 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 26 Oct 2020 02:11:24 +0300 Subject: [PATCH 030/314] [WIP] IDL-based codegen --- Avalonia.sln | 53 ++ packages/Avalonia/Avalonia.csproj | 7 +- packages/Avalonia/AvaloniaBuildTasks.targets | 2 + src/Avalonia.Build.Tasks/ComInteropHelper.cs | 130 +++++ .../CompileAvaloniaXamlTask.cs | 6 +- src/Avalonia.Build.Tasks/Program.cs | 3 +- .../XamlCompilerTaskExecutor.cs | 8 +- .../Avalonia.MicroCom.csproj | 8 + .../IMicroComExceptionCallback.cs | 9 + .../IMicroComShadowContainer.cs | 9 + src/Avalonia.MicroCom/IUnknown.cs | 12 + src/Avalonia.MicroCom/LocalInterop.cs | 17 + src/Avalonia.MicroCom/MicroComProxyBase.cs | 78 +++ src/Avalonia.MicroCom/MicroComRuntime.cs | 88 +++ src/Avalonia.MicroCom/MicroComShadow.cs | 171 ++++++ src/Avalonia.MicroCom/MicroComVtblBase.cs | 41 ++ src/Avalonia.Native/avn.idl | 522 ++++++++++++++++++ src/tools/MicroComGenerator/Ast.cs | 102 ++++ src/tools/MicroComGenerator/AstParser.cs | 228 ++++++++ .../CSharpGen.InterfaceGen.cs | 453 +++++++++++++++ .../MicroComGenerator/CSharpGen.Utils.cs | 97 ++++ src/tools/MicroComGenerator/CSharpGen.cs | 89 +++ src/tools/MicroComGenerator/CppGen.cs | 108 ++++ src/tools/MicroComGenerator/Extensions.cs | 90 +++ .../MicroComGenerator.csproj | 12 + src/tools/MicroComGenerator/ParseException.cs | 27 + src/tools/MicroComGenerator/Program.cs | 44 ++ src/tools/MicroComGenerator/TokenParser.cs | 417 ++++++++++++++ 28 files changed, 2821 insertions(+), 10 deletions(-) create mode 100644 src/Avalonia.Build.Tasks/ComInteropHelper.cs create mode 100644 src/Avalonia.MicroCom/Avalonia.MicroCom.csproj create mode 100644 src/Avalonia.MicroCom/IMicroComExceptionCallback.cs create mode 100644 src/Avalonia.MicroCom/IMicroComShadowContainer.cs create mode 100644 src/Avalonia.MicroCom/IUnknown.cs create mode 100644 src/Avalonia.MicroCom/LocalInterop.cs create mode 100644 src/Avalonia.MicroCom/MicroComProxyBase.cs create mode 100644 src/Avalonia.MicroCom/MicroComRuntime.cs create mode 100644 src/Avalonia.MicroCom/MicroComShadow.cs create mode 100644 src/Avalonia.MicroCom/MicroComVtblBase.cs create mode 100644 src/Avalonia.Native/avn.idl create mode 100644 src/tools/MicroComGenerator/Ast.cs create mode 100644 src/tools/MicroComGenerator/AstParser.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.Utils.cs create mode 100644 src/tools/MicroComGenerator/CSharpGen.cs create mode 100644 src/tools/MicroComGenerator/CppGen.cs create mode 100644 src/tools/MicroComGenerator/Extensions.cs create mode 100644 src/tools/MicroComGenerator/MicroComGenerator.csproj create mode 100644 src/tools/MicroComGenerator/ParseException.cs create mode 100644 src/tools/MicroComGenerator/Program.cs create mode 100644 src/tools/MicroComGenerator/TokenParser.cs diff --git a/Avalonia.sln b/Avalonia.sln index 34ad19b41d..74a2dbb94b 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -226,6 +226,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.ReactiveUI.Events" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox", "samples\Sandbox\Sandbox.csproj", "{11BE52AF-E2DD-4CF0-B19A-05285ACAF571}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroComGenerator", "src\tools\MicroComGenerator\MicroComGenerator.csproj", "{AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.MicroCom", "src\Avalonia.MicroCom\Avalonia.MicroCom.csproj", "{FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 @@ -2064,6 +2068,54 @@ Global {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhone.Build.0 = Release|Any CPU {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {11BE52AF-E2DD-4CF0-B19A-05285ACAF571}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhone.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|Any CPU.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhone.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhone.Build.0 = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhone.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|Any CPU.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhone.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhone.Build.0 = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2123,6 +2175,7 @@ Global {3C84E04B-36CF-4D0D-B965-C26DD649D1F3} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9} {909A8CBD-7D0E-42FD-B841-022AD8925820} = {8B6A8209-894F-4BA1-B880-965FD453982C} {11BE52AF-E2DD-4CF0-B19A-05285ACAF571} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj index cd3ce9adcd..90c1c67956 100644 --- a/packages/Avalonia/Avalonia.csproj +++ b/packages/Avalonia/Avalonia.csproj @@ -5,8 +5,9 @@ - + + @@ -15,9 +16,7 @@ - + <_PackageFiles Include="$(DesignerHostAppPath)/Avalonia.Designer.HostApp/bin/$(Configuration)/netcoreapp2.0/Avalonia.Designer.HostApp.dll"> diff --git a/packages/Avalonia/AvaloniaBuildTasks.targets b/packages/Avalonia/AvaloniaBuildTasks.targets index 612c368633..57b4cb04e3 100644 --- a/packages/Avalonia/AvaloniaBuildTasks.targets +++ b/packages/Avalonia/AvaloniaBuildTasks.targets @@ -3,6 +3,7 @@ <_AvaloniaUseExternalMSBuild>$(AvaloniaUseExternalMSBuild) <_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false low + <_AvaloniaPatchComInterop Condition="'$(_AvaloniaPatchComInterop)' == ''">false @@ -90,6 +91,7 @@ AssemblyOriginatorKeyFile="$(AssemblyOriginatorKeyFile)" SignAssembly="$(SignAssembly)" DelaySign="$(DelaySign)" + EnableComInteropPatching="$(_AvaloniaPatchComInterop)" /> (); + var initializers = new List(); + foreach (var type in asm.MainModule.Types) + { + var i = type.Methods.FirstOrDefault(m => m.Name == "__MicroComModuleInit"); + if (i != null) + initializers.Add(i); + + PatchType(type, classToRemoveList); + } + + // Remove All Interop classes + foreach (var type in classToRemoveList) + asm.MainModule.Types.Remove(type); + + + // Patch automatic registrations + if (initializers.Count != 0) + { + var moduleType = asm.MainModule.Types.First(x => x.Name == ""); + + // Needed for compatibility with upcoming .NET 5 feature, look for existing initializer first + var staticCtor = moduleType.Methods.FirstOrDefault(m => m.Name == ".cctor"); + if (staticCtor == null) + { + // Create a new static ctor if none exists + staticCtor = new MethodDefinition(".cctor", + MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | + MethodAttributes.Static | MethodAttributes.Private, + asm.MainModule.TypeSystem.Void); + staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); + moduleType.Methods.Add(staticCtor); + } + + foreach (var i in initializers) + staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Call, i)); + } + + } + + + + static void PatchMethod(MethodDefinition method) + { + if (method.HasBody) + { + var ilProcessor = method.Body.GetILProcessor(); + + var instructions = method.Body.Instructions; + for (int i = 0; i < instructions.Count; i++) + { + Instruction instruction = instructions[i]; + + if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference) + { + var methodDescription = (MethodReference)instruction.Operand; + + if (methodDescription.Name.StartsWith("Calli") && methodDescription.DeclaringType.Name == "LocalInterop") + { + var callSite = new CallSite(methodDescription.ReturnType) { CallingConvention = MethodCallingConvention.StdCall }; + + if (methodDescription.Name.StartsWith("CalliCdecl")) + { + callSite.CallingConvention = MethodCallingConvention.C; + } + else if(methodDescription.Name.StartsWith("CalliThisCall")) + { + callSite.CallingConvention = MethodCallingConvention.ThisCall; + } + else if(methodDescription.Name.StartsWith("CalliStdCall")) + { + callSite.CallingConvention = MethodCallingConvention.StdCall; + } + else if(methodDescription.Name.StartsWith("CalliFastCall")) + { + callSite.CallingConvention = MethodCallingConvention.FastCall; + } + + // Last parameter is the function ptr, so we don't add it as a parameter for calli + // as it is already an implicit parameter for calli + for (int j = 0; j < methodDescription.Parameters.Count - 1; j++) + { + var parameterDefinition = methodDescription.Parameters[j]; + callSite.Parameters.Add(parameterDefinition); + } + + // Create calli Instruction + var callIInstruction = ilProcessor.Create(OpCodes.Calli, callSite); + + // Replace instruction + ilProcessor.Replace(instruction, callIInstruction); + } + } + } + } + } + + /// + /// Patches the type. + /// + /// The type. + static void PatchType(TypeDefinition type, List classToRemoveList) + { + // Patch methods + foreach (var method in type.Methods) + PatchMethod(method); + + if (type.Name == "LocalInterop") + classToRemoveList.Add(type); + + // Patch nested types + foreach (var typeDefinition in type.NestedTypes) + PatchType(typeDefinition, classToRemoveList); + } + } +} diff --git a/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs b/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs index 8e1f6c257d..f44e90b25e 100644 --- a/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs +++ b/src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs @@ -40,8 +40,8 @@ namespace Avalonia.Build.Tasks var res = XamlCompilerTaskExecutor.Compile(BuildEngine, input, File.ReadAllLines(ReferencesFilePath).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray(), ProjectDirectory, OutputPath, VerifyIl, outputImportance, - (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null - ); + (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null, + EnableComInteropPatching); if (!res.Success) return false; if (!res.WrittenFile) @@ -76,6 +76,8 @@ namespace Avalonia.Build.Tasks public bool VerifyIl { get; set; } + public bool EnableComInteropPatching { get; set; } + public string AssemblyOriginatorKeyFile { get; set; } public bool SignAssembly { get; set; } public bool DelaySign { get; set; } diff --git a/src/Avalonia.Build.Tasks/Program.cs b/src/Avalonia.Build.Tasks/Program.cs index 1909c4c6ec..b18c19cd63 100644 --- a/src/Avalonia.Build.Tasks/Program.cs +++ b/src/Avalonia.Build.Tasks/Program.cs @@ -29,7 +29,8 @@ namespace Avalonia.Build.Tasks OutputPath = args[2], BuildEngine = new ConsoleBuildEngine(), ProjectDirectory = Directory.GetCurrentDirectory(), - VerifyIl = true + VerifyIl = true, + EnableComInteropPatching = true }.Execute() ? 0 : 2; diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 6b01af2ede..938732cfe1 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -42,13 +42,13 @@ namespace Avalonia.Build.Tasks } public static CompileResult Compile(IBuildEngine engine, string input, string[] references, string projectDirectory, - string output, bool verifyIl, MessageImportance logImportance, string strongNameKey) + string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom) { var typeSystem = new CecilTypeSystem(references.Concat(new[] {input}), input); var asm = typeSystem.TargetAssemblyDefinition; var emres = new EmbeddedResources(asm); var avares = new AvaloniaResources(asm, projectDirectory); - if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0) + if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0 && !patchCom) // Nothing to do return new CompileResult(true); @@ -374,7 +374,9 @@ namespace Avalonia.Build.Tasks loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldnull)); loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); - + + if (patchCom) + ComInteropHelper.PatchAssembly(asm, typeSystem); var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; if (!string.IsNullOrWhiteSpace(strongNameKey)) diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj new file mode 100644 index 0000000000..aaf54ed80e --- /dev/null +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -0,0 +1,8 @@ + + + + netstandard2.0 + true + + + diff --git a/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs b/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs new file mode 100644 index 0000000000..08f20339ec --- /dev/null +++ b/src/Avalonia.MicroCom/IMicroComExceptionCallback.cs @@ -0,0 +1,9 @@ +using System; + +namespace Avalonia.MicroCom +{ + public interface IMicroComExceptionCallback + { + void RaiseException(Exception e); + } +} diff --git a/src/Avalonia.MicroCom/IMicroComShadowContainer.cs b/src/Avalonia.MicroCom/IMicroComShadowContainer.cs new file mode 100644 index 0000000000..a33d3a9811 --- /dev/null +++ b/src/Avalonia.MicroCom/IMicroComShadowContainer.cs @@ -0,0 +1,9 @@ +namespace Avalonia.MicroCom +{ + public interface IMicroComShadowContainer + { + MicroComShadow Shadow { get; set; } + void OnReferencedFromNative(); + void OnUnreferencedFromNative(); + } +} diff --git a/src/Avalonia.MicroCom/IUnknown.cs b/src/Avalonia.MicroCom/IUnknown.cs new file mode 100644 index 0000000000..a46953ced9 --- /dev/null +++ b/src/Avalonia.MicroCom/IUnknown.cs @@ -0,0 +1,12 @@ +using System; + +namespace Avalonia.MicroCom +{ + public interface IUnknown : IDisposable + { + void AddRef(); + void Release(); + int QueryInterface(Guid guid, out IntPtr ppv); + T QueryInterface() where T : IUnknown; + } +} diff --git a/src/Avalonia.MicroCom/LocalInterop.cs b/src/Avalonia.MicroCom/LocalInterop.cs new file mode 100644 index 0000000000..785f4e03a5 --- /dev/null +++ b/src/Avalonia.MicroCom/LocalInterop.cs @@ -0,0 +1,17 @@ +using System; + +namespace Avalonia.MicroCom +{ + unsafe class LocalInterop + { + public static unsafe void CalliStdCallvoid(void* thisObject, void* methodPtr) + { + throw null; + } + + public static unsafe int CalliStdCallint(void* thisObject, Guid* guid, IntPtr* ppv, void* methodPtr) + { + throw null; + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs new file mode 100644 index 0000000000..56b80c2632 --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -0,0 +1,78 @@ +using System; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComProxyBase : IUnknown + { + private IntPtr _nativePointer; + private bool _ownsHandle; + + public IntPtr NativePointer + { + get + { + if (_nativePointer == IntPtr.Zero) + throw new ObjectDisposedException(this.GetType().FullName); + return _nativePointer; + } + } + + public void*** PPV => (void***)NativePointer; + + public MicroComProxyBase(IntPtr nativePointer, bool ownsHandle) + { + _nativePointer = nativePointer; + _ownsHandle = ownsHandle; + } + + protected virtual int VTableSize => 3; + + public void AddRef() + { + LocalInterop.CalliStdCallvoid(PPV, (*PPV)[1]); + } + + public void Release() + { + LocalInterop.CalliStdCallvoid(PPV, (*PPV)[2]); + } + + public int QueryInterface(Guid guid, out IntPtr ppv) + { + IntPtr r = default; + var rv = LocalInterop.CalliStdCallint(PPV, &guid, &r, (*PPV)[0]); + ppv = r; + return rv; + } + + public T QueryInterface() where T : IUnknown + { + var guid = MicroComRuntime.GetGuidFor(typeof(T)); + var rv = QueryInterface(guid, out var ppv); + if (rv != 0) + return (T)MicroComRuntime.CreateProxyFor(typeof(T), ppv, true); + throw new COMException("QueryInterface failed", rv); + } + + public bool IsDisposed => _nativePointer == IntPtr.Zero; + + public void Dispose() + { + if (_ownsHandle) + Release(); + _nativePointer = IntPtr.Zero; + } + + public bool OwnsHandle => _ownsHandle; + + public void EnsureOwned() + { + if (!_ownsHandle) + { + AddRef(); + _ownsHandle = true; + } + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs new file mode 100644 index 0000000000..eccf24b496 --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Concurrent; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public static unsafe class MicroComRuntime + { + private static ConcurrentDictionary _vtables = new ConcurrentDictionary(); + + private static ConcurrentDictionary> _factories = + new ConcurrentDictionary>(); + private static ConcurrentDictionary _guids = new ConcurrentDictionary(); + private static ConcurrentDictionary _guidsToTypes = new ConcurrentDictionary(); + + static MicroComRuntime() + { + Register(typeof(IUnknown), new Guid("00000000-0000-0000-C000-000000000046"), + (ppv, owns) => new MicroComProxyBase(ppv, owns)); + RegisterVTable(typeof(IUnknown), MicroComVtblBase.Vtable); + } + + public static void RegisterVTable(Type t, IntPtr vtable) + { + _vtables[t] = vtable; + } + + public static void Register(Type t, Guid guid, Func proxyFactory) + { + _factories[t] = proxyFactory; + _guids[t] = guid; + _guidsToTypes[guid] = t; + } + + public static Guid GetGuidFor(Type type) => _guids[type]; + + public static T CreateProxyFor(void* ppv, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(ppv), ownsHandle); + + public static object CreateProxyFor(Type type, IntPtr ppv, bool ownsHandle) => _factories[type](ppv, ownsHandle); + + public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown + { + if (obj is MicroComProxyBase proxy) + return (void*)proxy.NativePointer; + if (obj is IMicroComShadowContainer container) + { + container.Shadow ??= new MicroComShadow(container); + void* ptr = null; + var res = container.Shadow.GetOrCreateNativePointer(typeof(T), &ptr); + if (res != 0) + throw new COMException( + "Unable to create native callable wrapper for type " + typeof(T) + " for instance of type " + + obj.GetType(), + res); + if (owned) + container.Shadow.AddRef((Ccw*)ptr); + } + throw new ArgumentException("Unable to get a native pointer for " + obj); + } + + public static object GetObjectFromCcw(IntPtr ccw) + { + var ptr = (Ccw*)ccw; + var shadow = (MicroComShadow)GCHandle.FromIntPtr(ptr->GcShadowHandle).Target; + return shadow.Target; + } + + public static bool TryGetTypeForGuid(Guid guid, out Type t) => _guidsToTypes.TryGetValue(guid, out t); + + public static bool GetVtableFor(Type type, out IntPtr ptr) => _vtables.TryGetValue(type, out ptr); + + public static void UnhandledException(object target, Exception e) + { + if (target is IMicroComExceptionCallback cb) + { + try + { + cb.RaiseException(e); + } + catch + { + // We've tried + } + } + + } + } +} diff --git a/src/Avalonia.MicroCom/MicroComShadow.cs b/src/Avalonia.MicroCom/MicroComShadow.cs new file mode 100644 index 0000000000..c9411a089e --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComShadow.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComShadow : IDisposable + { + private readonly object _lock = new object(); + private readonly Dictionary _shadows = new Dictionary(); + private readonly Dictionary _backShadows = new Dictionary(); + private GCHandle? _handle; + private volatile int _refCount; + internal IMicroComShadowContainer Target { get; } + internal MicroComShadow(IMicroComShadowContainer target) + { + Target = target; + Target.Shadow = this; + } + + internal int QueryInterface(Ccw* ccw, Guid* guid, void** ppv) + { + if (MicroComRuntime.TryGetTypeForGuid(*guid, out var type)) + return QueryInterface(type, ppv); + else + return unchecked((int)0x80004002u); + } + + internal int QueryInterface(Type type, void** ppv) + { + if (!type.IsInstanceOfType(Target)) + return unchecked((int)0x80004002u); + + var rv = GetOrCreateNativePointer(type, ppv); + if (rv == 0) + AddRef((Ccw*)*ppv); + return rv; + } + + internal int GetOrCreateNativePointer(Type type, void** ppv) + { + if (!MicroComRuntime.GetVtableFor(type, out var vtable)) + return unchecked((int)0x80004002u); + lock (_lock) + { + + if (_shadows.TryGetValue(type, out var shadow)) + { + var targetCcw = (Ccw*)shadow; + AddRef(targetCcw); + *ppv = targetCcw; + return 0; + } + else + { + var intPtr = Marshal.AllocHGlobal(Marshal.SizeOf()); + var targetCcw = (Ccw*)intPtr; + *targetCcw = default; + targetCcw->RefCount = 0; + targetCcw->VTable = vtable; + if (_handle == null) + _handle = GCHandle.Alloc(this); + targetCcw->GcShadowHandle = GCHandle.ToIntPtr(_handle.Value); + _shadows[type] = intPtr; + _backShadows[intPtr] = type; + *ppv = targetCcw; + + return 0; + } + } + } + + internal int AddRef(Ccw* ccw) + { + if (Interlocked.Increment(ref _refCount) == 1) + { + try + { + Target.OnUnreferencedFromNative(); + } + catch (Exception e) + { + MicroComRuntime.UnhandledException(Target, e); + } + } + + return Interlocked.Increment(ref ccw->RefCount); + } + + internal int Release(Ccw* ccw) + { + Interlocked.Decrement(ref _refCount); + var cnt = Interlocked.Decrement(ref ccw->RefCount); + if (cnt == 0) + return FreeCcw(ccw); + + return cnt; + } + + int FreeCcw(Ccw* ccw) + { + lock (_lock) + { + // Shadow got resurrected by a call to QueryInterface from another thread + if (ccw->RefCount != 0) + return ccw->RefCount; + + var intPtr = new IntPtr(ccw); + var type = _backShadows[intPtr]; + _backShadows.Remove(intPtr); + _shadows.Remove(type); + Marshal.FreeHGlobal(intPtr); + if (_shadows.Count == 0) + { + _handle?.Free(); + _handle = null; + try + { + Target.OnUnreferencedFromNative(); + } + catch(Exception e) + { + MicroComRuntime.UnhandledException(Target, e); + } + } + } + + return 0; + } + + /* + Needs to be called to support the following scenario: + 1) Object created + 2) Object passed to native code, shadow is created, CCW is created + 3) Native side has never called AddRef + + In that case the GC handle to the shadow object is still alive + */ + + public void Dispose() + { + lock (_lock) + { + List toRemove = null; + foreach (var kv in _backShadows) + { + var ccw = (Ccw*)kv.Key; + if (ccw->RefCount == 0) + { + toRemove ??= new List(); + toRemove.Add(kv.Key); + } + } + + if(toRemove != null) + foreach (var intPtr in toRemove) + FreeCcw((Ccw*)intPtr); + } + } + } + + [StructLayout(LayoutKind.Sequential)] + struct Ccw + { + public IntPtr VTable; + public IntPtr GcShadowHandle; + public volatile int RefCount; + public MicroComShadow GetShadow() => (MicroComShadow)GCHandle.FromIntPtr(GcShadowHandle).Target; + } +} diff --git a/src/Avalonia.MicroCom/MicroComVtblBase.cs b/src/Avalonia.MicroCom/MicroComVtblBase.cs new file mode 100644 index 0000000000..4cd419cdaf --- /dev/null +++ b/src/Avalonia.MicroCom/MicroComVtblBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Avalonia.MicroCom +{ + public unsafe class MicroComVtblBase + { + private List _methods = new List(); + [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + private delegate int AddRefDelegate(Ccw* ccw); + + [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + private delegate int QueryInterfaceDelegate(Ccw* ccw, Guid* guid, void** ppv); + + public static IntPtr Vtable { get; } = new MicroComVtblBase().CreateVTable(); + public MicroComVtblBase() + { + AddMethod((QueryInterfaceDelegate)QueryInterface); + AddMethod((AddRefDelegate)AddRef); + } + + protected void AddMethod(Delegate d) + { + GCHandle.Alloc(d); + _methods.Add(Marshal.GetFunctionPointerForDelegate(d)); + } + + protected unsafe IntPtr CreateVTable() + { + var ptr = (IntPtr*)Marshal.AllocHGlobal((IntPtr.Size + 1) * _methods.Count); + for (var c = 0; c < _methods.Count; c++) + ptr[c] = _methods[c]; + return new IntPtr(ptr); + } + + static int QueryInterface(Ccw* ccw, Guid* guid, void** ppv) => ccw->GetShadow().QueryInterface(ccw, guid, ppv); + static int AddRef(Ccw* ccw) => ccw->GetShadow().AddRef(ccw); + static int Release(Ccw* ccw) => ccw->GetShadow().Release(ccw); + } +} diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl new file mode 100644 index 0000000000..c763007826 --- /dev/null +++ b/src/Avalonia.Native/avn.idl @@ -0,0 +1,522 @@ +@clr-namespace Avalonia.Native.MicroCom +@clr-access internal +@cpp-preamble @@ +#include "com.h" +#include "key.h" +#include "stddef.h" +@@ + +enum SystemDecorations { + SystemDecorationsNone = 0, + SystemDecorationsBorderOnly = 1, + SystemDecorationsFull = 2, +} + +struct AvnSize +{ + double Width, Height; +} + +struct AvnPixelSize +{ + int Width, Height; +} + +struct AvnRect +{ + double X, Y, Width, Height; +} + +struct AvnVector +{ + double X, Y; +} + +struct AvnPoint +{ + double X, Y; +} + +struct AvnScreen +{ + AvnRect Bounds; + AvnRect WorkingArea; + float PixelDensity; + bool Primary; +} + +enum AvnPixelFormat +{ + kAvnRgb565, + kAvnRgba8888, + kAvnBgra8888 +} + +struct AvnFramebuffer +{ + void* Data; + int Width; + int Height; + int Stride; + AvnVector Dpi; + AvnPixelFormat PixelFormat; +} + +struct AvnColor +{ + byte Alpha; + byte Red; + byte Green; + byte Blue; +} + +enum AvnRawMouseEventType +{ + LeaveWindow, + LeftButtonDown, + LeftButtonUp, + RightButtonDown, + RightButtonUp, + MiddleButtonDown, + MiddleButtonUp, + XButton1Down, + XButton1Up, + XButton2Down, + XButton2Up, + Move, + Wheel, + NonClientLeftButtonDown, + TouchBegin, + TouchUpdate, + TouchEnd, + TouchCancel +} + +enum AvnRawKeyEventType +{ + KeyDown, + KeyUp +} + +enum AvnInputModifiers +{ + AvnInputModifiersNone = 0, + Alt = 1, + Control = 2, + Shift = 4, + Windows = 8, + LeftMouseButton = 16, + RightMouseButton = 32, + MiddleMouseButton = 64, + XButton1MouseButton = 128, + XButton2MouseButton = 256 +} + +[class-enum] +enum AvnDragDropEffects +{ + None = 0, + Copy = 1, + Move = 2, + Link = 4, +} + +[class-enum] +enum AvnDragEventType +{ + Enter, + Over, + Leave, + Drop +} + +enum AvnWindowState +{ + Normal, + Minimized, + Maximized, + FullScreen, +} + +enum AvnStandardCursorType +{ + CursorArrow, + CursorIbeam, + CursorWait, + CursorCross, + CursorUpArrow, + CursorSizeWestEast, + CursorSizeNorthSouth, + CursorSizeAll, + CursorNo, + CursorHand, + CursorAppStarting, + CursorHelp, + CursorTopSide, + CursorBottomSize, + CursorLeftSide, + CursorRightSide, + CursorTopLeftCorner, + CursorTopRightCorner, + CursorBottomLeftCorner, + CursorBottomRightCorner, + CursorDragMove, + CursorDragCopy, + CursorDragLink, + CursorNone +} + +enum AvnWindowEdge +{ + WindowEdgeNorthWest, + WindowEdgeNorth, + WindowEdgeNorthEast, + WindowEdgeWest, + WindowEdgeEast, + WindowEdgeSouthWest, + WindowEdgeSouth, + WindowEdgeSouthEast +} + +enum AvnMenuItemToggleType +{ + None, + CheckMark, + Radio +} + +enum AvnExtendClientAreaChromeHints +{ + AvnNoChrome = 0, + AvnSystemChrome = 0x01, + AvnPreferSystemChrome = 0x02, + AvnOSXThickTitleBar = 0x08, + AvnDefaultChrome = AvnSystemChrome, +} + +[uuid(809c652e-7396-11d2-9771-00a0c9b4d50c)] +interface IAvaloniaNativeFactory : IUnknown +{ + HRESULT Initialize(IAvnGCHandleDeallocatorCallback* deallocator); + IAvnMacOptions* GetMacOptions(); + HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnWindow** ppv); + HRESULT CreatePopup(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnPopup** ppv); + HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv); + HRESULT CreateSystemDialogs(IAvnSystemDialogs** ppv); + HRESULT CreateScreens(IAvnScreens** ppv); + HRESULT CreateClipboard(IAvnClipboard** ppv); + HRESULT CreateDndClipboard(IAvnClipboard** ppv); + HRESULT CreateCursorFactory(IAvnCursorFactory** ppv); + HRESULT ObtainGlDisplay(IAvnGlDisplay** ppv); + HRESULT SetAppMenu(IAvnMenu* menu); + HRESULT CreateMenu(IAvnMenuEvents* cb, IAvnMenu** ppv); + HRESULT CreateMenuItem(IAvnMenuItem** ppv); + HRESULT CreateMenuItemSeperator(IAvnMenuItem** ppv); +} + +[uuid(233e094f-9b9f-44a3-9a6e-6948bbdd9fb1)] +interface IAvnString : IUnknown +{ + HRESULT Pointer(void**retOut); + HRESULT Length(int*ret); +} + +[uuid(e5aca675-02b7-4129-aa79-d6e417210bda)] +interface IAvnWindowBase : IUnknown +{ + HRESULT Show(); + HRESULT Hide(); + HRESULT Close(); + HRESULT Activate(); + HRESULT GetClientSize(AvnSize*ret); + HRESULT GetScaling(double*ret); + HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize); + HRESULT Resize(double width, double height); + HRESULT Invalidate(AvnRect rect); + HRESULT BeginMoveDrag(); + HRESULT BeginResizeDrag(AvnWindowEdge edge); + HRESULT GetPosition(AvnPoint*ret); + HRESULT SetPosition(AvnPoint point); + HRESULT PointToClient(AvnPoint point, AvnPoint*ret); + HRESULT PointToScreen(AvnPoint point, AvnPoint*ret); + HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose); + HRESULT SetTopMost(bool value); + HRESULT SetCursor(IAvnCursor* cursor); + HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret); + HRESULT SetMainMenu(IAvnMenu* menu); + HRESULT ObtainNSWindowHandle(void** retOut); + HRESULT ObtainNSWindowHandleRetained(void** retOut); + HRESULT ObtainNSViewHandle(void** retOut); + HRESULT ObtainNSViewHandleRetained(void** retOut); + HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut); + HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, + IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle); + HRESULT SetBlurEnabled(bool enable); +} + +[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91)] +interface IAvnPopup : IAvnWindowBase +{ + +} + +[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d)] +interface IAvnWindow : IAvnWindowBase +{ + HRESULT SetEnabled(bool enable); + HRESULT SetParent(IAvnWindow* parent); + HRESULT SetCanResize(bool value); + HRESULT SetDecorations(SystemDecorations value); + HRESULT SetTitle(void* utf8Title); + HRESULT SetTitleBarColor(AvnColor color); + HRESULT SetWindowState(AvnWindowState state); + HRESULT GetWindowState(AvnWindowState*ret); + HRESULT TakeFocusFromChildren(); + HRESULT SetExtendClientArea(bool enable); + HRESULT SetExtendClientAreaHints(AvnExtendClientAreaChromeHints hints); + HRESULT GetExtendTitleBarHeight(double*ret); + HRESULT SetExtendTitleBarHeight(double value); +} + +[uuid(939b6599-40a8-4710-a4c8-5d72d8f174fb)] +interface IAvnWindowBaseEvents : IUnknown +{ + HRESULT Paint(); + void Closed(); + void Activated(); + void Deactivated(); + void Resized([const] AvnSize* size); + void PositionChanged(AvnPoint position); + void RawMouseEvent(AvnRawMouseEventType type, + uint timeStamp, + AvnInputModifiers modifiers, + AvnPoint point, + AvnVector delta); + bool RawKeyEvent(AvnRawKeyEventType type, uint timeStamp, AvnInputModifiers modifiers, uint key); + bool RawTextInputEvent(uint timeStamp, [const] char* text); + void ScalingChanged(double scaling); + void RunRenderPriorityJobs(); + void LostFocus(); + AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position, + AvnInputModifiers modifiers, AvnDragDropEffects effects, + IAvnClipboard* clipboard, void* dataObjectHandle); +} + +[uuid(1ae178ee-1fcc-447f-b6dd-b7bb727f934c)] +interface IAvnWindowEvents : IAvnWindowBaseEvents +{ + /** + * Closing Event + * Called when the user presses the OS window close button. + * return true to allow the close, return false to prevent close. + */ + bool Closing(); + + void WindowStateChanged(AvnWindowState state); + + void GotInputWhenDisabled(); +} + +[uuid(e34ae0f8-18b4-48a3-b09d-2e6b19a3cf5e)] +interface IAvnMacOptions : IUnknown +{ + HRESULT SetShowInDock(int show); + HRESULT SetApplicationTitle(void* utf8string); +} + +[uuid(04c1b049-1f43-418a-9159-cae627ec1367)] +interface IAvnActionCallback : IUnknown +{ + void Run(); +} + +[uuid(6df4d2db-0b80-4f59-ad88-0baa5e21eb14)] +interface IAvnSignaledCallback : IUnknown +{ + void Signaled(int priority, bool priorityContainsMeaningfulValue); +} + +[uuid(97330f88-c22b-4a8e-a130-201520091b01)] +interface IAvnLoopCancellation : IUnknown +{ + void Cancel(); +} + +[uuid(fbc06f3d-7860-42df-83fd-53c4b02dd9c3)] +interface IAvnPlatformThreadingInterface : IUnknown +{ + bool GetCurrentThreadIsLoopThread(); + void SetSignaledCallback(IAvnSignaledCallback* cb); + IAvnLoopCancellation* CreateLoopCancellation(); + HRESULT RunLoop(IAvnLoopCancellation* cancel); + // Can't pass int* to sharpgentools for some reason + void Signal(int priority); + IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback); +} + +[uuid(6c621a6e-e4c1-4ae3-9749-83eeeffa09b6)] +interface IAvnSystemDialogEvents : IUnknown +{ + void OnCompleted(int numResults, void* ptrFirstResult); +} + +[uuid(4d7a47db-a944-4061-abe7-62cb6aa0ffd5)] +interface IAvnSystemDialogs : IUnknown +{ + void SelectFolderDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + [const] char* title, + [const] char* initialPath); + + void OpenFileDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + bool allowMultiple, + [const] char* title, + [const] char* initialDirectory, + [const] char* initialFile, + [const] char* filters); + + void SaveFileDialog(IAvnWindow* parentWindowHandle, + IAvnSystemDialogEvents* events, + [const] char* title, + [const] char* initialDirectory, + [const] char* initialFile, + [const] char* filters); +} + +[uuid(9a52bc7a-d8c7-4230-8d34-704a0b70a933)] +interface IAvnScreens : IUnknown +{ + HRESULT GetScreenCount(int* ret); + HRESULT GetScreen(int index, AvnScreen* ret); +} + +[uuid(792b1bd4-76cc-46ea-bfd0-9d642154b1b3)] +interface IAvnClipboard : IUnknown +{ + HRESULT GetText(char* type, IAvnString**ppv); + HRESULT SetText(char* type, void* utf8Text); + HRESULT ObtainFormats(IAvnStringArray**ppv); + HRESULT GetStrings(char* type, IAvnStringArray**ppv); + HRESULT SetBytes(char* type, void* utf8Text, int len); + HRESULT GetBytes(char* type, IAvnString**ppv); + + HRESULT Clear(); +} + +[uuid(3f998545-f027-4d4d-bd2a-1a80926d984e)] +interface IAvnCursor : IUnknown +{ +} + +[uuid(51ecfb12-c427-4757-a2c9-1596bfce53ef)] +interface IAvnCursorFactory : IUnknown +{ + HRESULT GetCursor(AvnStandardCursorType cursorType, IAvnCursor** retOut); +} + +[uuid(60452465-8616-40af-bc00-042e69828ce7)] +interface IAvnGlDisplay : IUnknown +{ + HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv); + void LegacyClearCurrentContext(); + HRESULT WrapContext(void* native, IAvnGlContext**ppv); + void* GetProcAddress(char* proc); +} + +[uuid(78c5711e-2a98-40d2-bac4-0cc9a49dc4f3)] +interface IAvnGlContext : IUnknown +{ + HRESULT MakeCurrent(IUnknown** ppv); + HRESULT LegacyMakeCurrent(); + int GetSampleCount(); + int GetStencilSize(); + void* GetNativeHandle(); +} + +[uuid(931062d2-5bc8-4062-8588-83dd8deb99c2)] +interface IAvnGlSurfaceRenderTarget : IUnknown +{ + HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret); +} + +[uuid(e625b406-f04c-484e-946a-4abd2c6015ad)] +interface IAvnGlSurfaceRenderingSession : IUnknown +{ + HRESULT GetPixelSize(AvnPixelSize* ret); + HRESULT GetScaling(double* ret); +} + +[uuid(a7724dc1-cf6b-4fa8-9d23-228bf2593edc)] +interface IAvnMenu : IUnknown +{ + HRESULT InsertItem(int index, IAvnMenuItem* item); + HRESULT RemoveItem(IAvnMenuItem* item); + HRESULT SetTitle(void* utf8String); + HRESULT Clear(); +} + +[uuid(59e0586d-bd1c-4b85-9882-80d448b0fed9)] +interface IAvnPredicateCallback : IUnknown +{ + bool Evaluate(); +} + +[uuid(f890219a-1720-4cd5-9a26-cd95fccbf53c)] +interface IAvnMenuItem : IUnknown +{ + HRESULT SetSubMenu(IAvnMenu* menu); + HRESULT SetTitle(void* utf8String); + HRESULT SetGesture(void* utf8String, AvnInputModifiers modifiers); + HRESULT SetAction(IAvnPredicateCallback* predicate, IAvnActionCallback* callback); + HRESULT SetIsChecked(bool isChecked); + HRESULT SetToggleType(AvnMenuItemToggleType toggleType); + HRESULT SetIcon(void* data, size_t length); +} + +[uuid(0af7df53-7632-42f4-a650-0992c361b477)] +interface IAvnMenuEvents : IUnknown +{ + /** + * NeedsUpdate + */ + void NeedsUpdate(); +} + +[uuid(5142bb41-66ab-49e7-bb37-cd079c000f27)] +interface IAvnStringArray : IUnknown +{ + uint GetCount(); + HRESULT Get(uint index, IAvnString**ppv); +} + +[uuid(a13d2382-3b3a-4d1c-9b27-8f34653d3f01)] +interface IAvnDndResultCallback : IUnknown +{ + void OnDragAndDropComplete(AvnDragDropEffects effecct); +} + +[uuid(f07c608e-52e9-422d-836e-c70f6e9b80f5)] +interface IAvnGCHandleDeallocatorCallback : IUnknown +{ + void FreeGCHandle(void* handle); +} + +[uuid(91c7f677-f26b-4ff3-93cc-cf15aa966ffa)] +interface IAvnNativeControlHost : IUnknown +{ + HRESULT CreateDefaultChild(void* parent, void** retOut); + IAvnNativeControlHostTopLevelAttachment* CreateAttachment(); + void DestroyDefaultChild(void* child); +} + +[uuid(14a9e164-1aae-4271-bb78-7b5230999b52)] +interface IAvnNativeControlHostTopLevelAttachment : IUnknown +{ + void* GetParentHandle(); + HRESULT InitializeWithChildHandle(void* child); + HRESULT AttachTo(IAvnNativeControlHost* host); + void ShowInBounds(float x, float y, float width, float height); + void HideWithSize(float width, float height); + void ReleaseChild(); +} diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs new file mode 100644 index 0000000000..8613cbba88 --- /dev/null +++ b/src/tools/MicroComGenerator/Ast.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; + +namespace MicroComGenerator.Ast +{ + public class AstAttributeNode + { + public string Name { get; set; } + public string Value { get; set; } + + public AstAttributeNode(string name, string value) + { + Name = name; + Value = value; + } + + public override string ToString() => $"{Name} = {Value}"; + } + + public class AstEnumNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public override string ToString() => Name; + } + + public class AstEnumMemberNode + { + public string Name { get; set; } + public string Value { get; set; } + + public AstEnumMemberNode(string name, string value) + { + Name = name; + Value = value; + } + + public override string ToString() => $"{Name} = {Value}"; + } + + public class AstStructNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public override string ToString() => Name; + } + + public class AstTypeNode + { + public string Name { get; set; } + public int PointerLevel { get; set; } + + public override string ToString() => Name + new string('*', PointerLevel); + } + + public class AstStructMemberNode + { + public string Name { get; set; } + public AstTypeNode Type { get; set; } + + public override string ToString() => $"{Type} {Name}"; + } + + public class AstInterfaceNode : List + { + public List Attributes { get; set; } = new List(); + public string Name { get; set; } + public string Inherits { get; set; } + + public override string ToString() + { + if (Inherits == null) + return Name; + return $"{Name} : {Inherits}"; + } + } + + public class AstInterfaceMemberNode : List + { + public string Name { get; set; } + public AstTypeNode ReturnType { get; set; } + public List Attributes { get; set; } = new List(); + + public override string ToString() => $"{ReturnType} {Name} ({string.Join(", ", this)})"; + } + + public class AstInterfaceMemberArgumentNode + { + public string Name { get; set; } + public AstTypeNode Type { get; set; } + public List Attributes { get; set; } = new List(); + + public override string ToString() => $"{Type} {Name}"; + } + + public class AstIdlNode + { + public List Attributes { get; set; } = new List(); + public List Enums { get; set; } = new List(); + public List Structs { get; set; } = new List(); + public List Interfaces { get; set; } = new List(); + } +} diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs new file mode 100644 index 0000000000..46404da3d7 --- /dev/null +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -0,0 +1,228 @@ +using System.Collections.Generic; +using MicroComGenerator.Ast; + +namespace MicroComGenerator +{ + public class AstParser + { + public static AstIdlNode Parse(string source) + { + var parser = new TokenParser(source); + var idl = new AstIdlNode { Attributes = ParseGlobalAttributes(ref parser) }; + + while (!parser.Eof) + { + var attrs = ParseLocalAttributes(ref parser); + + if (parser.TryParseKeyword("enum")) + idl.Enums.Add(ParseEnum(attrs, ref parser)); + else if (parser.TryParseKeyword("struct")) + idl.Structs.Add(ParseStruct(attrs, ref parser)); + else if (parser.TryParseKeyword("interface")) + idl.Interfaces.Add(ParseInterface(attrs, ref parser)); + else + throw new ParseException("Unexpected character", ref parser); + } + + return idl; + } + + static List ParseGlobalAttributes(ref TokenParser parser) + { + var rv = new List(); + while (!parser.Eof) + { + parser.SkipWhitespace(); + if (parser.TryConsume('@')) + { + var ident = parser.ParseIdentifier("-"); + var value = parser.ReadToEol().Trim(); + if (value == "@@") + { + parser.Advance(1); + value = ""; + while (true) + { + var l = parser.ReadToEol(); + if (l == "@@") + break; + else + value = value.Length == 0 ? l : (value + "\n" + l); + parser.Advance(1); + } + + } + rv.Add(new AstAttributeNode(ident, value)); + } + else + return rv; + } + + return rv; + } + + static List ParseLocalAttributes(ref TokenParser parser) + { + var rv = new List(); + if (parser.TryConsume("[")) + { + while (!parser.TryConsume("]") && !parser.Eof) + { + if (parser.TryConsume(',')) + continue; + + // Get identifier + var ident = parser.ParseIdentifier("-"); + + // No value, end of attribute list + if (parser.TryConsume(']')) + { + rv.Add(new AstAttributeNode(ident, null)); + return rv; + } + // No value, next attribute + else if (parser.TryConsume(',')) + rv.Add(new AstAttributeNode(ident, null)); + // Has value + else if (parser.TryConsume('(')) + { + var value = parser.ReadTo(')'); + parser.Consume(')'); + rv.Add(new AstAttributeNode(ident, value)); + } + else + throw new ParseException("Unexpected character", ref parser); + } + + if (parser.Eof) + throw new ParseException("Unexpected EOF", ref parser); + } + + return rv; + } + + static void EnsureOpenBracket(ref TokenParser parser) + { + if (!parser.TryConsume('{')) + throw new ParseException("{ expected", ref parser); + } + + static AstEnumNode ParseEnum(List attrs, ref TokenParser parser) + { + var name = parser.ParseIdentifier(); + EnsureOpenBracket(ref parser); + var rv = new AstEnumNode { Name = name, Attributes = attrs }; + while (!parser.TryConsume('}') && !parser.Eof) + { + if (parser.TryConsume(',')) + continue; + + var ident = parser.ParseIdentifier(); + + // Automatic value + if (parser.TryConsume(',') || parser.Peek == '}') + { + rv.Add(new AstEnumMemberNode(ident, null)); + continue; + } + + if (!parser.TryConsume('=')) + throw new ParseException("Unexpected character", ref parser); + + var value = parser.ReadToAny(",}").Trim(); + rv.Add(new AstEnumMemberNode(ident, value)); + + if (parser.Eof) + throw new ParseException("Unexpected EOF", ref parser); + } + + + return rv; + } + + static AstTypeNode ParseType(ref TokenParser parser) + { + var ident = parser.ParseIdentifier(); + var t = new AstTypeNode { Name = ident }; + while (parser.TryConsume('*')) + t.PointerLevel++; + return t; + } + + static AstStructNode ParseStruct(List attrs, ref TokenParser parser) + { + var name = parser.ParseIdentifier(); + EnsureOpenBracket(ref parser); + var rv = new AstStructNode { Name = name, Attributes = attrs }; + while (!parser.TryConsume('}') && !parser.Eof) + { + var t = ParseType(ref parser); + bool parsedAtLeastOneMember = false; + while (!parser.TryConsume(';')) + { + // Skip any , + while (parser.TryConsume(',')) { } + + var ident = parser.ParseIdentifier(); + parsedAtLeastOneMember = true; + rv.Add(new AstStructMemberNode { Name = ident, Type = t }); + } + + if (!parsedAtLeastOneMember) + throw new ParseException("Expected at least one enum member with declared type " + t, ref parser); + } + + return rv; + } + + static AstInterfaceNode ParseInterface(List interfaceAttrs, ref TokenParser parser) + { + var interfaceName = parser.ParseIdentifier(); + string inheritsFrom = null; + if (parser.TryConsume(":")) + inheritsFrom = parser.ParseIdentifier(); + + EnsureOpenBracket(ref parser); + var rv = new AstInterfaceNode + { + Name = interfaceName, Attributes = interfaceAttrs, Inherits = inheritsFrom + }; + while (!parser.TryConsume('}') && !parser.Eof) + { + var memberAttrs = ParseLocalAttributes(ref parser); + var returnType = ParseType(ref parser); + var name = parser.ParseIdentifier(); + var member = new AstInterfaceMemberNode + { + Name = name, ReturnType = returnType, Attributes = memberAttrs + }; + rv.Add(member); + + parser.Consume('('); + while (true) + { + if (parser.TryConsume(')')) + break; + + var argumentAttrs = ParseLocalAttributes(ref parser); + var type = ParseType(ref parser); + var argName = parser.ParseIdentifier(); + member.Add(new AstInterfaceMemberArgumentNode + { + Name = argName, Type = type, Attributes = argumentAttrs + }); + + if (parser.TryConsume(')')) + break; + if (parser.TryConsume(',')) + continue; + throw new ParseException("Unexpected character", ref parser); + } + + parser.Consume(';'); + } + + return rv; + } + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs new file mode 100644 index 0000000000..2fcf1b404b --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -0,0 +1,453 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using MicroComGenerator.Ast; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +// ReSharper disable CoVariantArrayConversion + +// HERE BE DRAGONS + +namespace MicroComGenerator +{ + public partial class CSharpGen + { + abstract class Arg + { + public string Name; + public string NativeType; + + public virtual StatementSyntax CreateFixed(StatementSyntax inner) => inner; + + public virtual void PreMarshal(List body) + { + } + + public virtual void PreMarshalForReturn(List body) => + throw new InvalidOperationException("Don't know how to use " + NativeType + " as HRESULT-return"); + + public virtual ExpressionSyntax Value(bool isHresultReturn) => ParseExpression(Name); + public abstract string ManagedType { get; } + public virtual string ReturnManagedType => ManagedType; + + public virtual StatementSyntax[] ReturnMarshalResult() => new[] { ParseStatement("return " + Name + ";") }; + + + public virtual void BackPreMarshal(List body) + { + } + + public virtual ExpressionSyntax BackMarshalValue() => ParseExpression(Name); + public virtual ExpressionSyntax BackMarshalReturn(string resultVar) => ParseExpression(resultVar); + + } + + class InterfaceReturnArg : Arg + { + public string InterfaceType; + public override ExpressionSyntax Value(bool isHresultReturn) => ParseExpression("&" + PName); + public override string ManagedType => InterfaceType; + + private string PName => "__marshal_" + Name; + + public override void PreMarshalForReturn(List body) + { + body.Add(ParseStatement("void* " + PName + " = null;")); + } + + public override StatementSyntax[] ReturnMarshalResult() => new[] + { + ParseStatement("return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + PName + ", true);") + }; + + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression("INVALID"); + } + + public override ExpressionSyntax BackMarshalReturn(string resultVar) + { + return ParseExpression($"Avalonia.MicroCom.MicroComRuntime.GetNativePointer({resultVar}, true)"); + } + } + + class InterfaceArg : Arg + { + public string InterfaceType; + + public override ExpressionSyntax Value(bool isHresultReturn) => + ParseExpression("Avalonia.MicroCom.MicroComRuntime.GetNativePointer(" + Name + ")"); + + public override string ManagedType => InterfaceType; + + public override StatementSyntax[] ReturnMarshalResult() => new[] + { + ParseStatement("return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + Name + ", true);") + }; + + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression("Avalonia.MicroCom.MicroComRuntime.CreateProxyFor<" + InterfaceType + ">(" + + Name + ", false)"); + } + + public override ExpressionSyntax BackMarshalReturn(string resultVar) + { + return ParseExpression($"Avalonia.MicroCom.MicroComRuntime.GetNativePointer({resultVar}, true)"); + } + } + + class BypassArg : Arg + { + public string Type { get; set; } + public int PointerLevel; + public override string ManagedType => Type + new string('*', PointerLevel); + public override string ReturnManagedType => Type + new string('*', PointerLevel - 1); + + public override ExpressionSyntax Value(bool isHresultReturn) + { + if (isHresultReturn) + return ParseExpression("&" + Name); + return base.Value(false); + } + + public override void PreMarshalForReturn(List body) + { + if (PointerLevel == 0) + base.PreMarshalForReturn(body); + else + body.Add(ParseStatement(Type + new string('*', PointerLevel - 1) + " " + Name + "=default;")); + } + } + + class StringArg : Arg + { + private string BName => "__bytemarshal_" + Name; + private string FName => "__fixedmarshal_" + Name; + + public override void PreMarshal(List body) + { + body.Add(ParseStatement($"var {BName} = new byte[System.Text.Encoding.UTF8.GetByteCount({Name})+1];")); + body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name.Length}, {BName}, 0);")); + } + + public override StatementSyntax CreateFixed(StatementSyntax inner) + { + return FixedStatement(DeclareVar("byte*", FName, ParseExpression(BName)), inner); + } + + public override ExpressionSyntax Value(bool isHresultReturn) => ParseExpression(FName); + public override string ManagedType => "string"; + public override ExpressionSyntax BackMarshalValue() + { + return ParseExpression( + $"({Name} == null ? null : System.Runtime.InteropServices.Marshal.PtrToStringAnsi(new IntPtr(" + Name + ")))"); + } + } + + string ConvertNativeType(string type) + { + if (type == "size_t") + return "System.IntPtr"; + if (type == "HRESULT") + return "int"; + return type; + } + + Arg ConvertArg(string name, AstTypeNode type) + { + type = new AstTypeNode { Name = ConvertNativeType(type.Name), PointerLevel = type.PointerLevel }; + + if (type.PointerLevel == 2) + { + if (type.Name.StartsWith("I")) + return new InterfaceReturnArg { Name = name, InterfaceType = type.Name, NativeType = "void**" }; + } + else if (type.PointerLevel == 1) + { + if (type.Name.StartsWith("I")) + return new InterfaceArg { Name = name, InterfaceType = type.Name, NativeType = "void*" }; + if (type.Name == "char") + return new StringArg { Name = name, NativeType = "byte*" }; + } + + return new BypassArg + { + Name = name, Type = type.Name, PointerLevel = type.PointerLevel, NativeType = type.ToString() + }; + } + + + void GenerateInterfaceMember(AstInterfaceMemberNode member, ref InterfaceDeclarationSyntax iface, + ref ClassDeclarationSyntax proxy, ref ClassDeclarationSyntax vtbl, + List vtblCtor, int num) + { + // Prepare method information + var args = member.Select(a => ConvertArg(a.Name, a.Type)).ToList(); + var returnArg = ConvertArg("__result", member.ReturnType); + bool isHresult = member.ReturnType.Name == "HRESULT"; + bool isHresultLastArgumentReturn = isHresult + && args.Count > 0 + && (args.Last().Name == "ppv" || args.Last().Name == "retOut" || args.Last().Name == "ret") + && ((member.Last().Type.PointerLevel > 0 + && !member.Last().Type.Name + .StartsWith("I")) + || member.Last().Type.PointerLevel == 2); + + bool isVoidReturn = member.ReturnType.Name == "void" && member.ReturnType.PointerLevel == 0; + + + // Generate method signature + MethodDeclarationSyntax GenerateManagedSig(string returnType, string name, + IEnumerable<(string n, string t)> args) + => MethodDeclaration(ParseTypeName(returnType), name).WithParameterList( + ParameterList( + SeparatedList(args.Select(x => Parameter(Identifier(x.n)).WithType(ParseTypeName(x.t)))))); + + var managedSig = + isHresult ? + GenerateManagedSig(isHresultLastArgumentReturn ? args.Last().ReturnManagedType : "void", + member.Name, + (isHresultLastArgumentReturn ? args.SkipLast(1) : args).Select(a => (a.Name, a.ManagedType))) : + GenerateManagedSig(returnArg.ManagedType, member.Name, args.Select(a => (a.Name, a.ManagedType))); + + iface = iface.AddMembers(managedSig.WithSemicolonToken(Semicolon())); + + // Prepare args for marshaling + var preMarshal = new List(); + if (!isVoidReturn) + preMarshal.Add(ParseStatement(returnArg.NativeType + " __result;")); + + for (var idx = 0; idx < args.Count; idx++) + { + if (isHresultLastArgumentReturn && idx == args.Count - 1) + args[idx].PreMarshalForReturn(preMarshal); + else + args[idx].PreMarshal(preMarshal); + } + + // Generate call expression + ExpressionSyntax callExpr = InvocationExpression(_localInterop.GetCaller(returnArg.NativeType, + args.Select(x => x.NativeType).ToList())) + .AddArgumentListArguments(Argument(ParseExpression("PPV"))) + .AddArgumentListArguments(args + .Select((a, i) => Argument(a.Value(isHresultLastArgumentReturn && i == args.Count - 1))).ToArray()) + .AddArgumentListArguments(Argument(ParseExpression("PPV[base.VTableSize + " + num + "]"))); + + // Save call result if needed + if (!isVoidReturn) + callExpr = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, ParseExpression("__result"), + callExpr); + + + // Wrap call into fixed() blocks + StatementSyntax callStatement = ExpressionStatement(callExpr); + foreach (var arg in args) + callStatement = arg.CreateFixed(callStatement); + + // Build proxy body + var proxyBody = Block() + .AddStatements(preMarshal.ToArray()) + .AddStatements(callStatement); + + // Process return value + if (!isVoidReturn) + { + if (isHresult) + { + proxyBody = proxyBody.AddStatements( + ParseStatement( + $"if(__result != 0) throw new System.Runtime.InteropServices.COMException(\"{member.Name} failed\", __result);")); + + if (isHresultLastArgumentReturn) + proxyBody = proxyBody.AddStatements(args.Last().ReturnMarshalResult()); + } + else + proxyBody = proxyBody.AddStatements(returnArg.ReturnMarshalResult()); + } + + // Add the proxy method + proxy = proxy.AddMembers(managedSig.AddModifiers(SyntaxKind.PublicKeyword) + .WithBody(proxyBody)); + + + // Generate VTable method + + var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name+"Delegate") + .AddParameterListParameters(Parameter(Identifier("@this")).WithType(ParseTypeName("IntPtr"))) + .AddParameterListParameters(args.Select(x => + Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()); + + var shadowMethod = MethodDeclaration(shadowDelegate.ReturnType, member.Name) + .WithParameterList(shadowDelegate.ParameterList) + .AddModifiers(Token(SyntaxKind.StaticKeyword)); + + var backPreMarshal = new List(); + foreach (var arg in args) + arg.BackPreMarshal(backPreMarshal); + + backPreMarshal.Add( + ParseStatement($"__target = ({iface.Identifier.Text})Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this);")); + + var isBackVoidReturn = isVoidReturn || (isHresult && !isHresultLastArgumentReturn); + + StatementSyntax backCallStatement; + + var backCallExpr = + IsPropertyRewriteCandidate(managedSig) ? + ParseExpression("__target." + member.Name.Substring(3)) : + InvocationExpression(ParseExpression("__target." + member.Name)) + .WithArgumentList(ArgumentList(SeparatedList( + (isHresultLastArgumentReturn ? args.SkipLast(1) : args) + .Select(a => + Argument(a.BackMarshalValue()))))); + + if (isBackVoidReturn) + backCallStatement = ExpressionStatement(backCallExpr); + else + { + backCallStatement = LocalDeclarationStatement(DeclareVar("var", "__result", backCallExpr)); + if (isHresultLastArgumentReturn) + { + backCallStatement = Block(backCallStatement, + ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, + ParseExpression("*" + args.Last().Name), + args.Last().BackMarshalReturn("__result") + ))); + + } + else + backCallStatement = Block(backCallStatement, + ReturnStatement(returnArg.BackMarshalReturn("__result"))); + } + + BlockSyntax backBodyBlock = Block().AddStatements(backPreMarshal.ToArray()).AddStatements(backCallStatement); + + + backBodyBlock = Block( + TryStatement( + SingletonList(CatchClause( + CatchDeclaration(ParseTypeName("System.Exception"), Identifier("__exception__")), null, + Block( + ParseStatement( + "Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__);"), + isHresult ? ParseStatement("return unchecked((int)0x80004005u);") + : isVoidReturn ? EmptyStatement() : ParseStatement("return default;") + )))) + .WithBlock(Block(backBodyBlock)) + ); + if (isHresult) + backBodyBlock = backBodyBlock.AddStatements(ParseStatement("return 0;")); + + + backBodyBlock = Block() + .AddStatements(ParseStatement($"{iface.Identifier.Text} __target = null;")) + .AddStatements(backBodyBlock.Statements.ToArray()); + + shadowMethod = shadowMethod.WithBody(backBodyBlock); + + vtbl = vtbl.AddMembers(shadowDelegate).AddMembers(shadowMethod); + vtblCtor.Add(ParseStatement("base.AddMethod((" + shadowDelegate.Identifier.Text + ")" + + shadowMethod.Identifier.Text + ");")); + + + + + } + + class LocalInteropHelper + { + public ClassDeclarationSyntax Class { get; private set; } = ClassDeclaration("LocalInterop"); + private HashSet _existing = new HashSet(); + + public ExpressionSyntax GetCaller(string returnType, List args) + { + var name = "CalliStdCall" + returnType.Replace("*", "_ptr"); + var signature = returnType + "::" + name + "::" + string.Join("::", args); + if (_existing.Add(signature)) + { + Class = Class.AddMembers(MethodDeclaration(ParseTypeName(returnType), name) + .AddModifiers(SyntaxKind.StaticKeyword, SyntaxKind.UnsafeKeyword, SyntaxKind.PublicKeyword) + .AddParameterListParameters(Parameter(Identifier("thisObj")).WithType(ParseTypeName("void*"))) + .AddParameterListParameters(args.Select((x, i) => + Parameter(Identifier("arg" + i)).WithType(ParseTypeName(x))).ToArray()) + .AddParameterListParameters(Parameter(Identifier("methodPtr")).WithType(ParseTypeName("void*"))) + .WithBody(Block(ExpressionStatement(ThrowExpression(ParseExpression("null")))))); + } + + return ParseExpression("LocalInterop." + name); + } + } + + + void GenerateInterface(ref NamespaceDeclarationSyntax ns, ref NamespaceDeclarationSyntax implNs, + AstInterfaceNode iface) + { + var guidString = iface.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value; + if (guidString == null) + throw new CodeGenException("Missing GUID for " + iface.Name); + var inheritsUnknown = iface.Inherits == null || iface.Inherits == "IUnknown"; + + var ifaceDec = InterfaceDeclaration(iface.Name) + .WithBaseType(inheritsUnknown ? "Avalonia.MicroCom.IUnknown" : iface.Inherits) + .AddModifiers(Token(_visibility), Token(SyntaxKind.UnsafeKeyword)); + + var proxyClassName = "__MicroCom" + iface.Name + "Proxy"; + var proxy = ClassDeclaration(proxyClassName) + .AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility)) + .WithBaseType(inheritsUnknown ? + "Avalonia.MicroCom.MicroComProxyBase" : + ("__MicroCom" + iface.Inherits + "Proxy")); + + + // Generate vtable + var vtbl = ClassDeclaration("__MicroCom" + iface.Name + "VTable") + .AddModifiers(Token(SyntaxKind.UnsafeKeyword)); + + vtbl = vtbl.WithBaseType(inheritsUnknown ? + "Avalonia.MicroCom.MicroComVtblBase" : + "__MicroCom" + iface.Inherits + "VTable"); + + var vtblCtor = new List(); + for (var idx = 0; idx < iface.Count; idx++) + GenerateInterfaceMember(iface[idx], ref ifaceDec, ref proxy, ref vtbl, vtblCtor, idx); + + vtbl = vtbl.AddMembers( + ConstructorDeclaration(vtbl.Identifier.Text) + .AddModifiers(Token(SyntaxKind.PublicKeyword)) + .WithBody(Block(vtblCtor)) + ) + .AddMembers(MethodDeclaration(ParseTypeName("void"), "__MicroComModuleInit") + .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) + .WithExpressionBody(ArrowExpressionClause( + ParseExpression("Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(" + + proxyClassName + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) + .WithSemicolonToken(Semicolon())); + + + // Finalize proxy code + proxy = proxy.AddMembers( + MethodDeclaration(ParseTypeName("void"), "__MicroComModuleInit") + .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) + .WithBody(Block( + ParseStatement("Avalonia.MicroCom.MicroComRuntime.Register(typeof(" + + proxyClassName + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + + proxyClassName + "(p, owns));") + ))) + .AddMembers(ParseMemberDeclaration("public " + proxyClassName + + "(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) {}")) + .AddMembers(ParseMemberDeclaration("protected override int VTableSize => base.VTableSize + " + + iface.Count + ";")); + + ns = ns.AddMembers(RewriteMethodsToProperties(ifaceDec)); + implNs = implNs.AddMembers(RewriteMethodsToProperties(proxy), RewriteMethodsToProperties(vtbl)); + } + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.Utils.cs b/src/tools/MicroComGenerator/CSharpGen.Utils.cs new file mode 100644 index 0000000000..ed2bcdd6d8 --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.Utils.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Formatting; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +namespace MicroComGenerator +{ + public partial class CSharpGen + { + + CompilationUnitSyntax Unit() + => CompilationUnit().WithUsings(List(new[] + { + "System", "System.Text", "System.Collections", "System.Collections.Generic", "Avalonia.MicroCom" + } + .Concat(_extraUsings).Select(u => UsingDirective(IdentifierName(u))))); + + string Format(CompilationUnitSyntax unit) + { + var cw = new AdhocWorkspace(); + return Microsoft.CodeAnalysis.Formatting.Formatter.Format(unit.NormalizeWhitespace(), cw, cw.Options + .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, true) + .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, true) + .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, true) + .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true) + + ).ToFullString(); + } + + + SyntaxToken Semicolon() => Token(SyntaxKind.SemicolonToken); + + static VariableDeclarationSyntax DeclareVar(string type, string name, + ExpressionSyntax? initializer = null) + => VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList(VariableDeclarator(name) + .WithInitializer(initializer == null ? null : EqualsValueClause(initializer)))); + + FieldDeclarationSyntax DeclareConstant(string type, string name, LiteralExpressionSyntax value) + => FieldDeclaration( + VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList( + VariableDeclarator(name).WithInitializer(EqualsValueClause(value)) + )) + ).WithSemicolonToken(Semicolon()) + .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ConstKeyword))); + + FieldDeclarationSyntax DeclareField(string type, string name, params SyntaxKind[] modifiers) => + DeclareField(type, name, null, modifiers); + + FieldDeclarationSyntax DeclareField(string type, string name, EqualsValueClauseSyntax initializer, + params SyntaxKind[] modifiers) => + FieldDeclaration( + VariableDeclaration(ParseTypeName(type), + SingletonSeparatedList( + VariableDeclarator(name).WithInitializer(initializer)))) + .WithSemicolonToken(Semicolon()) + .WithModifiers(TokenList(modifiers.Select(x => Token(x)))); + + bool IsPropertyRewriteCandidate(MethodDeclarationSyntax method) + { + if(method.Identifier.Text.Contains("GetScaling")) + Console.WriteLine(); + return (method.Identifier.Text.StartsWith("Get") && + method.ParameterList.Parameters.Count == 0); + } + + TypeDeclarationSyntax RewriteMethodsToProperties(T decl) where T : TypeDeclarationSyntax + { + var replace = new Dictionary(); + foreach (var method in decl.Members.OfType().ToList()) + { + if (IsPropertyRewriteCandidate(method)) + { + var getter = AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); + if (method.Body != null) + getter = getter.WithBody(method.Body); + else + getter = getter.WithSemicolonToken(Semicolon()); + + replace[method] = PropertyDeclaration(method.ReturnType, + method.Identifier.Text.Substring(3)) + .WithModifiers(method.Modifiers).AddAccessorListAccessors(getter); + + } + } + + return decl.ReplaceNodes(replace.Keys, (m, m2) => replace[m]); + } + + } +} diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs new file mode 100644 index 0000000000..49e4f7a09e --- /dev/null +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using MicroComGenerator.Ast; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +// ReSharper disable CoVariantArrayConversion + +namespace MicroComGenerator +{ + public partial class CSharpGen + { + private readonly AstIdlNode _idl; + private List _extraUsings; + private string _namespace; + private SyntaxKind _visibility; + private LocalInteropHelper _localInterop = new LocalInteropHelper(); + + public CSharpGen(AstIdlNode idl) + { + _idl = idl; + _extraUsings = _idl.Attributes.Where(u => u.Name == "clr-using").Select(u => u.Value).ToList(); + _namespace = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-namespace")?.Value; + if (_namespace == null) + throw new CodeGenException("Missing clr-namespace attribute"); + var visibilityString = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-access")?.Value; + if (visibilityString == null) + throw new CodeGenException("Missing clr-visibility attribute"); + if (visibilityString == "internal") + _visibility = SyntaxKind.InternalKeyword; + else if (visibilityString == "public") + _visibility = SyntaxKind.PublicKeyword; + else + throw new CodeGenException("Invalid clr-access attribute"); + } + + public string Generate() + { + var ns = NamespaceDeclaration(ParseName(_namespace)); + var implNs = NamespaceDeclaration(ParseName(_namespace + ".Impl")); + ns = GenerateEnums(ns); + ns = GenerateStructs(ns); + foreach (var i in _idl.Interfaces) + GenerateInterface(ref ns, ref implNs, i); + + implNs = implNs.AddMembers(_localInterop.Class); + var unit = Unit().AddMembers(ns, implNs); + + return Format(unit); + } + + NamespaceDeclarationSyntax GenerateEnums(NamespaceDeclarationSyntax ns) + { + return ns.AddMembers(_idl.Enums.Select(e => + EnumDeclaration(e.Name) + .WithModifiers(TokenList(Token(_visibility))) + .WithMembers(SeparatedList(e.Select(m => + { + var member = EnumMemberDeclaration(m.Name); + if (m.Value != null) + return member.WithEqualsValue(EqualsValueClause(ParseExpression(m.Value))); + return member; + }))) + ).ToArray()); + } + + NamespaceDeclarationSyntax GenerateStructs(NamespaceDeclarationSyntax ns) + { + return ns.AddMembers(_idl.Structs.Select(e => + StructDeclaration(e.Name) + .WithModifiers(TokenList(Token(_visibility))) + .AddModifiers(Token(SyntaxKind.UnsafeKeyword)) + .AddAttributeLists(AttributeList(SingletonSeparatedList( + Attribute(ParseName("System.Runtime.InteropServices.StructLayout"), + AttributeArgumentList(SingletonSeparatedList( + AttributeArgument( + ParseExpression("System.Runtime.InteropServices.LayoutKind.Sequential")))) + )))) + .WithMembers(new SyntaxList(SeparatedList(e.Select(m => + DeclareField(m.Type.ToString(), m.Name, SyntaxKind.PublicKeyword))))) + ).ToArray()); + } + + + + } +} diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs new file mode 100644 index 0000000000..133902f764 --- /dev/null +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -0,0 +1,108 @@ +using System; +using System.Linq; +using System.Text; +using MicroComGenerator.Ast; + +namespace MicroComGenerator +{ + public class CppGen + { + static string ConvertType(AstTypeNode type) + { + var name = type.Name; + if (name == "byte") + name = "unsigned char"; + else if(name == "uint") + name = "unsigned int"; + return name + new string('*', type.PointerLevel); + } + + public static string GenerateCpp(AstIdlNode idl) + { + var sb = new StringBuilder(); + var preamble = idl.Attributes.FirstOrDefault(x => x.Name == "cpp-preamble")?.Value; + if (preamble != null) + sb.AppendLine(preamble); + + foreach (var s in idl.Structs) + sb.AppendLine("struct " + s.Name + ";"); + + foreach (var s in idl.Interfaces) + sb.AppendLine("struct " + s.Name + ";"); + + foreach (var en in idl.Enums) + { + sb.Append("enum "); + if (en.Attributes.Any(a => a.Name == "class-enum")) + sb.Append("class "); + sb.Append(en.Name).Append(" "); + sb.AppendLine(en.Name).AppendLine("{"); + + foreach (var m in en) + { + sb.Append(" ").Append(m.Name); + if (m.Value != null) + sb.Append(" = ").Append(m.Value); + sb.AppendLine(","); + } + + sb.AppendLine("};"); + } + + foreach (var s in idl.Structs) + { + sb.Append("struct ").AppendLine(s.Name).AppendLine("{"); + foreach (var m in s) + sb.Append(" ").Append(ConvertType(m.Type)).Append(" ").Append(m.Name).AppendLine(";"); + + sb.AppendLine("};"); + } + + foreach (var i in idl.Interfaces) + { + var guidString = i.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value; + if (guidString == null) + throw new CodeGenException("Missing uuid for " + i.Name); + + var guid = Guid.Parse(guidString).ToString().Replace("-", ""); + + + sb.Append("COMINTERFACE(").Append(i.Name).Append(", ") + .Append(guid.Substring(0, 8)).Append(", ") + .Append(guid.Substring(8, 4)).Append(", ") + .Append(guid.Substring(12, 4)); + for (var c = 0; c < 8; c++) + { + sb.Append(", ").Append(guid.Substring(16 + c * 2, 2)); + } + + sb.Append(") : ") + .AppendLine(i.Inherits ?? "IUnknown") + .AppendLine("{"); + + foreach (var m in i) + { + sb.Append(" ").Append(ConvertType(m.ReturnType)).Append(" ").Append(m.Name).AppendLine(" ("); + for (var c = 0; c < m.Count; c++) + { + var arg = m[c]; + sb.Append(" "); + if (arg.Attributes.Any(a => a.Name == "const")) + sb.Append("const "); + sb.Append(ConvertType(arg.Type)) + .Append(" ") + .Append(arg.Name); + if (c != m.Count - 1) + sb.Append(", "); + sb.AppendLine(); + sb.AppendLine(" );"); + } + } + + sb.AppendLine("}"); + } + + return sb.ToString(); + } + } +} diff --git a/src/tools/MicroComGenerator/Extensions.cs b/src/tools/MicroComGenerator/Extensions.cs new file mode 100644 index 0000000000..4942442d1b --- /dev/null +++ b/src/tools/MicroComGenerator/Extensions.cs @@ -0,0 +1,90 @@ + +using System; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +namespace MicroComGenerator +{ + public static class Extensions + { + public static ClassDeclarationSyntax AddModifiers(this ClassDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static MethodDeclarationSyntax AddModifiers(this MethodDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static PropertyDeclarationSyntax AddModifiers(this PropertyDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static ConstructorDeclarationSyntax AddModifiers(this ConstructorDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static AccessorDeclarationSyntax AddModifiers(this AccessorDeclarationSyntax cl, params SyntaxKind[] modifiers) + { + if (modifiers == null) + return cl; + return cl.AddModifiers(modifiers.Select(x => SyntaxFactory.Token(x)).ToArray()); + } + + public static string WithLowerFirst(this string s) + { + if (string.IsNullOrEmpty(s)) + return s; + return char.ToLowerInvariant(s[0]) + s.Substring(1); + } + + public static ExpressionSyntax MemberAccess(params string[] identifiers) + { + if (identifiers == null || identifiers.Length == 0) + throw new ArgumentException(); + var expr = (ExpressionSyntax)IdentifierName(identifiers[0]); + for (var c = 1; c < identifiers.Length; c++) + expr = MemberAccess(expr, identifiers[c]); + return expr; + } + + public static ExpressionSyntax MemberAccess(ExpressionSyntax expr, params string[] identifiers) + { + foreach (var i in identifiers) + expr = MemberAccess(expr, i); + return expr; + } + + public static MemberAccessExpressionSyntax MemberAccess(ExpressionSyntax expr, string identifier) => + MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, IdentifierName(identifier)); + + public static ClassDeclarationSyntax WithBaseType(this ClassDeclarationSyntax cl, string bt) + { + return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); + } + + public static InterfaceDeclarationSyntax WithBaseType(this InterfaceDeclarationSyntax cl, string bt) + { + return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); + } + + public static string StripPrefix(this string s, string prefix) => string.IsNullOrEmpty(s) + ? s + : s.StartsWith(prefix) + ? s.Substring(prefix.Length) + : s; + } +} diff --git a/src/tools/MicroComGenerator/MicroComGenerator.csproj b/src/tools/MicroComGenerator/MicroComGenerator.csproj new file mode 100644 index 0000000000..193bb9a100 --- /dev/null +++ b/src/tools/MicroComGenerator/MicroComGenerator.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/src/tools/MicroComGenerator/ParseException.cs b/src/tools/MicroComGenerator/ParseException.cs new file mode 100644 index 0000000000..dfa8dcfe54 --- /dev/null +++ b/src/tools/MicroComGenerator/ParseException.cs @@ -0,0 +1,27 @@ +using System; + +namespace MicroComGenerator +{ + class ParseException : Exception + { + public int Line { get; } + public int Position { get; } + + public ParseException(string message, int line, int position) : base(message) + { + Line = line; + Position = position; + } + + public ParseException(string message, ref TokenParser parser) : this(message, parser.Line, parser.Position) + { + } + } + + class CodeGenException : Exception + { + public CodeGenException(string message) : base(message) + { + } + } +} diff --git a/src/tools/MicroComGenerator/Program.cs b/src/tools/MicroComGenerator/Program.cs new file mode 100644 index 0000000000..578ba1465d --- /dev/null +++ b/src/tools/MicroComGenerator/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using System.Linq; +using CommandLine; + +namespace MicroComGenerator +{ + class Program + { + public class Options + { + [Option('i', "input", Required = true, HelpText = "Input IDL file")] + public string Input { get; set; } + + [Option("cpp", Required = false, HelpText = "C++ output file")] + public string CppOutput { get; set; } + + [Option("cs", Required = false, HelpText = "C# output file")] + public string CSharpOutput { get; set; } + + } + + static int Main(string[] args) + { + var p = Parser.Default.ParseArguments(args); + if (p is NotParsed) + { + return 1; + } + + var opts = ((Parsed)p).Value; + + var text = File.ReadAllText(opts.Input); + var ast = AstParser.Parse(text); + + if (opts.CppOutput != null) + File.WriteAllText(opts.CppOutput, CppGen.GenerateCpp(ast)); + if (opts.CSharpOutput != null) + File.WriteAllText(opts.CSharpOutput, new CSharpGen(ast).Generate()); + + return 0; + } + } +} diff --git a/src/tools/MicroComGenerator/TokenParser.cs b/src/tools/MicroComGenerator/TokenParser.cs new file mode 100644 index 0000000000..ea8850b8e4 --- /dev/null +++ b/src/tools/MicroComGenerator/TokenParser.cs @@ -0,0 +1,417 @@ +using System; +using System.Globalization; +using System.IO; + +namespace MicroComGenerator +{ + internal ref struct TokenParser + { + private ReadOnlySpan _s; + public int Position { get; private set; } + public int Line { get; private set; } + public TokenParser(ReadOnlySpan s) + { + _s = s; + Position = 0; + Line = 0; + } + + public void SkipWhitespace() + { + while (true) + { + if(_s.Length == 0) + return; + if (char.IsWhiteSpace(_s[0])) + Advance(1); + else if (_s[0] == '/' && _s.Length>1) + { + if (_s[1] == '/') + SkipOneLineComment(); + else if (_s[1] == '*') + SkipMultiLineComment(); + else + return; + } + else + return; + } + } + + void SkipOneLineComment() + { + while (true) + { + if (_s.Length > 0 && _s[0] != '\n' && _s[0] != '\r') + Advance(1); + else + return; + } + } + + void SkipMultiLineComment() + { + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("No matched */ found for /*", l, p); + + if (_s[0] == '*' && _s.Length > 1 && _s[1] == '/') + { + Advance(2); + return; + } + + Advance(1); + } + } + + static bool IsAlphaNumeric(char ch) => (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || + (ch >= 'A' && ch <= 'Z'); + + public void Consume(char c) + { + if (!TryConsume(c)) + throw new ParseException("Expected " + c, Line, Position); + } + public bool TryConsume(char c) + { + SkipWhitespace(); + if (_s.Length == 0 || _s[0] != c) + return false; + + Advance(1); + return true; + } + + public bool TryConsume(string s) + { + SkipWhitespace(); + if (_s.Length < s.Length) + return false; + for (var c = 0; c < s.Length; c++) + { + if (_s[c] != s[c]) + return false; + } + + Advance(s.Length); + return true; + } + + public bool TryConsumeAny(ReadOnlySpan chars, out char token) + { + SkipWhitespace(); + token = default; + if (_s.Length == 0) + return false; + + foreach (var c in chars) + { + if (c == _s[0]) + { + token = c; + Advance(1); + return true; + } + } + + return false; + } + + + public bool TryParseKeyword(string keyword) + { + SkipWhitespace(); + if (keyword.Length > _s.Length) + return false; + for(var c=0; c keyword.Length && IsAlphaNumeric(_s[keyword.Length])) + return false; + + Advance(keyword.Length); + return true; + } + + public bool TryParseKeywordLowerCase(string keywordInLowerCase) + { + SkipWhitespace(); + if (keywordInLowerCase.Length > _s.Length) + return false; + for(var c=0; c keywordInLowerCase.Length && IsAlphaNumeric(_s[keywordInLowerCase.Length])) + return false; + + Advance(keywordInLowerCase.Length); + return true; + } + + public void Advance(int c) + { + while (c > 0) + { + if (_s[0] == '\n') + { + Line++; + Position = 0; + } + else + Position++; + + _s = _s.Slice(1); + c--; + } + } + + public int Length => _s.Length; + public bool Eof + { + get + { + SkipWhitespace(); + return Length == 0; + } + } + + public char Peek + { + get + { + if (_s.Length == 0) + throw new ParseException("Unexpected EOF", Line, Position); + return _s[0]; + } + } + + public string ParseIdentifier(ReadOnlySpan extraValidChars) + { + if (!TryParseIdentifier(extraValidChars, out var ident)) + throw new ParseException("Identifier expected", Line, Position); + return ident.ToString(); + } + + public string ParseIdentifier() + { + if (!TryParseIdentifier(out var ident)) + throw new ParseException("Identifier expected", Line, Position); + return ident.ToString(); + } + + public bool TryParseIdentifier(ReadOnlySpan extraValidChars, out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_')) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if (IsAlphaNumeric(ch) || ch == '_') + len++; + else + { + var found = false; + foreach(var vc in extraValidChars) + if (vc == ch) + { + found = true; + break; + } + + if (found) + len++; + else + break; + } + } + + res = _s.Slice(0, len); + Advance(len); + return true; + } + + public bool TryParseIdentifier(out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_')) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if (IsAlphaNumeric(ch) || ch == '_') + len++; + else + break; + } + + res = _s.Slice(0, len); + Advance(len); + return true; + } + + public string ReadToEol() + { + var initial = _s; + var len = 0; + while (true) + { + if (_s.Length > 0 && _s[0] != '\n' && _s[0] != '\r') + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public string ReadTo(char c) + { + var initial = _s; + var len = 0; + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("Expected " + c + " before EOF", l, p); + + if (_s[0] != c) + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public string ReadToAny(ReadOnlySpan chars) + { + var initial = _s; + var len = 0; + var l = Line; + var p = Position; + while (true) + { + if (_s.Length == 0) + throw new ParseException("Expected any of '" + chars.ToString() + "' before EOF", l, p); + + var foundTerminator = false; + foreach (var term in chars) + { + if (_s[0] == term) + { + foundTerminator = true; + break; + } + } + + if (!foundTerminator) + { + len++; + Advance(1); + } + else + return initial.Slice(0, len).ToString(); + } + } + + public bool TryParseCall(out ReadOnlySpan res) + { + res = ReadOnlySpan.Empty; + SkipWhitespace(); + if (_s.Length == 0) + return false; + var first = _s[0]; + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z'))) + return false; + int len = 1; + for (var c = 1; c < _s.Length; c++) + { + var ch = _s[c]; + if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch<= 'Z') || ch == '.') + len++; + else + break; + } + + res = _s.Slice(0, len); + + // Find '(' + for (var c = len; c < _s.Length; c++) + { + if(char.IsWhiteSpace(_s[c])) + continue; + if(_s[c]=='(') + { + Advance(c + 1); + return true; + } + + return false; + + } + + return false; + + } + + + public bool TryParseFloat(out float res) + { + res = 0; + SkipWhitespace(); + if (_s.Length == 0) + return false; + + var len = 0; + var dotCount = 0; + for (var c = 0; c < _s.Length; c++) + { + var ch = _s[c]; + if (ch >= '0' && ch <= '9') + len = c + 1; + else if (ch == '.' && dotCount == 0) + { + len = c + 1; + dotCount++; + } + else + break; + } + + var span = _s.Slice(0, len); + +#if NETSTANDARD2_0 + if (!float.TryParse(span.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out res)) + return false; +#else + if (!float.TryParse(span, NumberStyles.Number, CultureInfo.InvariantCulture, out res)) + return false; +#endif + Advance(len); + return true; + } + + public override string ToString() => _s.ToString(); + + } +} From b8686877afcbdd2016c622fe77895649a868c607 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Tue, 27 Oct 2020 20:29:03 +0200 Subject: [PATCH 031/314] add failing test for issue #4945 --- .../Selection/InternalSelectionModelTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs b/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs index ce3e698cf3..8701fc2479 100644 --- a/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs @@ -232,6 +232,39 @@ namespace Avalonia.Controls.UnitTests.Selection Assert.Contains(nameof(target.SelectedItem), changed); } + [Fact] + public void Raises_Selection_Changed_On_Item_Move() + { + var items = new AvaloniaList(new[] { "foo", "bar", "baz" }); + var target = CreateTarget(source: items); + + target.SelectedIndex = 1; + + var changed = new List(); + + target.PropertyChanged += (s, e) => changed.Add(e.PropertyName); + + var oldSelectedIndex = target.SelectedIndex; + var oldSelectedItem = target.SelectedItem; + + + var sel = items[1]; + var other = items[2]; + + items[2] = sel; + items[1] = other; + + Assert.NotEqual(oldSelectedIndex, target.SelectedIndex); + Assert.NotEqual(oldSelectedItem, target.SelectedItem); + + Assert.Equal(-1, target.SelectedIndex); + Assert.Equal(null, target.SelectedItem); + + Assert.Contains(nameof(target.SelectedIndex), changed); + Assert.Contains(nameof(target.SelectedItem), changed); + } + + [Fact] public void Preserves_SelectedItem_On_Items_Reset() { From 53a06aed3b3f23e0ac05822b2047c7bd19179b7d Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Tue, 27 Oct 2020 20:40:49 +0200 Subject: [PATCH 032/314] fix notification for selected item in listbox issue #4945 --- src/Avalonia.Controls/Selection/SelectionModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.Controls/Selection/SelectionModel.cs b/src/Avalonia.Controls/Selection/SelectionModel.cs index 054974e4f1..6ae53a4d59 100644 --- a/src/Avalonia.Controls/Selection/SelectionModel.cs +++ b/src/Avalonia.Controls/Selection/SelectionModel.cs @@ -443,6 +443,7 @@ namespace Avalonia.Controls.Selection } if ((e.Action == NotifyCollectionChangedAction.Remove && e.OldStartingIndex <= oldSelectedIndex) || + (e.Action == NotifyCollectionChangedAction.Replace && e.OldStartingIndex == oldSelectedIndex) || e.Action == NotifyCollectionChangedAction.Reset) { RaisePropertyChanged(nameof(SelectedItem)); From aeb08c7ae3b3ad800ec2cc70ec73088a04152c10 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 16:56:26 +0300 Subject: [PATCH 033/314] Use MicroCom instead of SharpGen (NOT TESTED YET) --- src/Avalonia.MicroCom/IUnknown.cs | 4 - src/Avalonia.MicroCom/MicroComProxyBase.cs | 33 +- src/Avalonia.MicroCom/MicroComRuntime.cs | 11 +- src/Avalonia.MicroCom/MicroComShadow.cs | 2 +- src/Avalonia.Native/.gitignore | 1 + src/Avalonia.Native/Avalonia.Native.csproj | 27 +- .../AvaloniaNativeMenuExporter.cs | 7 +- src/Avalonia.Native/AvaloniaNativePlatform.cs | 12 +- .../AvaloniaNativePlatformOpenGlInterface.cs | 4 +- src/Avalonia.Native/AvnString.cs | 22 +- src/Avalonia.Native/CallbackBase.cs | 78 +- src/Avalonia.Native/ClipboardImpl.cs | 16 +- src/Avalonia.Native/DeferredFramebuffer.cs | 7 +- src/Avalonia.Native/Generated/Enumerations.cs | 628 ---- src/Avalonia.Native/Generated/Functions.cs | 5 - src/Avalonia.Native/Generated/Interfaces.cs | 3092 ----------------- src/Avalonia.Native/Generated/LocalInterop.cs | 202 -- src/Avalonia.Native/Generated/Structures.cs | 246 -- src/Avalonia.Native/Helpers.cs | 2 +- src/Avalonia.Native/IAvnMenu.cs | 45 +- src/Avalonia.Native/IAvnMenuItem.cs | 41 +- src/Avalonia.Native/NativeControlHostImpl.cs | 4 +- .../PlatformThreadingInterface.cs | 5 +- src/Avalonia.Native/ScreenImpl.cs | 2 +- src/Avalonia.Native/SystemDialogs.cs | 8 +- src/Avalonia.Native/WindowImpl.cs | 28 +- src/Avalonia.Native/WindowImplBase.cs | 18 +- src/Avalonia.Native/avn.idl | 42 +- src/tools/MicroComGenerator/Ast.cs | 175 +- src/tools/MicroComGenerator/AstParser.cs | 17 +- .../CSharpGen.InterfaceGen.cs | 18 +- .../MicroComGenerator/CSharpGen.Utils.cs | 25 +- src/tools/MicroComGenerator/CSharpGen.cs | 52 +- src/tools/MicroComGenerator/CppGen.cs | 7 +- .../MicroComGenerator.csproj | 2 - 35 files changed, 457 insertions(+), 4431 deletions(-) delete mode 100644 src/Avalonia.Native/Generated/Enumerations.cs delete mode 100644 src/Avalonia.Native/Generated/Functions.cs delete mode 100644 src/Avalonia.Native/Generated/Interfaces.cs delete mode 100644 src/Avalonia.Native/Generated/LocalInterop.cs delete mode 100644 src/Avalonia.Native/Generated/Structures.cs diff --git a/src/Avalonia.MicroCom/IUnknown.cs b/src/Avalonia.MicroCom/IUnknown.cs index a46953ced9..0dc4106423 100644 --- a/src/Avalonia.MicroCom/IUnknown.cs +++ b/src/Avalonia.MicroCom/IUnknown.cs @@ -4,9 +4,5 @@ namespace Avalonia.MicroCom { public interface IUnknown : IDisposable { - void AddRef(); - void Release(); - int QueryInterface(Guid guid, out IntPtr ppv); - T QueryInterface() where T : IUnknown; } } diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs index 56b80c2632..6a13fb10c4 100644 --- a/src/Avalonia.MicroCom/MicroComProxyBase.cs +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -1,12 +1,15 @@ using System; +using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; +using System.Threading; namespace Avalonia.MicroCom { - public unsafe class MicroComProxyBase : IUnknown + public unsafe class MicroComProxyBase : CriticalFinalizerObject, IUnknown { private IntPtr _nativePointer; private bool _ownsHandle; + private SynchronizationContext _synchronizationContext; public IntPtr NativePointer { @@ -24,6 +27,9 @@ namespace Avalonia.MicroCom { _nativePointer = nativePointer; _ownsHandle = ownsHandle; + _synchronizationContext = SynchronizationContext.Current; + if(!_ownsHandle) + GC.SuppressFinalize(this); } protected virtual int VTableSize => 3; @@ -56,13 +62,16 @@ namespace Avalonia.MicroCom } public bool IsDisposed => _nativePointer == IntPtr.Zero; - - public void Dispose() + + protected virtual void Dispose(bool disposing) { if (_ownsHandle) Release(); _nativePointer = IntPtr.Zero; + GC.SuppressFinalize(this); } + + public void Dispose() => Dispose(true); public bool OwnsHandle => _ownsHandle; @@ -70,9 +79,27 @@ namespace Avalonia.MicroCom { if (!_ownsHandle) { + GC.ReRegisterForFinalize(true); AddRef(); _ownsHandle = true; } } + + private static readonly SendOrPostCallback _disposeDelegate = DisposeOnContext; + + private static void DisposeOnContext(object state) + { + (state as MicroComProxyBase)?.Dispose(false); + } + + ~MicroComProxyBase() + { + if(!_ownsHandle) + return; + if (_synchronizationContext == null) + Dispose(); + else + _synchronizationContext.Post(_disposeDelegate, this); + } } } diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs index eccf24b496..d43568631a 100644 --- a/src/Avalonia.MicroCom/MicroComRuntime.cs +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -34,9 +34,10 @@ namespace Avalonia.MicroCom public static Guid GetGuidFor(Type type) => _guids[type]; - public static T CreateProxyFor(void* ppv, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(ppv), ownsHandle); + public static T CreateProxyFor(void* pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), new IntPtr(pObject), ownsHandle); + public static T CreateProxyFor(IntPtr pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), pObject, ownsHandle); - public static object CreateProxyFor(Type type, IntPtr ppv, bool ownsHandle) => _factories[type](ppv, ownsHandle); + public static object CreateProxyFor(Type type, IntPtr pObject, bool ownsHandle) => _factories[type](pObject, ownsHandle); public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown { @@ -84,5 +85,11 @@ namespace Avalonia.MicroCom } } + + public static T CloneReference(T iface) where T : IUnknown + { + var ownedPointer = GetNativePointer(iface, true); + return CreateProxyFor(ownedPointer, true); + } } } diff --git a/src/Avalonia.MicroCom/MicroComShadow.cs b/src/Avalonia.MicroCom/MicroComShadow.cs index c9411a089e..a6a0fd519e 100644 --- a/src/Avalonia.MicroCom/MicroComShadow.cs +++ b/src/Avalonia.MicroCom/MicroComShadow.cs @@ -77,7 +77,7 @@ namespace Avalonia.MicroCom { try { - Target.OnUnreferencedFromNative(); + Target.OnReferencedFromNative(); } catch (Exception e) { diff --git a/src/Avalonia.Native/.gitignore b/src/Avalonia.Native/.gitignore index b1153e777c..b270c05962 100644 --- a/src/Avalonia.Native/.gitignore +++ b/src/Avalonia.Native/.gitignore @@ -1 +1,2 @@ Generated/*.cs +*.Generated.cs diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index 49bd578290..a3e99595c2 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -21,11 +21,30 @@ - - - - + + + + + false + all + true + + + + + + + + + + + + + + <_AvaloniaPatchComInterop>true + + \ No newline at end of file diff --git a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs index 6d1b95b997..b192de95de 100644 --- a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs +++ b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs @@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.Platform; using Avalonia.Dialogs; using Avalonia.Native.Interop; +using Avalonia.Native.Interop.Impl; using Avalonia.Threading; namespace Avalonia.Native @@ -15,7 +16,7 @@ namespace Avalonia.Native private bool _exported = false; private IAvnWindow _nativeWindow; private NativeMenu _menu; - private IAvnMenu _nativeMenu; + private __MicroComIAvnMenuProxy _nativeMenu; public AvaloniaNativeMenuExporter(IAvnWindow nativeWindow, IAvaloniaNativeFactory factory) { @@ -135,7 +136,7 @@ namespace Avalonia.Native if (_nativeMenu is null) { - _nativeMenu = IAvnMenu.Create(_factory); + _nativeMenu = (__MicroComIAvnMenuProxy)__MicroComIAvnMenuProxy.Create(_factory); _nativeMenu.Initialise(this, appMenuHolder, ""); @@ -156,7 +157,7 @@ namespace Avalonia.Native if (_nativeMenu is null) { - _nativeMenu = IAvnMenu.Create(_factory); + _nativeMenu = __MicroComIAvnMenuProxy.Create(_factory); _nativeMenu.Initialise(this, menu, ""); diff --git a/src/Avalonia.Native/AvaloniaNativePlatform.cs b/src/Avalonia.Native/AvaloniaNativePlatform.cs index e8b2f065c7..6ce55e17b3 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatform.cs +++ b/src/Avalonia.Native/AvaloniaNativePlatform.cs @@ -4,6 +4,7 @@ using System.Security.Cryptography; using Avalonia.Controls.Platform; using Avalonia.Input; using Avalonia.Input.Platform; +using Avalonia.MicroCom; using Avalonia.Native.Interop; using Avalonia.OpenGL; using Avalonia.Platform; @@ -29,7 +30,7 @@ namespace Avalonia.Native public static AvaloniaNativePlatform Initialize(IntPtr factory, AvaloniaNativePlatformOptions options) { - var result = new AvaloniaNativePlatform(new IAvaloniaNativeFactory(factory)); + var result = new AvaloniaNativePlatform(MicroComRuntime.CreateProxyFor(factory, true)); result.DoInitialize(options); return result; @@ -65,10 +66,7 @@ namespace Avalonia.Native { if(!string.IsNullOrWhiteSpace(Application.Current.Name)) { - using (var buffer = new Utf8Buffer(Application.Current.Name)) - { - _factory.MacOptions.SetApplicationTitle(buffer.DangerousGetHandle()); - } + _factory.MacOptions.SetApplicationTitle(Application.Current.Name); } } @@ -93,7 +91,7 @@ namespace Avalonia.Native { var macOpts = AvaloniaLocator.Current.GetService(); - _factory.MacOptions.ShowInDock = macOpts?.ShowInDock != false ? 1 : 0; + _factory.MacOptions.SetShowInDock(macOpts?.ShowInDock != false ? 1 : 0); } AvaloniaLocator.CurrentMutable @@ -153,7 +151,7 @@ namespace Avalonia.Native set { _showInDock = value; - _opts.ShowInDock = value ? 1 : 0; + _opts.SetShowInDock(value ? 1 : 0); } } } diff --git a/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs b/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs index dbe968b82f..3b3d8836fd 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs +++ b/src/Avalonia.Native/AvaloniaNativePlatformOpenGlInterface.cs @@ -150,12 +150,12 @@ namespace Avalonia.Native { get { - var s = _session.GetPixelSize(); + var s = _session.PixelSize; return new PixelSize(s.Width, s.Height); } } - public double Scaling => _session.GetScaling(); + public double Scaling => _session.Scaling; public bool IsYFlipped => true; diff --git a/src/Avalonia.Native/AvnString.cs b/src/Avalonia.Native/AvnString.cs index 11b1a33276..dcd473bae3 100644 --- a/src/Avalonia.Native/AvnString.cs +++ b/src/Avalonia.Native/AvnString.cs @@ -1,8 +1,22 @@ +using System; using System.Runtime.InteropServices; namespace Avalonia.Native.Interop { - unsafe partial class IAvnString + partial interface IAvnString + { + public string String { get; } + public byte[] Bytes { get; } + } + + partial interface IAvnStringArray + { + string[] ToStringArray(); + } +} +namespace Avalonia.Native.Interop.Impl +{ + unsafe partial class __MicroComIAvnStringProxy { private string _managed; private byte[] _bytes; @@ -16,7 +30,7 @@ namespace Avalonia.Native.Interop var ptr = Pointer(); if (ptr == null) return null; - _managed = System.Text.Encoding.UTF8.GetString((byte*)ptr.ToPointer(), Length()); + _managed = System.Text.Encoding.UTF8.GetString((byte*)ptr, Length()); } return _managed; @@ -30,7 +44,7 @@ namespace Avalonia.Native.Interop if (_bytes == null) { _bytes = new byte[Length()]; - Marshal.Copy(Pointer(), _bytes, 0, _bytes.Length); + Marshal.Copy(new IntPtr(Pointer()), _bytes, 0, _bytes.Length); } return _bytes; @@ -40,7 +54,7 @@ namespace Avalonia.Native.Interop public override string ToString() => String; } - partial class IAvnStringArray + partial class __MicroComIAvnStringArrayProxy { public string[] ToStringArray() { diff --git a/src/Avalonia.Native/CallbackBase.cs b/src/Avalonia.Native/CallbackBase.cs index 4cda358d0a..455ed4b159 100644 --- a/src/Avalonia.Native/CallbackBase.cs +++ b/src/Avalonia.Native/CallbackBase.cs @@ -1,44 +1,30 @@ using System; using System.Runtime.ExceptionServices; -using SharpGen.Runtime; +using Avalonia.MicroCom; using Avalonia.Platform; namespace Avalonia.Native { - public class CallbackBase : SharpGen.Runtime.IUnknown, IExceptionCallback + public class CallbackBase : IUnknown, IMicroComShadowContainer, IMicroComExceptionCallback { - private uint _refCount; - private bool _disposed; private readonly object _lock = new object(); - private ShadowContainer _shadow; + private bool _referencedFromManaged = true; + private bool _referencedFromNative = false; + private bool _destroyed; + - public CallbackBase() - { - _refCount = 1; - } - - public ShadowContainer Shadow + protected virtual void Destroyed() { - get => _shadow; - set - { - lock (_lock) - { - if (_disposed && value != null) - { - throw new ObjectDisposedException("CallbackBase"); - } - _shadow = value; - } - } } - public uint AddRef() + public void RaiseException(Exception e) { - lock (_lock) + if (AvaloniaLocator.Current.GetService() is PlatformThreadingInterface threadingInterface) { - return ++_refCount; + threadingInterface.TerminateNativeApp(); + + threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e)); } } @@ -46,43 +32,35 @@ namespace Avalonia.Native { lock (_lock) { - if (!_disposed) - { - _disposed = true; - Release(); - } + _referencedFromManaged = false; + DestroyIfNeeded(); } } - public uint Release() + void DestroyIfNeeded() { - lock (_lock) + if(_destroyed) + return; + if (_referencedFromManaged == false && _referencedFromNative == false) { - _refCount--; - - if (_refCount == 0) - { - Shadow?.Dispose(); - Shadow = null; - Destroyed(); - } - - return _refCount; + _destroyed = true; + Destroyed(); } } - protected virtual void Destroyed() + public MicroComShadow Shadow { get; set; } + public void OnReferencedFromNative() { - + lock (_lock) + _referencedFromNative = true; } - public void RaiseException(Exception e) + public void OnUnreferencedFromNative() { - if (AvaloniaLocator.Current.GetService() is PlatformThreadingInterface threadingInterface) + lock (_lock) { - threadingInterface.TerminateNativeApp(); - - threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e)); + _referencedFromNative = false; + DestroyIfNeeded(); } } } diff --git a/src/Avalonia.Native/ClipboardImpl.cs b/src/Avalonia.Native/ClipboardImpl.cs index 554e7a497a..4ee590516b 100644 --- a/src/Avalonia.Native/ClipboardImpl.cs +++ b/src/Avalonia.Native/ClipboardImpl.cs @@ -35,17 +35,12 @@ namespace Avalonia.Native return Task.FromResult(text.String); } - public Task SetTextAsync(string text) + public unsafe Task SetTextAsync(string text) { _native.Clear(); - if (text != null) - { - using (var buffer = new Utf8Buffer(text)) - { - _native.SetText(NSPasteboardTypeString, buffer.DangerousGetHandle()); - } - } + if (text != null) + _native.SetText(NSPasteboardTypeString, text); return Task.CompletedTask; } @@ -90,11 +85,10 @@ namespace Avalonia.Native { var o = data.Get(fmt); if(o is string s) - using (var b = new Utf8Buffer(s)) - _native.SetText(fmt, b.DangerousGetHandle()); + _native.SetText(fmt, s); else if(o is byte[] bytes) fixed (byte* pbytes = bytes) - _native.SetBytes(fmt, new IntPtr(pbytes), bytes.Length); + _native.SetBytes(fmt, pbytes, bytes.Length); } return Task.CompletedTask; } diff --git a/src/Avalonia.Native/DeferredFramebuffer.cs b/src/Avalonia.Native/DeferredFramebuffer.cs index 8ea7b20b8c..950b6a3197 100644 --- a/src/Avalonia.Native/DeferredFramebuffer.cs +++ b/src/Avalonia.Native/DeferredFramebuffer.cs @@ -2,11 +2,10 @@ using System.Runtime.InteropServices; using Avalonia.Native.Interop; using Avalonia.Platform; -using SharpGen.Runtime; namespace Avalonia.Native { - public class DeferredFramebuffer : ILockedFramebuffer + internal unsafe class DeferredFramebuffer : ILockedFramebuffer { private readonly Func, bool> _lockWindow; @@ -56,7 +55,7 @@ namespace Avalonia.Native { var fb = new AvnFramebuffer { - Data = Address, + Data = Address.ToPointer(), Dpi = new AvnVector { X = Dpi.X, @@ -70,7 +69,7 @@ namespace Avalonia.Native using (var d = new Disposer(Address)) { - win.ThreadSafeSetSwRenderedFrame(ref fb, d); + win.ThreadSafeSetSwRenderedFrame(&fb, d); } })) { diff --git a/src/Avalonia.Native/Generated/Enumerations.cs b/src/Avalonia.Native/Generated/Enumerations.cs deleted file mode 100644 index 0b30ce50c0..0000000000 --- a/src/Avalonia.Native/Generated/Enumerations.cs +++ /dev/null @@ -1,628 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - /// - /// No documentation. - /// - /// AvnDragDropEffects - /// AvnDragDropEffects - public enum AvnDragDropEffects : System.Int32 - { - /// - /// No documentation. - /// - /// None - /// None - None = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Copy - /// Copy - Copy = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Move - /// Move - Move = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Link - /// Link - Link = unchecked ((System.Int32)(4))} - - /// - /// No documentation. - /// - /// AvnDragEventType - /// AvnDragEventType - public enum AvnDragEventType : System.Int32 - { - /// - /// No documentation. - /// - /// Enter - /// Enter - Enter = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Over - /// Over - Over = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Leave - /// Leave - Leave = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Drop - /// Drop - Drop = unchecked ((System.Int32)(3))} - - /// - /// No documentation. - /// - /// AvnExtendClientAreaChromeHints - /// AvnExtendClientAreaChromeHints - public enum AvnExtendClientAreaChromeHints : System.Int32 - { - /// - /// No documentation. - /// - /// AvnNoChrome - /// AvnNoChrome - AvnNoChrome = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// AvnSystemChrome - /// AvnSystemChrome - AvnSystemChrome = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// AvnPreferSystemChrome - /// AvnPreferSystemChrome - AvnPreferSystemChrome = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// AvnOSXThickTitleBar - /// AvnOSXThickTitleBar - AvnOSXThickTitleBar = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// AvnDefaultChrome - /// AvnDefaultChrome - AvnDefaultChrome = unchecked ((System.Int32)(1))} - - /// - /// No documentation. - /// - /// AvnInputModifiers - /// AvnInputModifiers - public enum AvnInputModifiers : System.Int32 - { - /// - /// No documentation. - /// - /// AvnInputModifiersNone - /// AvnInputModifiersNone - AvnInputModifiersNone = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Alt - /// Alt - Alt = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Control - /// Control - Control = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// Shift - /// Shift - Shift = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// Windows - /// Windows - Windows = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// LeftMouseButton - /// LeftMouseButton - LeftMouseButton = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// RightMouseButton - /// RightMouseButton - RightMouseButton = unchecked ((System.Int32)(32)), - /// - /// No documentation. - /// - /// MiddleMouseButton - /// MiddleMouseButton - MiddleMouseButton = unchecked ((System.Int32)(64)), - /// - /// No documentation. - /// - /// XButton1MouseButton - /// XButton1MouseButton - XButton1MouseButton = unchecked ((System.Int32)(128)), - /// - /// No documentation. - /// - /// XButton2MouseButton - /// XButton2MouseButton - XButton2MouseButton = unchecked ((System.Int32)(256))} - - /// - /// No documentation. - /// - /// AvnMenuItemToggleType - /// AvnMenuItemToggleType - public enum AvnMenuItemToggleType : System.Int32 - { - /// - /// No documentation. - /// - /// None - /// None - None = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// CheckMark - /// CheckMark - CheckMark = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Radio - /// Radio - Radio = unchecked ((System.Int32)(2))} - - /// - /// No documentation. - /// - /// AvnPixelFormat - /// AvnPixelFormat - public enum AvnPixelFormat : System.Int32 - { - /// - /// No documentation. - /// - /// kAvnRgb565 - /// kAvnRgb565 - KAvnRgb565 = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// kAvnRgba8888 - /// kAvnRgba8888 - KAvnRgba8888 = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// kAvnBgra8888 - /// kAvnBgra8888 - KAvnBgra8888 = unchecked ((System.Int32)(2))} - - /// - /// No documentation. - /// - /// AvnRawKeyEventType - /// AvnRawKeyEventType - public enum AvnRawKeyEventType : System.Int32 - { - /// - /// No documentation. - /// - /// KeyDown - /// KeyDown - KeyDown = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// KeyUp - /// KeyUp - KeyUp = unchecked ((System.Int32)(1))} - - /// - /// No documentation. - /// - /// AvnRawMouseEventType - /// AvnRawMouseEventType - public enum AvnRawMouseEventType : System.Int32 - { - /// - /// No documentation. - /// - /// LeaveWindow - /// LeaveWindow - LeaveWindow = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// LeftButtonDown - /// LeftButtonDown - LeftButtonDown = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// LeftButtonUp - /// LeftButtonUp - LeftButtonUp = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// RightButtonDown - /// RightButtonDown - RightButtonDown = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// RightButtonUp - /// RightButtonUp - RightButtonUp = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// MiddleButtonDown - /// MiddleButtonDown - MiddleButtonDown = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// MiddleButtonUp - /// MiddleButtonUp - MiddleButtonUp = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// XButton1Down - /// XButton1Down - XButton1Down = unchecked ((System.Int32)(7)), - /// - /// No documentation. - /// - /// XButton1Up - /// XButton1Up - XButton1Up = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// XButton2Down - /// XButton2Down - XButton2Down = unchecked ((System.Int32)(9)), - /// - /// No documentation. - /// - /// XButton2Up - /// XButton2Up - XButton2Up = unchecked ((System.Int32)(10)), - /// - /// No documentation. - /// - /// Move - /// Move - Move = unchecked ((System.Int32)(11)), - /// - /// No documentation. - /// - /// Wheel - /// Wheel - Wheel = unchecked ((System.Int32)(12)), - /// - /// No documentation. - /// - /// NonClientLeftButtonDown - /// NonClientLeftButtonDown - NonClientLeftButtonDown = unchecked ((System.Int32)(13)), - /// - /// No documentation. - /// - /// TouchBegin - /// TouchBegin - TouchBegin = unchecked ((System.Int32)(14)), - /// - /// No documentation. - /// - /// TouchUpdate - /// TouchUpdate - TouchUpdate = unchecked ((System.Int32)(15)), - /// - /// No documentation. - /// - /// TouchEnd - /// TouchEnd - TouchEnd = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// TouchCancel - /// TouchCancel - TouchCancel = unchecked ((System.Int32)(17))} - - /// - /// No documentation. - /// - /// AvnStandardCursorType - /// AvnStandardCursorType - public enum AvnStandardCursorType : System.Int32 - { - /// - /// No documentation. - /// - /// CursorArrow - /// CursorArrow - CursorArrow = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// CursorIbeam - /// CursorIbeam - CursorIbeam = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// CursorWait - /// CursorWait - CursorWait = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// CursorCross - /// CursorCross - CursorCross = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// CursorUpArrow - /// CursorUpArrow - CursorUpArrow = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// CursorSizeWestEast - /// CursorSizeWestEast - CursorSizeWestEast = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// CursorSizeNorthSouth - /// CursorSizeNorthSouth - CursorSizeNorthSouth = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// CursorSizeAll - /// CursorSizeAll - CursorSizeAll = unchecked ((System.Int32)(7)), - /// - /// No documentation. - /// - /// CursorNo - /// CursorNo - CursorNo = unchecked ((System.Int32)(8)), - /// - /// No documentation. - /// - /// CursorHand - /// CursorHand - CursorHand = unchecked ((System.Int32)(9)), - /// - /// No documentation. - /// - /// CursorAppStarting - /// CursorAppStarting - CursorAppStarting = unchecked ((System.Int32)(10)), - /// - /// No documentation. - /// - /// CursorHelp - /// CursorHelp - CursorHelp = unchecked ((System.Int32)(11)), - /// - /// No documentation. - /// - /// CursorTopSide - /// CursorTopSide - CursorTopSide = unchecked ((System.Int32)(12)), - /// - /// No documentation. - /// - /// CursorBottomSize - /// CursorBottomSize - CursorBottomSize = unchecked ((System.Int32)(13)), - /// - /// No documentation. - /// - /// CursorLeftSide - /// CursorLeftSide - CursorLeftSide = unchecked ((System.Int32)(14)), - /// - /// No documentation. - /// - /// CursorRightSide - /// CursorRightSide - CursorRightSide = unchecked ((System.Int32)(15)), - /// - /// No documentation. - /// - /// CursorTopLeftCorner - /// CursorTopLeftCorner - CursorTopLeftCorner = unchecked ((System.Int32)(16)), - /// - /// No documentation. - /// - /// CursorTopRightCorner - /// CursorTopRightCorner - CursorTopRightCorner = unchecked ((System.Int32)(17)), - /// - /// No documentation. - /// - /// CursorBottomLeftCorner - /// CursorBottomLeftCorner - CursorBottomLeftCorner = unchecked ((System.Int32)(18)), - /// - /// No documentation. - /// - /// CursorBottomRightCorner - /// CursorBottomRightCorner - CursorBottomRightCorner = unchecked ((System.Int32)(19)), - /// - /// No documentation. - /// - /// CursorDragMove - /// CursorDragMove - CursorDragMove = unchecked ((System.Int32)(20)), - /// - /// No documentation. - /// - /// CursorDragCopy - /// CursorDragCopy - CursorDragCopy = unchecked ((System.Int32)(21)), - /// - /// No documentation. - /// - /// CursorDragLink - /// CursorDragLink - CursorDragLink = unchecked ((System.Int32)(22)), - /// - /// No documentation. - /// - /// CursorNone - /// CursorNone - CursorNone = unchecked ((System.Int32)(23))} - - /// - /// No documentation. - /// - /// AvnWindowEdge - /// AvnWindowEdge - public enum AvnWindowEdge : System.Int32 - { - /// - /// No documentation. - /// - /// WindowEdgeNorthWest - /// WindowEdgeNorthWest - WindowEdgeNorthWest = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// WindowEdgeNorth - /// WindowEdgeNorth - WindowEdgeNorth = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// WindowEdgeNorthEast - /// WindowEdgeNorthEast - WindowEdgeNorthEast = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// WindowEdgeWest - /// WindowEdgeWest - WindowEdgeWest = unchecked ((System.Int32)(3)), - /// - /// No documentation. - /// - /// WindowEdgeEast - /// WindowEdgeEast - WindowEdgeEast = unchecked ((System.Int32)(4)), - /// - /// No documentation. - /// - /// WindowEdgeSouthWest - /// WindowEdgeSouthWest - WindowEdgeSouthWest = unchecked ((System.Int32)(5)), - /// - /// No documentation. - /// - /// WindowEdgeSouth - /// WindowEdgeSouth - WindowEdgeSouth = unchecked ((System.Int32)(6)), - /// - /// No documentation. - /// - /// WindowEdgeSouthEast - /// WindowEdgeSouthEast - WindowEdgeSouthEast = unchecked ((System.Int32)(7))} - - /// - /// No documentation. - /// - /// AvnWindowState - /// AvnWindowState - public enum AvnWindowState : System.Int32 - { - /// - /// No documentation. - /// - /// Normal - /// Normal - Normal = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// Minimized - /// Minimized - Minimized = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// Maximized - /// Maximized - Maximized = unchecked ((System.Int32)(2)), - /// - /// No documentation. - /// - /// FullScreen - /// FullScreen - FullScreen = unchecked ((System.Int32)(3))} - - /// - /// No documentation. - /// - /// SystemDecorations - /// SystemDecorations - public enum SystemDecorations : System.Int32 - { - /// - /// No documentation. - /// - /// SystemDecorationsNone - /// SystemDecorationsNone - SystemDecorationsNone = unchecked ((System.Int32)(0)), - /// - /// No documentation. - /// - /// SystemDecorationsBorderOnly - /// SystemDecorationsBorderOnly - SystemDecorationsBorderOnly = unchecked ((System.Int32)(1)), - /// - /// No documentation. - /// - /// SystemDecorationsFull - /// SystemDecorationsFull - SystemDecorationsFull = unchecked ((System.Int32)(2))} -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Functions.cs b/src/Avalonia.Native/Generated/Functions.cs deleted file mode 100644 index 6ab648dc50..0000000000 --- a/src/Avalonia.Native/Generated/Functions.cs +++ /dev/null @@ -1,5 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Interfaces.cs b/src/Avalonia.Native/Generated/Interfaces.cs deleted file mode 100644 index 161ada1e50..0000000000 --- a/src/Avalonia.Native/Generated/Interfaces.cs +++ /dev/null @@ -1,3092 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f01")] - public partial class IAvaloniaNativeFactory : SharpGen.Runtime.ComObject - { - public IAvaloniaNativeFactory(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvaloniaNativeFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvaloniaNativeFactory(nativePtr); - /// - /// No documentation. - /// - /// GetMacOptions - /// GetMacOptions - public Avalonia.Native.Interop.IAvnMacOptions MacOptions - { - get => GetMacOptions(); - } - - /// - /// No documentation. - /// - /// SetAppMenu - /// SetAppMenu - public Avalonia.Native.Interop.IAvnMenu AppMenu - { - set => SetAppMenu(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::Initialize([In] IAvnGCHandleDeallocatorCallback* deallocator) - /// IAvaloniaNativeFactory::Initialize - public unsafe void Initialize(Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallback deallocator) - { - System.IntPtr deallocator_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - deallocator_ = SharpGen.Runtime.CppObject.ToCallbackPtr(deallocator); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)deallocator_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(deallocator); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnMacOptions* IAvaloniaNativeFactory::GetMacOptions() - /// IAvaloniaNativeFactory::GetMacOptions - internal unsafe Avalonia.Native.Interop.IAvnMacOptions GetMacOptions() - { - Avalonia.Native.Interop.IAvnMacOptions __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnMacOptions(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateWindow([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnWindow** ppv) - /// IAvaloniaNativeFactory::CreateWindow - public unsafe Avalonia.Native.Interop.IAvnWindow CreateWindow(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) - { - System.IntPtr cb_ = System.IntPtr.Zero; - System.IntPtr gl_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnWindow vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnWindow(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - System.GC.KeepAlive(gl); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreatePopup([In] IAvnWindowEvents* cb,[In] IAvnGlContext* gl,[In] IAvnPopup** ppv) - /// IAvaloniaNativeFactory::CreatePopup - public unsafe Avalonia.Native.Interop.IAvnPopup CreatePopup(Avalonia.Native.Interop.IAvnWindowEvents cb, Avalonia.Native.Interop.IAvnGlContext gl) - { - System.IntPtr cb_ = System.IntPtr.Zero; - System.IntPtr gl_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnPopup vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - gl_ = SharpGen.Runtime.CppObject.ToCallbackPtr(gl); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, (void *)gl_, &vOut_, (*(void ***)this._nativePointer)[6]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnPopup(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - System.GC.KeepAlive(gl); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreatePlatformThreadingInterface([In] IAvnPlatformThreadingInterface** ppv) - /// IAvaloniaNativeFactory::CreatePlatformThreadingInterface - public unsafe Avalonia.Native.Interop.IAvnPlatformThreadingInterface CreatePlatformThreadingInterface() - { - Avalonia.Native.Interop.IAvnPlatformThreadingInterface vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[7]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnPlatformThreadingInterface(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateSystemDialogs([In] IAvnSystemDialogs** ppv) - /// IAvaloniaNativeFactory::CreateSystemDialogs - public unsafe Avalonia.Native.Interop.IAvnSystemDialogs CreateSystemDialogs() - { - Avalonia.Native.Interop.IAvnSystemDialogs vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[8]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnSystemDialogs(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateScreens([In] IAvnScreens** ppv) - /// IAvaloniaNativeFactory::CreateScreens - public unsafe Avalonia.Native.Interop.IAvnScreens CreateScreens() - { - Avalonia.Native.Interop.IAvnScreens vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[9]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnScreens(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateClipboard([In] IAvnClipboard** ppv) - /// IAvaloniaNativeFactory::CreateClipboard - public unsafe Avalonia.Native.Interop.IAvnClipboard CreateClipboard() - { - Avalonia.Native.Interop.IAvnClipboard vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[10]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateDndClipboard([In] IAvnClipboard** ppv) - /// IAvaloniaNativeFactory::CreateDndClipboard - public unsafe Avalonia.Native.Interop.IAvnClipboard CreateDndClipboard() - { - Avalonia.Native.Interop.IAvnClipboard vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[11]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnClipboard(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateCursorFactory([In] IAvnCursorFactory** ppv) - /// IAvaloniaNativeFactory::CreateCursorFactory - public unsafe Avalonia.Native.Interop.IAvnCursorFactory CreateCursorFactory() - { - Avalonia.Native.Interop.IAvnCursorFactory vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[12]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnCursorFactory(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::ObtainGlDisplay([In] IAvnGlDisplay** ppv) - /// IAvaloniaNativeFactory::ObtainGlDisplay - public unsafe Avalonia.Native.Interop.IAvnGlDisplay ObtainGlDisplay() - { - Avalonia.Native.Interop.IAvnGlDisplay vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[13]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlDisplay(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::SetAppMenu([In] IAvnMenu* menu) - /// IAvaloniaNativeFactory::SetAppMenu - internal unsafe void SetAppMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[14]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenu([In] IAvnMenuEvents* cb,[In] IAvnMenu** ppv) - /// IAvaloniaNativeFactory::CreateMenu - public unsafe Avalonia.Native.Interop.IAvnMenu CreateMenu(Avalonia.Native.Interop.IAvnMenuEvents cb) - { - System.IntPtr cb_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnMenu vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cb_, &vOut_, (*(void ***)this._nativePointer)[15]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenu(vOut_); - else - vOut = null; - System.GC.KeepAlive(cb); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenuItem([In] IAvnMenuItem** ppv) - /// IAvaloniaNativeFactory::CreateMenuItem - public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItem() - { - Avalonia.Native.Interop.IAvnMenuItem vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[16]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvaloniaNativeFactory::CreateMenuItemSeperator([In] IAvnMenuItem** ppv) - /// IAvaloniaNativeFactory::CreateMenuItemSeperator - public unsafe Avalonia.Native.Interop.IAvnMenuItem CreateMenuItemSeperator() - { - Avalonia.Native.Interop.IAvnMenuItem vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[17]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnMenuItem(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - } - - class IAvnActionCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnActionCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnActionCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new RunDelegate(Run)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RunDelegate(System.IntPtr thisObject); - private static unsafe void Run(System.IntPtr thisObject) - { - try - { - IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; - @this.Run(); - } - catch (System.Exception __exception__) - { - IAvnActionCallback @this = (IAvnActionCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnActionCallbackShadow.IAvnActionCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f08"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnActionCallbackShadow))] - public partial interface IAvnActionCallback : SharpGen.Runtime.IUnknown - { - void Run(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0f")] - public partial class IAvnClipboard : SharpGen.Runtime.ComObject - { - public IAvnClipboard(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnClipboard(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnClipboard(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetText([In] char* type,[In] IAvnString** ppv) - /// IAvnClipboard::GetText - public unsafe Avalonia.Native.Interop.IAvnString GetText(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::SetText([In] char* type,[In] void* utf8Text) - /// IAvnClipboard::SetText - public unsafe void SetText(System.String type, System.IntPtr utf8Text) - { - System.IntPtr type_; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, (*(void ***)this._nativePointer)[4]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnClipboard::ObtainFormats([In] IAvnStringArray** ppv) - /// IAvnClipboard::ObtainFormats - public unsafe Avalonia.Native.Interop.IAvnStringArray ObtainFormats() - { - Avalonia.Native.Interop.IAvnStringArray vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetStrings([In] char* type,[In] IAvnStringArray** ppv) - /// IAvnClipboard::GetStrings - public unsafe Avalonia.Native.Interop.IAvnStringArray GetStrings(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnStringArray vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[6]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnStringArray(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::SetBytes([In] char* type,[In] void* utf8Text,[In] int len) - /// IAvnClipboard::SetBytes - public unsafe void SetBytes(System.String type, System.IntPtr utf8Text, System.Int32 len) - { - System.IntPtr type_; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, (void *)utf8Text, len, (*(void ***)this._nativePointer)[7]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnClipboard::GetBytes([In] char* type,[In] IAvnString** ppv) - /// IAvnClipboard::GetBytes - public unsafe Avalonia.Native.Interop.IAvnString GetBytes(System.String type) - { - System.IntPtr type_; - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - type_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(type); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)type_, &vOut_, (*(void ***)this._nativePointer)[8]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - System.Runtime.InteropServices.Marshal.FreeHGlobal(type_); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnClipboard::Clear() - /// IAvnClipboard::Clear - public unsafe void Clear() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f10")] - public partial class IAvnCursor : SharpGen.Runtime.ComObject - { - public IAvnCursor(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnCursor(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursor(nativePtr); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f11")] - public partial class IAvnCursorFactory : SharpGen.Runtime.ComObject - { - public IAvnCursorFactory(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnCursorFactory(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnCursorFactory(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnCursorFactory::GetCursor([In] AvnStandardCursorType cursorType,[Out] IAvnCursor** retOut) - /// IAvnCursorFactory::GetCursor - public unsafe Avalonia.Native.Interop.IAvnCursor GetCursor(Avalonia.Native.Interop.AvnStandardCursorType cursorType) - { - Avalonia.Native.Interop.IAvnCursor retOut; - System.IntPtr retOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)cursorType), &retOut_, (*(void ***)this._nativePointer)[3]); - if (retOut_ != System.IntPtr.Zero) - retOut = new Avalonia.Native.Interop.IAvnCursor(retOut_); - else - retOut = null; - __result__.CheckError(); - return retOut; - } - } - - class IAvnDndResultCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnDndResultCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnDndResultCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new OnDragAndDropCompleteDelegate(OnDragAndDropComplete)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void OnDragAndDropCompleteDelegate(System.IntPtr thisObject, int arg0); - private static unsafe void OnDragAndDropComplete(System.IntPtr thisObject, int param0) - { - try - { - Avalonia.Native.Interop.AvnDragDropEffects effecct = default (Avalonia.Native.Interop.AvnDragDropEffects); - effecct = (Avalonia.Native.Interop.AvnDragDropEffects)param0; - IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; - @this.OnDragAndDropComplete(effecct); - } - catch (System.Exception __exception__) - { - IAvnDndResultCallback @this = (IAvnDndResultCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnDndResultCallbackShadow.IAvnDndResultCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnDndResultCallbackShadow))] - public partial interface IAvnDndResultCallback : SharpGen.Runtime.IUnknown - { - void OnDragAndDropComplete(Avalonia.Native.Interop.AvnDragDropEffects effecct); - } - - class IAvnGCHandleDeallocatorCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnGCHandleDeallocatorCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnGCHandleDeallocatorCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new FreeGCHandleDelegate(FreeGCHandle)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void FreeGCHandleDelegate(System.IntPtr thisObject, void *arg0); - private static unsafe void FreeGCHandle(System.IntPtr thisObject, void *param0) - { - try - { - System.IntPtr handle = default (System.IntPtr); - handle = (System.IntPtr)param0; - IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; - @this.FreeGCHandle(handle); - } - catch (System.Exception __exception__) - { - IAvnGCHandleDeallocatorCallback @this = (IAvnGCHandleDeallocatorCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow.IAvnGCHandleDeallocatorCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f22"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnGCHandleDeallocatorCallbackShadow))] - public partial interface IAvnGCHandleDeallocatorCallback : SharpGen.Runtime.IUnknown - { - void FreeGCHandle(System.IntPtr handle); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f14")] - public partial class IAvnGlContext : SharpGen.Runtime.ComObject - { - public IAvnGlContext(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlContext(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlContext(nativePtr); - /// - /// No documentation. - /// - /// GetSampleCount - /// GetSampleCount - public System.Int32 SampleCount - { - get => GetSampleCount(); - } - - /// - /// No documentation. - /// - /// GetStencilSize - /// GetStencilSize - public System.Int32 StencilSize - { - get => GetStencilSize(); - } - - /// - /// No documentation. - /// - /// GetNativeHandle - /// GetNativeHandle - public System.IntPtr NativeHandle - { - get => GetNativeHandle(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlContext::MakeCurrent([In] IUnknown** ppv) - /// IAvnGlContext::MakeCurrent - public unsafe SharpGen.Runtime.IUnknown MakeCurrent() - { - SharpGen.Runtime.IUnknown vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new SharpGen.Runtime.ComObject(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlContext::LegacyMakeCurrent() - /// IAvnGlContext::LegacyMakeCurrent - public unsafe void LegacyMakeCurrent() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// int IAvnGlContext::GetSampleCount() - /// IAvnGlContext::GetSampleCount - internal unsafe System.Int32 GetSampleCount() - { - System.Int32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// int IAvnGlContext::GetStencilSize() - /// IAvnGlContext::GetStencilSize - internal unsafe System.Int32 GetStencilSize() - { - System.Int32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void* IAvnGlContext::GetNativeHandle() - /// IAvnGlContext::GetNativeHandle - internal unsafe System.IntPtr GetNativeHandle() - { - System.IntPtr __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[7]); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f13")] - public partial class IAvnGlDisplay : SharpGen.Runtime.ComObject - { - public IAvnGlDisplay(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlDisplay(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlDisplay(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnGlDisplay::CreateContext([In] IAvnGlContext* share,[In] IAvnGlContext** ppv) - /// IAvnGlDisplay::CreateContext - public unsafe Avalonia.Native.Interop.IAvnGlContext CreateContext(Avalonia.Native.Interop.IAvnGlContext share) - { - System.IntPtr share_ = System.IntPtr.Zero; - Avalonia.Native.Interop.IAvnGlContext vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - share_ = SharpGen.Runtime.CppObject.ToCallbackPtr(share); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)share_, &vOut_, (*(void ***)this._nativePointer)[3]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); - else - vOut = null; - System.GC.KeepAlive(share); - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// void IAvnGlDisplay::LegacyClearCurrentContext() - /// IAvnGlDisplay::LegacyClearCurrentContext - public unsafe void LegacyClearCurrentContext() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[4]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnGlDisplay::WrapContext([In] void* native,[In] IAvnGlContext** ppv) - /// IAvnGlDisplay::WrapContext - public unsafe Avalonia.Native.Interop.IAvnGlContext WrapContext(System.IntPtr native) - { - Avalonia.Native.Interop.IAvnGlContext vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)native, &vOut_, (*(void ***)this._nativePointer)[5]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnGlContext(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// void* IAvnGlDisplay::GetProcAddress([In] char* proc) - /// IAvnGlDisplay::GetProcAddress - public unsafe System.IntPtr GetProcAddress(System.String rocRef) - { - System.IntPtr rocRef_; - System.IntPtr __result__; - rocRef_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(rocRef); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (void *)rocRef_, (*(void ***)this._nativePointer)[6]); - System.Runtime.InteropServices.Marshal.FreeHGlobal(rocRef_); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f16")] - public partial class IAvnGlSurfaceRenderingSession : SharpGen.Runtime.ComObject - { - public IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlSurfaceRenderingSession(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderingSession(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderingSession::GetPixelSize([In] AvnPixelSize* ret) - /// IAvnGlSurfaceRenderingSession::GetPixelSize - public unsafe Avalonia.Native.Interop.AvnPixelSize GetPixelSize() - { - Avalonia.Native.Interop.AvnPixelSize ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderingSession::GetScaling([In] double* ret) - /// IAvnGlSurfaceRenderingSession::GetScaling - public unsafe System.Double GetScaling() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f15")] - public partial class IAvnGlSurfaceRenderTarget : SharpGen.Runtime.ComObject - { - public IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnGlSurfaceRenderTarget(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnGlSurfaceRenderTarget(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnGlSurfaceRenderTarget::BeginDrawing([In] IAvnGlSurfaceRenderingSession** ret) - /// IAvnGlSurfaceRenderTarget::BeginDrawing - public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession BeginDrawing() - { - Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession ret; - System.IntPtr ret_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[3]); - if (ret_ != System.IntPtr.Zero) - ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderingSession(ret_); - else - ret = null; - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0a")] - public partial class IAvnLoopCancellation : SharpGen.Runtime.ComObject - { - public IAvnLoopCancellation(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnLoopCancellation(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnLoopCancellation(nativePtr); - /// - /// No documentation. - /// - /// void IAvnLoopCancellation::Cancel() - /// IAvnLoopCancellation::Cancel - public unsafe void Cancel() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[3]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f07")] - public partial class IAvnMacOptions : SharpGen.Runtime.ComObject - { - public IAvnMacOptions(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMacOptions(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMacOptions(nativePtr); - /// - /// No documentation. - /// - /// SetShowInDock - /// SetShowInDock - public System.Int32 ShowInDock - { - set => SetShowInDock(value); - } - - /// - /// No documentation. - /// - /// SetApplicationTitle - /// SetApplicationTitle - public System.IntPtr ApplicationTitle - { - set => SetApplicationTitle(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMacOptions::SetShowInDock([In] int show) - /// IAvnMacOptions::SetShowInDock - internal unsafe void SetShowInDock(System.Int32 show) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, show, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMacOptions::SetApplicationTitle([In] void* utf8string) - /// IAvnMacOptions::SetApplicationTitle - internal unsafe void SetApplicationTitle(System.IntPtr utf8string) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8string, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] - public partial class IAvnMenu : SharpGen.Runtime.ComObject - { - public IAvnMenu(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMenu(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenu(nativePtr); - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::InsertItem([In] int index,[In] IAvnMenuItem* item) - /// IAvnMenu::InsertItem - public unsafe void InsertItem(System.Int32 index, Avalonia.Native.Interop.IAvnMenuItem item) - { - System.IntPtr item_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, (void *)item_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(item); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::RemoveItem([In] IAvnMenuItem* item) - /// IAvnMenu::RemoveItem - public unsafe void RemoveItem(Avalonia.Native.Interop.IAvnMenuItem item) - { - System.IntPtr item_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - item_ = SharpGen.Runtime.CppObject.ToCallbackPtr(item); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)item_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(item); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenu::SetTitle([In] void* utf8String) - /// IAvnMenu::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8String) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnMenu::Clear() - /// IAvnMenu::Clear - public unsafe void Clear() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - __result__.CheckError(); - } - } - - class IAvnMenuEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnMenuEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnMenuEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new NeedsUpdateDelegate(NeedsUpdate)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void NeedsUpdateDelegate(System.IntPtr thisObject); - private static unsafe void NeedsUpdate(System.IntPtr thisObject) - { - try - { - IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; - @this.NeedsUpdate(); - } - catch (System.Exception __exception__) - { - IAvnMenuEvents @this = (IAvnMenuEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnMenuEventsShadow.IAvnMenuEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f1A"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnMenuEventsShadow))] - public partial interface IAvnMenuEvents : SharpGen.Runtime.IUnknown - { - void NeedsUpdate(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f19")] - public partial class IAvnMenuItem : SharpGen.Runtime.ComObject - { - public IAvnMenuItem(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnMenuItem(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnMenuItem(nativePtr); - /// - /// No documentation. - /// - /// SetSubMenu - /// SetSubMenu - public Avalonia.Native.Interop.IAvnMenu SubMenu - { - set => SetSubMenu(value); - } - - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// SetIsChecked - /// SetIsChecked - public System.Boolean IsChecked - { - set => SetIsChecked(value); - } - - /// - /// No documentation. - /// - /// SetToggleType - /// SetToggleType - public Avalonia.Native.Interop.AvnMenuItemToggleType ToggleType - { - set => SetToggleType(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetSubMenu([In] IAvnMenu* menu) - /// IAvnMenuItem::SetSubMenu - internal unsafe void SetSubMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetTitle([In] void* utf8String) - /// IAvnMenuItem::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8String) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetGesture([In] void* utf8String,[In] AvnInputModifiers modifiers) - /// IAvnMenuItem::SetGesture - public unsafe void SetGesture(System.IntPtr utf8String, Avalonia.Native.Interop.AvnInputModifiers modifiers) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8String, unchecked ((System.Int32)modifiers), (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetAction([In] IAvnPredicateCallback* predicate,[In] IAvnActionCallback* callback) - /// IAvnMenuItem::SetAction - public unsafe void SetAction(Avalonia.Native.Interop.IAvnPredicateCallback redicateRef, Avalonia.Native.Interop.IAvnActionCallback callback) - { - System.IntPtr redicateRef_ = System.IntPtr.Zero; - System.IntPtr callback_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - redicateRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(redicateRef); - callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)redicateRef_, (void *)callback_, (*(void ***)this._nativePointer)[6]); - System.GC.KeepAlive(redicateRef); - System.GC.KeepAlive(callback); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetIsChecked([In] bool isChecked) - /// IAvnMenuItem::SetIsChecked - internal unsafe void SetIsChecked(System.Boolean isChecked) - { - System.Byte isChecked_; - SharpGen.Runtime.Result __result__; - isChecked_ = (System.Byte)(isChecked ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, isChecked_, (*(void ***)this._nativePointer)[7]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetToggleType([In] AvnMenuItemToggleType toggleType) - /// IAvnMenuItem::SetToggleType - internal unsafe void SetToggleType(Avalonia.Native.Interop.AvnMenuItemToggleType toggleType) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)toggleType), (*(void ***)this._nativePointer)[8]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnMenuItem::SetIcon([In] void* data,[In] size_t length) - /// IAvnMenuItem::SetIcon - public unsafe void SetIcon(System.IntPtr data, SharpGen.Runtime.PointerSize length) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)data, (void *)length, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] - public partial class IAvnNativeControlHost : SharpGen.Runtime.ComObject - { - public IAvnNativeControlHost(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnNativeControlHost(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHost(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHost::CreateDefaultChild([In] void* parent,[Out] void** retOut) - /// IAvnNativeControlHost::CreateDefaultChild - public unsafe System.IntPtr CreateDefaultChild(System.IntPtr arentRef) - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef, &retOut, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnNativeControlHostTopLevelAttachment* IAvnNativeControlHost::CreateAttachment() - /// IAvnNativeControlHost::CreateAttachment - public unsafe Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment CreateAttachment() - { - Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[4]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnNativeControlHostTopLevelAttachment(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnNativeControlHost::DestroyDefaultChild([In] void* child) - /// IAvnNativeControlHost::DestroyDefaultChild - public unsafe void DestroyDefaultChild(System.IntPtr child) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[5]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f21")] - public partial class IAvnNativeControlHostTopLevelAttachment : SharpGen.Runtime.ComObject - { - public IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnNativeControlHostTopLevelAttachment(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnNativeControlHostTopLevelAttachment(nativePtr); - /// - /// No documentation. - /// - /// GetParentHandle - /// GetParentHandle - public System.IntPtr ParentHandle - { - get => GetParentHandle(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// void* IAvnNativeControlHostTopLevelAttachment::GetParentHandle() - /// IAvnNativeControlHostTopLevelAttachment::GetParentHandle - internal unsafe System.IntPtr GetParentHandle() - { - System.IntPtr __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[3]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle([In] void* child) - /// IAvnNativeControlHostTopLevelAttachment::InitializeWithChildHandle - public unsafe void InitializeWithChildHandle(System.IntPtr child) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)child, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnNativeControlHostTopLevelAttachment::AttachTo([In] IAvnNativeControlHost* host) - /// IAvnNativeControlHostTopLevelAttachment::AttachTo - public unsafe void AttachTo(Avalonia.Native.Interop.IAvnNativeControlHost host) - { - System.IntPtr host_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - host_ = SharpGen.Runtime.CppObject.ToCallbackPtr(host); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)host_, (*(void ***)this._nativePointer)[5]); - System.GC.KeepAlive(host); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnNativeControlHostTopLevelAttachment::ShowInBounds([In] float x,[In] float y,[In] float width,[In] float height) - /// IAvnNativeControlHostTopLevelAttachment::ShowInBounds - public unsafe void ShowInBounds(System.Single x, System.Single y, System.Single width, System.Single height) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, x, y, width, height, (*(void ***)this._nativePointer)[6]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// void IAvnNativeControlHostTopLevelAttachment::HideWithSize([In] float width,[In] float height) - /// IAvnNativeControlHostTopLevelAttachment::HideWithSize - public unsafe void HideWithSize(System.Single width, System.Single height) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, width, height, (*(void ***)this._nativePointer)[7]); - } - - /// - /// No documentation. - /// - /// void IAvnNativeControlHostTopLevelAttachment::ReleaseChild() - /// IAvnNativeControlHostTopLevelAttachment::ReleaseChild - public unsafe void ReleaseChild() - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (*(void ***)this._nativePointer)[8]); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0b")] - public partial class IAvnPlatformThreadingInterface : SharpGen.Runtime.ComObject - { - public IAvnPlatformThreadingInterface(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnPlatformThreadingInterface(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPlatformThreadingInterface(nativePtr); - /// - /// No documentation. - /// - /// GetCurrentThreadIsLoopThread - /// GetCurrentThreadIsLoopThread - public System.Boolean CurrentThreadIsLoopThread - { - get => GetCurrentThreadIsLoopThread(); - } - - /// - /// No documentation. - /// - /// SetSignaledCallback - /// SetSignaledCallback - public Avalonia.Native.Interop.IAvnSignaledCallback SignaledCallback - { - set => SetSignaledCallback(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// bool IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread() - /// IAvnPlatformThreadingInterface::GetCurrentThreadIsLoopThread - internal unsafe System.Boolean GetCurrentThreadIsLoopThread() - { - System.Boolean __result__; - System.Byte __result__native; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemByte(this._nativePointer, (*(void ***)this._nativePointer)[3]); - __result__ = __result__native != 0; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnPlatformThreadingInterface::SetSignaledCallback([In] IAvnSignaledCallback* cb) - /// IAvnPlatformThreadingInterface::SetSignaledCallback - internal unsafe void SetSignaledCallback(Avalonia.Native.Interop.IAvnSignaledCallback cb) - { - System.IntPtr cb_ = System.IntPtr.Zero; - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)cb_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(cb); - } - - /// - /// No documentation. - /// - /// No documentation. - /// IAvnLoopCancellation* IAvnPlatformThreadingInterface::CreateLoopCancellation() - /// IAvnPlatformThreadingInterface::CreateLoopCancellation - public unsafe Avalonia.Native.Interop.IAvnLoopCancellation CreateLoopCancellation() - { - Avalonia.Native.Interop.IAvnLoopCancellation __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, (*(void ***)this._nativePointer)[5]); - if (__result__native != System.IntPtr.Zero) - __result__ = new Avalonia.Native.Interop.IAvnLoopCancellation(__result__native); - else - __result__ = null; - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnPlatformThreadingInterface::RunLoop([In] IAvnLoopCancellation* cancel) - /// IAvnPlatformThreadingInterface::RunLoop - public unsafe void RunLoop(Avalonia.Native.Interop.IAvnLoopCancellation cancel) - { - System.IntPtr cancel_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cancel_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cancel); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cancel_, (*(void ***)this._nativePointer)[6]); - System.GC.KeepAlive(cancel); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// void IAvnPlatformThreadingInterface::Signal([In] int priority) - /// IAvnPlatformThreadingInterface::Signal - public unsafe void Signal(System.Int32 priority) - { - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, priority, (*(void ***)this._nativePointer)[7]); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// IUnknown* IAvnPlatformThreadingInterface::StartTimer([In] int priority,[In] int ms,[In] IAvnActionCallback* callback) - /// IAvnPlatformThreadingInterface::StartTimer - public unsafe SharpGen.Runtime.ComObject StartTimer(System.Int32 priority, System.Int32 ms, Avalonia.Native.Interop.IAvnActionCallback callback) - { - System.IntPtr callback_ = System.IntPtr.Zero; - SharpGen.Runtime.ComObject __result__; - System.IntPtr __result__native = System.IntPtr.Zero; - callback_ = SharpGen.Runtime.CppObject.ToCallbackPtr(callback); - __result__native = Avalonia.Native.LocalInterop.CalliThisCallSystemIntPtr(this._nativePointer, priority, ms, (void *)callback_, (*(void ***)this._nativePointer)[8]); - if (__result__native != System.IntPtr.Zero) - __result__ = new SharpGen.Runtime.ComObject(__result__native); - else - __result__ = null; - System.GC.KeepAlive(callback); - return __result__; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f03")] - public partial class IAvnPopup : Avalonia.Native.Interop.IAvnWindowBase - { - public IAvnPopup(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnPopup(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnPopup(nativePtr); - } - - class IAvnPredicateCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnPredicateCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnPredicateCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new EvaluateDelegate(Evaluate)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte EvaluateDelegate(System.IntPtr thisObject); - private static unsafe System.Byte Evaluate(System.IntPtr thisObject) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; - __result__ = @this.Evaluate(); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnPredicateCallback @this = (IAvnPredicateCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnPredicateCallbackShadow.IAvnPredicateCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f18"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnPredicateCallbackShadow))] - public partial interface IAvnPredicateCallback : SharpGen.Runtime.IUnknown - { - System.Boolean Evaluate(); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0e")] - public partial class IAvnScreens : SharpGen.Runtime.ComObject - { - public IAvnScreens(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnScreens(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnScreens(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnScreens::GetScreenCount([In] int* ret) - /// IAvnScreens::GetScreenCount - public unsafe System.Int32 GetScreenCount() - { - System.Int32 ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnScreens::GetScreen([In] int index,[In] AvnScreen* ret) - /// IAvnScreens::GetScreen - public unsafe Avalonia.Native.Interop.AvnScreen GetScreen(System.Int32 index) - { - Avalonia.Native.Interop.AvnScreen ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - class IAvnSignaledCallbackShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnSignaledCallbackVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnSignaledCallbackVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new SignaledDelegate(Signaled)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void SignaledDelegate(System.IntPtr thisObject, int arg0, System.Byte arg1); - private static unsafe void Signaled(System.IntPtr thisObject, int param0, System.Byte param1) - { - try - { - System.Int32 priority = default (System.Int32); - priority = (System.Int32)param0; - System.Boolean priorityContainsMeaningfulValue = default (System.Boolean); - System.Byte priorityContainsMeaningfulValue_ = (System.Byte)param1; - IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; - priorityContainsMeaningfulValue = priorityContainsMeaningfulValue_ != 0; - @this.Signaled(priority, priorityContainsMeaningfulValue); - } - catch (System.Exception __exception__) - { - IAvnSignaledCallback @this = (IAvnSignaledCallback)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnSignaledCallbackShadow.IAvnSignaledCallbackVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f09"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSignaledCallbackShadow))] - public partial interface IAvnSignaledCallback : SharpGen.Runtime.IUnknown - { - void Signaled(System.Int32 priority, System.Boolean priorityContainsMeaningfulValue); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f17")] - public partial class IAvnString : SharpGen.Runtime.ComObject - { - public IAvnString(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnString(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnString(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnString::Pointer([Out] void** retOut) - /// IAvnString::Pointer - public unsafe System.IntPtr Pointer() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnString::Length([In] int* ret) - /// IAvnString::Length - public unsafe System.Int32 Length() - { - System.Int32 ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - return ret; - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f20")] - public partial class IAvnStringArray : SharpGen.Runtime.ComObject - { - public IAvnStringArray(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnStringArray(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnStringArray(nativePtr); - /// - /// No documentation. - /// - /// GetCount - /// GetCount - public System.UInt32 Count - { - get => GetCount(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// unsigned int IAvnStringArray::GetCount() - /// IAvnStringArray::GetCount - internal unsafe System.UInt32 GetCount() - { - System.UInt32 __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallSystemUInt32(this._nativePointer, (*(void ***)this._nativePointer)[3]); - return __result__; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnStringArray::Get([In] unsigned int index,[In] IAvnString** ppv) - /// IAvnStringArray::Get - public unsafe Avalonia.Native.Interop.IAvnString Get(System.UInt32 index) - { - Avalonia.Native.Interop.IAvnString vOut; - System.IntPtr vOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, index, &vOut_, (*(void ***)this._nativePointer)[4]); - if (vOut_ != System.IntPtr.Zero) - vOut = new Avalonia.Native.Interop.IAvnString(vOut_); - else - vOut = null; - __result__.CheckError(); - return vOut; - } - } - - class IAvnSystemDialogEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnSystemDialogEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnSystemDialogEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 1) - { - AddMethod(new OnCompletedDelegate(OnCompleted)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void OnCompletedDelegate(System.IntPtr thisObject, int arg0, void *arg1); - private static unsafe void OnCompleted(System.IntPtr thisObject, int param0, void *param1) - { - try - { - System.Int32 numResults = default (System.Int32); - numResults = (System.Int32)param0; - System.IntPtr trFirstResultRef = default (System.IntPtr); - trFirstResultRef = (System.IntPtr)param1; - IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; - @this.OnCompleted(numResults, trFirstResultRef); - } - catch (System.Exception __exception__) - { - IAvnSystemDialogEvents @this = (IAvnSystemDialogEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnSystemDialogEventsShadow.IAvnSystemDialogEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0c"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnSystemDialogEventsShadow))] - public partial interface IAvnSystemDialogEvents : SharpGen.Runtime.IUnknown - { - void OnCompleted(System.Int32 numResults, System.IntPtr trFirstResultRef); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f0d")] - public partial class IAvnSystemDialogs : SharpGen.Runtime.ComObject - { - public IAvnSystemDialogs(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnSystemDialogs(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnSystemDialogs(nativePtr); - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::SelectFolderDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialPath) - /// IAvnSystemDialogs::SelectFolderDialog - public unsafe void SelectFolderDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialPath) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.IntPtr title_; - System.IntPtr initialPath_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialPath_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialPath); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialPath_, (*(void ***)this._nativePointer)[3]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialPath_); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::OpenFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] bool allowMultiple,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) - /// IAvnSystemDialogs::OpenFileDialog - public unsafe void OpenFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.Boolean allowMultiple, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.Byte allowMultiple_; - System.IntPtr title_; - System.IntPtr initialDirectory_; - System.IntPtr initialFile_; - System.IntPtr filters_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - allowMultiple_ = (System.Byte)(allowMultiple ? 1 : 0); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); - initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); - filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, allowMultiple_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[4]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// void IAvnSystemDialogs::SaveFileDialog([In] IAvnWindow* parentWindowHandle,[In] IAvnSystemDialogEvents* events,[In] const char* title,[In] const char* initialDirectory,[In] const char* initialFile,[In] const char* filters) - /// IAvnSystemDialogs::SaveFileDialog - public unsafe void SaveFileDialog(Avalonia.Native.Interop.IAvnWindow arentWindowHandleRef, Avalonia.Native.Interop.IAvnSystemDialogEvents events, System.String title, System.String initialDirectory, System.String initialFile, System.String filters) - { - System.IntPtr arentWindowHandleRef_ = System.IntPtr.Zero; - System.IntPtr events_ = System.IntPtr.Zero; - System.IntPtr title_; - System.IntPtr initialDirectory_; - System.IntPtr initialFile_; - System.IntPtr filters_; - arentWindowHandleRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentWindowHandleRef); - events_ = SharpGen.Runtime.CppObject.ToCallbackPtr(events); - title_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(title); - initialDirectory_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialDirectory); - initialFile_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(initialFile); - filters_ = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(filters); - Avalonia.Native.LocalInterop.CalliThisCallvoid(this._nativePointer, (void *)arentWindowHandleRef_, (void *)events_, (void *)title_, (void *)initialDirectory_, (void *)initialFile_, (void *)filters_, (*(void ***)this._nativePointer)[5]); - System.GC.KeepAlive(arentWindowHandleRef); - System.GC.KeepAlive(events); - System.Runtime.InteropServices.Marshal.FreeHGlobal(title_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialDirectory_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(initialFile_); - System.Runtime.InteropServices.Marshal.FreeHGlobal(filters_); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f04")] - public partial class IAvnWindow : Avalonia.Native.Interop.IAvnWindowBase - { - public IAvnWindow(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnWindow(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindow(nativePtr); - /// - /// No documentation. - /// - /// SetEnabled - /// SetEnabled - public System.Boolean Enabled - { - set => SetEnabled(value); - } - - /// - /// No documentation. - /// - /// SetParent - /// SetParent - public Avalonia.Native.Interop.IAvnWindow Parent - { - set => SetParent(value); - } - - /// - /// No documentation. - /// - /// SetCanResize - /// SetCanResize - public System.Boolean CanResize - { - set => SetCanResize(value); - } - - /// - /// No documentation. - /// - /// SetDecorations - /// SetDecorations - public Avalonia.Native.Interop.SystemDecorations Decorations - { - set => SetDecorations(value); - } - - /// - /// No documentation. - /// - /// SetTitle - /// SetTitle - public System.IntPtr Title - { - set => SetTitle(value); - } - - /// - /// No documentation. - /// - /// SetTitleBarColor - /// SetTitleBarColor - public Avalonia.Native.Interop.AvnColor TitleBarColor - { - set => SetTitleBarColor(value); - } - - /// - /// No documentation. - /// - /// SetExtendClientArea - /// SetExtendClientArea - public System.Boolean ExtendClientArea - { - set => SetExtendClientArea(value); - } - - /// - /// No documentation. - /// - /// SetExtendClientAreaHints - /// SetExtendClientAreaHints - public Avalonia.Native.Interop.AvnExtendClientAreaChromeHints ExtendClientAreaHints - { - set => SetExtendClientAreaHints(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetEnabled([In] bool enable) - /// IAvnWindow::SetEnabled - internal unsafe void SetEnabled(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[30]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetParent([In] IAvnWindow* parent) - /// IAvnWindow::SetParent - internal unsafe void SetParent(Avalonia.Native.Interop.IAvnWindow arentRef) - { - System.IntPtr arentRef_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - arentRef_ = SharpGen.Runtime.CppObject.ToCallbackPtr(arentRef); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)arentRef_, (*(void ***)this._nativePointer)[31]); - System.GC.KeepAlive(arentRef); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetCanResize([In] bool value) - /// IAvnWindow::SetCanResize - internal unsafe void SetCanResize(System.Boolean value) - { - System.Byte value_; - SharpGen.Runtime.Result __result__; - value_ = (System.Byte)(value ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[32]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetDecorations([In] SystemDecorations value) - /// IAvnWindow::SetDecorations - internal unsafe void SetDecorations(Avalonia.Native.Interop.SystemDecorations value) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)value), (*(void ***)this._nativePointer)[33]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetTitle([In] void* utf8Title) - /// IAvnWindow::SetTitle - internal unsafe void SetTitle(System.IntPtr utf8Title) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)utf8Title, (*(void ***)this._nativePointer)[34]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetTitleBarColor([In] AvnColor color) - /// IAvnWindow::SetTitleBarColor - internal unsafe void SetTitleBarColor(Avalonia.Native.Interop.AvnColor color) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, color, (*(void ***)this._nativePointer)[35]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetWindowState([In] AvnWindowState state) - /// IAvnWindow::SetWindowState - public unsafe void SetWindowState(Avalonia.Native.Interop.AvnWindowState state) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)state), (*(void ***)this._nativePointer)[36]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::GetWindowState([In] AvnWindowState* ret) - /// IAvnWindow::GetWindowState - public unsafe Avalonia.Native.Interop.AvnWindowState GetWindowState() - { - Avalonia.Native.Interop.AvnWindowState ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[37]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::TakeFocusFromChildren() - /// IAvnWindow::TakeFocusFromChildren - public unsafe void TakeFocusFromChildren() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[38]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendClientArea([In] bool enable) - /// IAvnWindow::SetExtendClientArea - internal unsafe void SetExtendClientArea(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[39]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendClientAreaHints([In] AvnExtendClientAreaChromeHints hints) - /// IAvnWindow::SetExtendClientAreaHints - internal unsafe void SetExtendClientAreaHints(Avalonia.Native.Interop.AvnExtendClientAreaChromeHints hints) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)hints), (*(void ***)this._nativePointer)[40]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindow::GetExtendTitleBarHeight([In] double* ret) - /// IAvnWindow::GetExtendTitleBarHeight - public unsafe System.Double GetExtendTitleBarHeight() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[41]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindow::SetExtendTitleBarHeight([In] double value) - /// IAvnWindow::SetExtendTitleBarHeight - public unsafe void SetExtendTitleBarHeight(System.Double value) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value, (*(void ***)this._nativePointer)[42]); - __result__.CheckError(); - } - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f02")] - public partial class IAvnWindowBase : SharpGen.Runtime.ComObject - { - public IAvnWindowBase(System.IntPtr nativePtr): base (nativePtr) - { - } - - public static explicit operator IAvnWindowBase(System.IntPtr nativePtr) => nativePtr == System.IntPtr.Zero ? null : new IAvnWindowBase(nativePtr); - /// - /// No documentation. - /// - /// SetTopMost - /// SetTopMost - public System.Boolean TopMost - { - set => SetTopMost(value); - } - - /// - /// No documentation. - /// - /// SetCursor - /// SetCursor - public Avalonia.Native.Interop.IAvnCursor Cursor - { - set => SetCursor(value); - } - - /// - /// No documentation. - /// - /// SetMainMenu - /// SetMainMenu - public Avalonia.Native.Interop.IAvnMenu MainMenu - { - set => SetMainMenu(value); - } - - /// - /// No documentation. - /// - /// SetBlurEnabled - /// SetBlurEnabled - public System.Boolean BlurEnabled - { - set => SetBlurEnabled(value); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Show() - /// IAvnWindowBase::Show - public unsafe void Show() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[3]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Hide() - /// IAvnWindowBase::Hide - public unsafe void Hide() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[4]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Close() - /// IAvnWindowBase::Close - public unsafe void Close() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[5]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::Activate() - /// IAvnWindowBase::Activate - public unsafe void Activate() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[6]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetClientSize([In] AvnSize* ret) - /// IAvnWindowBase::GetClientSize - public unsafe Avalonia.Native.Interop.AvnSize GetClientSize() - { - Avalonia.Native.Interop.AvnSize ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[7]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetScaling([In] double* ret) - /// IAvnWindowBase::GetScaling - public unsafe System.Double GetScaling() - { - System.Double ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[8]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetMinMaxSize([In] AvnSize minSize,[In] AvnSize maxSize) - /// IAvnWindowBase::SetMinMaxSize - public unsafe void SetMinMaxSize(Avalonia.Native.Interop.AvnSize minSize, Avalonia.Native.Interop.AvnSize maxSize) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, minSize, maxSize, (*(void ***)this._nativePointer)[9]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::Resize([In] double width,[In] double height) - /// IAvnWindowBase::Resize - public unsafe void Resize(System.Double width, System.Double height) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, width, height, (*(void ***)this._nativePointer)[10]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::Invalidate([In] AvnRect rect) - /// IAvnWindowBase::Invalidate - public unsafe void Invalidate(Avalonia.Native.Interop.AvnRect rect) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, rect, (*(void ***)this._nativePointer)[11]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::BeginMoveDrag() - /// IAvnWindowBase::BeginMoveDrag - public unsafe void BeginMoveDrag() - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (*(void ***)this._nativePointer)[12]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::BeginResizeDrag([In] AvnWindowEdge edge) - /// IAvnWindowBase::BeginResizeDrag - public unsafe void BeginResizeDrag(Avalonia.Native.Interop.AvnWindowEdge edge) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, unchecked ((System.Int32)edge), (*(void ***)this._nativePointer)[13]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::GetPosition([In] AvnPoint* ret) - /// IAvnWindowBase::GetPosition - public unsafe Avalonia.Native.Interop.AvnPoint GetPosition() - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret, (*(void ***)this._nativePointer)[14]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetPosition([In] AvnPoint point) - /// IAvnWindowBase::SetPosition - public unsafe void SetPosition(Avalonia.Native.Interop.AvnPoint point) - { - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, (*(void ***)this._nativePointer)[15]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::PointToClient([In] AvnPoint point,[In] AvnPoint* ret) - /// IAvnWindowBase::PointToClient - public unsafe Avalonia.Native.Interop.AvnPoint PointToClient(Avalonia.Native.Interop.AvnPoint point) - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[16]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::PointToScreen([In] AvnPoint point,[In] AvnPoint* ret) - /// IAvnWindowBase::PointToScreen - public unsafe Avalonia.Native.Interop.AvnPoint PointToScreen(Avalonia.Native.Interop.AvnPoint point) - { - Avalonia.Native.Interop.AvnPoint ret; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, point, &ret, (*(void ***)this._nativePointer)[17]); - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::ThreadSafeSetSwRenderedFrame([In] AvnFramebuffer* fb,[In] IUnknown* dispose) - /// IAvnWindowBase::ThreadSafeSetSwRenderedFrame - public unsafe void ThreadSafeSetSwRenderedFrame(ref Avalonia.Native.Interop.AvnFramebuffer fb, SharpGen.Runtime.IUnknown dispose) - { - System.IntPtr dispose_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - dispose_ = SharpGen.Runtime.CppObject.ToCallbackPtr(dispose); - fixed (void *fb_ = &fb) - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, fb_, (void *)dispose_, (*(void ***)this._nativePointer)[18]); - System.GC.KeepAlive(dispose); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetTopMost([In] bool value) - /// IAvnWindowBase::SetTopMost - internal unsafe void SetTopMost(System.Boolean value) - { - System.Byte value_; - SharpGen.Runtime.Result __result__; - value_ = (System.Byte)(value ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, value_, (*(void ***)this._nativePointer)[19]); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetCursor([In] IAvnCursor* cursor) - /// IAvnWindowBase::SetCursor - internal unsafe void SetCursor(Avalonia.Native.Interop.IAvnCursor cursor) - { - System.IntPtr cursor_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - cursor_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cursor); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)cursor_, (*(void ***)this._nativePointer)[20]); - System.GC.KeepAlive(cursor); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::CreateGlRenderTarget([In] IAvnGlSurfaceRenderTarget** ret) - /// IAvnWindowBase::CreateGlRenderTarget - public unsafe Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget CreateGlRenderTarget() - { - Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget ret; - System.IntPtr ret_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &ret_, (*(void ***)this._nativePointer)[21]); - if (ret_ != System.IntPtr.Zero) - ret = new Avalonia.Native.Interop.IAvnGlSurfaceRenderTarget(ret_); - else - ret = null; - __result__.CheckError(); - return ret; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetMainMenu([In] IAvnMenu* menu) - /// IAvnWindowBase::SetMainMenu - internal unsafe void SetMainMenu(Avalonia.Native.Interop.IAvnMenu menu) - { - System.IntPtr menu_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - menu_ = SharpGen.Runtime.CppObject.ToCallbackPtr(menu); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, (void *)menu_, (*(void ***)this._nativePointer)[22]); - System.GC.KeepAlive(menu); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSWindowHandle([Out] void** retOut) - /// IAvnWindowBase::ObtainNSWindowHandle - public unsafe System.IntPtr ObtainNSWindowHandle() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[23]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSWindowHandleRetained([Out] void** retOut) - /// IAvnWindowBase::ObtainNSWindowHandleRetained - public unsafe System.IntPtr ObtainNSWindowHandleRetained() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[24]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSViewHandle([Out] void** retOut) - /// IAvnWindowBase::ObtainNSViewHandle - public unsafe System.IntPtr ObtainNSViewHandle() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[25]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::ObtainNSViewHandleRetained([Out] void** retOut) - /// IAvnWindowBase::ObtainNSViewHandleRetained - public unsafe System.IntPtr ObtainNSViewHandleRetained() - { - System.IntPtr retOut; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut, (*(void ***)this._nativePointer)[26]); - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// HRESULT IAvnWindowBase::CreateNativeControlHost([Out] IAvnNativeControlHost** retOut) - /// IAvnWindowBase::CreateNativeControlHost - public unsafe Avalonia.Native.Interop.IAvnNativeControlHost CreateNativeControlHost() - { - Avalonia.Native.Interop.IAvnNativeControlHost retOut; - System.IntPtr retOut_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, &retOut_, (*(void ***)this._nativePointer)[27]); - if (retOut_ != System.IntPtr.Zero) - retOut = new Avalonia.Native.Interop.IAvnNativeControlHost(retOut_); - else - retOut = null; - __result__.CheckError(); - return retOut; - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::BeginDragAndDropOperation([In] AvnDragDropEffects effects,[In] AvnPoint point,[In] IAvnClipboard* clipboard,[In] IAvnDndResultCallback* cb,[In] void* sourceHandle) - /// IAvnWindowBase::BeginDragAndDropOperation - public unsafe void BeginDragAndDropOperation(Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.IAvnClipboard clipboard, Avalonia.Native.Interop.IAvnDndResultCallback cb, System.IntPtr sourceHandle) - { - System.IntPtr clipboard_ = System.IntPtr.Zero; - System.IntPtr cb_ = System.IntPtr.Zero; - SharpGen.Runtime.Result __result__; - clipboard_ = SharpGen.Runtime.CppObject.ToCallbackPtr(clipboard); - cb_ = SharpGen.Runtime.CppObject.ToCallbackPtr(cb); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint0(this._nativePointer, unchecked ((System.Int32)effects), point, (void *)clipboard_, (void *)cb_, (void *)sourceHandle, (*(void ***)this._nativePointer)[28]); - System.GC.KeepAlive(clipboard); - System.GC.KeepAlive(cb); - __result__.CheckError(); - } - - /// - /// No documentation. - /// - /// No documentation. - /// No documentation. - /// HRESULT IAvnWindowBase::SetBlurEnabled([In] bool enable) - /// IAvnWindowBase::SetBlurEnabled - internal unsafe void SetBlurEnabled(System.Boolean enable) - { - System.Byte enable_; - SharpGen.Runtime.Result __result__; - enable_ = (System.Byte)(enable ? 1 : 0); - __result__ = Avalonia.Native.LocalInterop.CalliThisCallint(this._nativePointer, enable_, (*(void ***)this._nativePointer)[29]); - __result__.CheckError(); - } - } - - class IAvnWindowBaseEventsShadow : SharpGen.Runtime.ComObjectShadow - { - protected unsafe class IAvnWindowBaseEventsVtbl : SharpGen.Runtime.ComObjectShadow.ComObjectVtbl - { - public IAvnWindowBaseEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 13) - { - AddMethod(new PaintDelegate(Paint)); - AddMethod(new ClosedDelegate(Closed)); - AddMethod(new ActivatedDelegate(Activated)); - AddMethod(new DeactivatedDelegate(Deactivated)); - AddMethod(new ResizedDelegate(Resized)); - AddMethod(new PositionChangedDelegate(PositionChanged)); - AddMethod(new RawMouseEventDelegate(RawMouseEvent)); - AddMethod(new RawKeyEventDelegate(RawKeyEvent)); - AddMethod(new RawTextInputEventDelegate(RawTextInputEvent)); - AddMethod(new ScalingChangedDelegate(ScalingChanged)); - AddMethod(new RunRenderPriorityJobsDelegate(RunRenderPriorityJobs)); - AddMethod(new LostFocusDelegate(LostFocus)); - AddMethod(new DragEventDelegate(DragEvent)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate int PaintDelegate(System.IntPtr thisObject); - private static unsafe int Paint(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Paint(); - return SharpGen.Runtime.Result.Ok.Code; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return SharpGen.Runtime.Result.GetResultFromException(__exception__).Code; - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ClosedDelegate(System.IntPtr thisObject); - private static unsafe void Closed(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Closed(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ActivatedDelegate(System.IntPtr thisObject); - private static unsafe void Activated(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Activated(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void DeactivatedDelegate(System.IntPtr thisObject); - private static unsafe void Deactivated(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Deactivated(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ResizedDelegate(System.IntPtr thisObject, void *arg0); - private static unsafe void Resized(System.IntPtr thisObject, void *param0) - { - try - { - Avalonia.Native.Interop.AvnSize size = System.Runtime.CompilerServices.Unsafe.AsRef(param0); - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.Resized(size); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void PositionChangedDelegate(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint arg0); - private static unsafe void PositionChanged(System.IntPtr thisObject, Avalonia.Native.Interop.AvnPoint param0) - { - try - { - Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); - position = (Avalonia.Native.Interop.AvnPoint)param0; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.PositionChanged(position); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RawMouseEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, Avalonia.Native.Interop.AvnPoint arg3, Avalonia.Native.Interop.AvnVector arg4); - private static unsafe void RawMouseEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4) - { - try - { - Avalonia.Native.Interop.AvnRawMouseEventType type = default (Avalonia.Native.Interop.AvnRawMouseEventType); - type = (Avalonia.Native.Interop.AvnRawMouseEventType)param0; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - Avalonia.Native.Interop.AvnPoint point = default (Avalonia.Native.Interop.AvnPoint); - point = (Avalonia.Native.Interop.AvnPoint)param3; - Avalonia.Native.Interop.AvnVector delta = default (Avalonia.Native.Interop.AvnVector); - delta = (Avalonia.Native.Interop.AvnVector)param4; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.RawMouseEvent(type, timeStamp, modifiers, point, delta); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte RawKeyEventDelegate(System.IntPtr thisObject, int arg0, System.UInt32 arg1, int arg2, System.UInt32 arg3); - private static unsafe System.Byte RawKeyEvent(System.IntPtr thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - Avalonia.Native.Interop.AvnRawKeyEventType type = default (Avalonia.Native.Interop.AvnRawKeyEventType); - type = (Avalonia.Native.Interop.AvnRawKeyEventType)param0; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - System.UInt32 key = default (System.UInt32); - key = (System.UInt32)param3; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - __result__ = @this.RawKeyEvent(type, timeStamp, modifiers, key); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte RawTextInputEventDelegate(System.IntPtr thisObject, System.UInt32 arg0, void *arg1); - private static unsafe System.Byte RawTextInputEvent(System.IntPtr thisObject, System.UInt32 param0, void *param1) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - System.UInt32 timeStamp = default (System.UInt32); - timeStamp = (System.UInt32)param0; - System.String text = default (System.String); - System.IntPtr text_ = (System.IntPtr)param1; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(text_); - __result__ = @this.RawTextInputEvent(timeStamp, text); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void ScalingChangedDelegate(System.IntPtr thisObject, double arg0); - private static unsafe void ScalingChanged(System.IntPtr thisObject, double param0) - { - try - { - System.Double scaling = default (System.Double); - scaling = (System.Double)param0; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.ScalingChanged(scaling); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void RunRenderPriorityJobsDelegate(System.IntPtr thisObject); - private static unsafe void RunRenderPriorityJobs(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.RunRenderPriorityJobs(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void LostFocusDelegate(System.IntPtr thisObject); - private static unsafe void LostFocus(System.IntPtr thisObject) - { - try - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - @this.LostFocus(); - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate Avalonia.Native.Interop.AvnDragDropEffects DragEventDelegate(System.IntPtr thisObject, int arg0, Avalonia.Native.Interop.AvnPoint arg1, int arg2, int arg3, void *arg4, void *arg5); - private static unsafe Avalonia.Native.Interop.AvnDragDropEffects DragEvent(System.IntPtr thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5) - { - try - { - Avalonia.Native.Interop.AvnDragDropEffects __result__ = default (Avalonia.Native.Interop.AvnDragDropEffects); - Avalonia.Native.Interop.AvnDragEventType type = default (Avalonia.Native.Interop.AvnDragEventType); - type = (Avalonia.Native.Interop.AvnDragEventType)param0; - Avalonia.Native.Interop.AvnPoint position = default (Avalonia.Native.Interop.AvnPoint); - position = (Avalonia.Native.Interop.AvnPoint)param1; - Avalonia.Native.Interop.AvnInputModifiers modifiers = default (Avalonia.Native.Interop.AvnInputModifiers); - modifiers = (Avalonia.Native.Interop.AvnInputModifiers)param2; - Avalonia.Native.Interop.AvnDragDropEffects effects = default (Avalonia.Native.Interop.AvnDragDropEffects); - effects = (Avalonia.Native.Interop.AvnDragDropEffects)param3; - Avalonia.Native.Interop.IAvnClipboard clipboard = default (Avalonia.Native.Interop.IAvnClipboard); - System.IntPtr clipboard_ = (System.IntPtr)param4; - System.IntPtr dataObjectHandle = default (System.IntPtr); - dataObjectHandle = (System.IntPtr)param5; - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - if (clipboard_ != System.IntPtr.Zero) - clipboard = new Avalonia.Native.Interop.IAvnClipboard(clipboard_); - else - clipboard = null; - __result__ = @this.DragEvent(type, position, modifiers, effects, clipboard, dataObjectHandle); - return __result__; - } - catch (System.Exception __exception__) - { - IAvnWindowBaseEvents @this = (IAvnWindowBaseEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (Avalonia.Native.Interop.AvnDragDropEffects); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f05"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowBaseEventsShadow))] - public partial interface IAvnWindowBaseEvents : SharpGen.Runtime.IUnknown - { - void Paint(); - void Closed(); - void Activated(); - void Deactivated(); - void Resized(Avalonia.Native.Interop.AvnSize size); - void PositionChanged(Avalonia.Native.Interop.AvnPoint position); - void RawMouseEvent(Avalonia.Native.Interop.AvnRawMouseEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnPoint point, Avalonia.Native.Interop.AvnVector delta); - System.Boolean RawKeyEvent(Avalonia.Native.Interop.AvnRawKeyEventType type, System.UInt32 timeStamp, Avalonia.Native.Interop.AvnInputModifiers modifiers, System.UInt32 key); - System.Boolean RawTextInputEvent(System.UInt32 timeStamp, System.String text); - void ScalingChanged(System.Double scaling); - void RunRenderPriorityJobs(); - void LostFocus(); - Avalonia.Native.Interop.AvnDragDropEffects DragEvent(Avalonia.Native.Interop.AvnDragEventType type, Avalonia.Native.Interop.AvnPoint position, Avalonia.Native.Interop.AvnInputModifiers modifiers, Avalonia.Native.Interop.AvnDragDropEffects effects, Avalonia.Native.Interop.IAvnClipboard clipboard, System.IntPtr dataObjectHandle); - } - - class IAvnWindowEventsShadow : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow - { - protected unsafe class IAvnWindowEventsVtbl : Avalonia.Native.Interop.IAvnWindowBaseEventsShadow.IAvnWindowBaseEventsVtbl - { - public IAvnWindowEventsVtbl(int numberOfCallbackMethods): base (numberOfCallbackMethods + 3) - { - AddMethod(new ClosingDelegate(Closing)); - AddMethod(new WindowStateChangedDelegate(WindowStateChanged)); - AddMethod(new GotInputWhenDisabledDelegate(GotInputWhenDisabled)); - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate System.Byte ClosingDelegate(System.IntPtr thisObject); - private static unsafe System.Byte Closing(System.IntPtr thisObject) - { - try - { - System.Boolean __result__ = default (System.Boolean); - System.Byte __result__native; - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - __result__ = @this.Closing(); - __result__native = (System.Byte)(__result__ ? 1 : 0); - return __result__native; - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - return default (System.Byte); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void WindowStateChangedDelegate(System.IntPtr thisObject, int arg0); - private static unsafe void WindowStateChanged(System.IntPtr thisObject, int param0) - { - try - { - Avalonia.Native.Interop.AvnWindowState state = default (Avalonia.Native.Interop.AvnWindowState); - state = (Avalonia.Native.Interop.AvnWindowState)param0; - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - @this.WindowStateChanged(state); - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.ThisCall)] - private delegate void GotInputWhenDisabledDelegate(System.IntPtr thisObject); - private static unsafe void GotInputWhenDisabled(System.IntPtr thisObject) - { - try - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - @this.GotInputWhenDisabled(); - } - catch (System.Exception __exception__) - { - IAvnWindowEvents @this = (IAvnWindowEvents)ToShadow(thisObject).Callback; - (@this as SharpGen.Runtime.IExceptionCallback)?.RaiseException(__exception__); - } - } - } - - protected override SharpGen.Runtime.CppObjectVtbl Vtbl - { - get; - } - - = new Avalonia.Native.Interop.IAvnWindowEventsShadow.IAvnWindowEventsVtbl(0); - } - - [System.Runtime.InteropServices.GuidAttribute("2e2cda0a-9ae5-4f1b-8e20-081a04279f06"), SharpGen.Runtime.ShadowAttribute(typeof (Avalonia.Native.Interop.IAvnWindowEventsShadow))] - public partial interface IAvnWindowEvents : Avalonia.Native.Interop.IAvnWindowBaseEvents - { - System.Boolean Closing(); - void WindowStateChanged(Avalonia.Native.Interop.AvnWindowState state); - void GotInputWhenDisabled(); - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/LocalInterop.cs b/src/Avalonia.Native/Generated/LocalInterop.cs deleted file mode 100644 index 41e69a6bdc..0000000000 --- a/src/Avalonia.Native/Generated/LocalInterop.cs +++ /dev/null @@ -1,202 +0,0 @@ -// - -namespace Avalonia.Native -{ - internal static partial class LocalInterop - { - public static unsafe int CalliThisCallint(void *thisObject, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid0(void *thisObject, int param0, System.UInt32 param1, int param2, Avalonia.Native.Interop.AvnPoint param3, Avalonia.Native.Interop.AvnVector param4, void *methodPtr) - { - throw null; - } - - public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, int param0, System.UInt32 param1, int param2, System.UInt32 param3, void *methodPtr) - { - throw null; - } - - public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, double param0, void *methodPtr) - { - throw null; - } - - public static unsafe Avalonia.Native.Interop.AvnDragDropEffects CalliThisCallAvaloniaNativeInteropAvnDragDropEffects0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, int param2, int param3, void *param4, void *param5, void *methodPtr) - { - throw null; - } - - public static unsafe System.Byte CalliThisCallSystemByte(void *thisObject, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnSize param0, Avalonia.Native.Interop.AvnSize param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, double param0, double param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnRect param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, int param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnPoint param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, System.Byte param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, int param0, Avalonia.Native.Interop.AvnPoint param1, void *param2, void *param3, void *param4, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint0(void *thisObject, Avalonia.Native.Interop.AvnColor param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, double param0, void *methodPtr) - { - throw null; - } - - public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *methodPtr) - { - throw null; - } - - public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, int param0, int param1, void *param2, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, int param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, System.Byte param2, void *param3, void *param4, void *param5, void *param6, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, void *param0, void *param1, void *param2, void *param3, void *param4, void *param5, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, int param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, int param2, void *methodPtr) - { - throw null; - } - - public static unsafe System.IntPtr CalliThisCallSystemIntPtr(void *thisObject, void *param0, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, void *param0, int param1, void *methodPtr) - { - throw null; - } - - public static unsafe System.UInt32 CalliThisCallSystemUInt32(void *thisObject, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, System.UInt32 param0, void *param1, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, float param2, float param3, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, float param0, float param1, void *methodPtr) - { - throw null; - } - - public static unsafe int CalliThisCallint(void *thisObject, void *param0, void *param1, void *param2, void *methodPtr) - { - throw null; - } - - public static unsafe void CalliThisCallvoid(void *thisObject, int param0, System.Byte param1, void *methodPtr) - { - throw null; - } - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Generated/Structures.cs b/src/Avalonia.Native/Generated/Structures.cs deleted file mode 100644 index fc871a2516..0000000000 --- a/src/Avalonia.Native/Generated/Structures.cs +++ /dev/null @@ -1,246 +0,0 @@ -// - -namespace Avalonia.Native.Interop -{ - /// - /// No documentation. - /// - /// AvnColor - /// AvnColor - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnColor - { - /// - /// No documentation. - /// - /// Alpha - /// Alpha - public System.Byte Alpha; - /// - /// No documentation. - /// - /// Red - /// Red - public System.Byte Red; - /// - /// No documentation. - /// - /// Green - /// Green - public System.Byte Green; - /// - /// No documentation. - /// - /// Blue - /// Blue - public System.Byte Blue; - } - - /// - /// No documentation. - /// - /// AvnFramebuffer - /// AvnFramebuffer - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnFramebuffer - { - /// - /// No documentation. - /// - /// Data - /// Data - public System.IntPtr Data; - /// - /// No documentation. - /// - /// Width - /// Width - public System.Int32 Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Int32 Height; - /// - /// No documentation. - /// - /// Stride - /// Stride - public System.Int32 Stride; - /// - /// No documentation. - /// - /// Dpi - /// Dpi - public Avalonia.Native.Interop.AvnVector Dpi; - /// - /// No documentation. - /// - /// PixelFormat - /// PixelFormat - public Avalonia.Native.Interop.AvnPixelFormat PixelFormat; - } - - /// - /// No documentation. - /// - /// AvnPixelSize - /// AvnPixelSize - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnPixelSize - { - /// - /// No documentation. - /// - /// Width - /// Width - public System.Int32 Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Int32 Height; - } - - /// - /// No documentation. - /// - /// AvnPoint - /// AvnPoint - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnPoint - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - } - - /// - /// No documentation. - /// - /// AvnRect - /// AvnRect - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnRect - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - /// - /// No documentation. - /// - /// Width - /// Width - public System.Double Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Double Height; - } - - /// - /// No documentation. - /// - /// AvnScreen - /// AvnScreen - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnScreen - { - /// - /// No documentation. - /// - /// Bounds - /// Bounds - public Avalonia.Native.Interop.AvnRect Bounds; - /// - /// No documentation. - /// - /// WorkingArea - /// WorkingArea - public Avalonia.Native.Interop.AvnRect WorkingArea; - /// - /// No documentation. - /// - /// PixelDensity - /// PixelDensity - public System.Single PixelDensity; - /// - /// No documentation. - /// - /// Primary - /// Primary - public bool Primary - { - get => 0 != _Primary; - set => _Primary = (System.Byte)(value ? 1 : 0); - } - - internal System.Byte _Primary; - } - - /// - /// No documentation. - /// - /// AvnSize - /// AvnSize - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnSize - { - /// - /// No documentation. - /// - /// Width - /// Width - public System.Double Width; - /// - /// No documentation. - /// - /// Height - /// Height - public System.Double Height; - } - - /// - /// No documentation. - /// - /// AvnVector - /// AvnVector - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 0, CharSet = System.Runtime.InteropServices.CharSet.Unicode)] - public partial struct AvnVector - { - /// - /// No documentation. - /// - /// X - /// X - public System.Double X; - /// - /// No documentation. - /// - /// Y - /// Y - public System.Double Y; - } -} \ No newline at end of file diff --git a/src/Avalonia.Native/Helpers.cs b/src/Avalonia.Native/Helpers.cs index 25e8250232..564434a04c 100644 --- a/src/Avalonia.Native/Helpers.cs +++ b/src/Avalonia.Native/Helpers.cs @@ -2,7 +2,7 @@ namespace Avalonia.Native { - public static class Helpers + internal static class Helpers { public static Point ToAvaloniaPoint (this AvnPoint pt) { diff --git a/src/Avalonia.Native/IAvnMenu.cs b/src/Avalonia.Native/IAvnMenu.cs index 8a49559a02..dd9464284f 100644 --- a/src/Avalonia.Native/IAvnMenu.cs +++ b/src/Avalonia.Native/IAvnMenu.cs @@ -22,15 +22,23 @@ namespace Avalonia.Native.Interop } } - public partial class IAvnMenu + partial interface IAvnMenu + { + void RaiseNeedsUpdate(); + void Deinitialise(); + } +} +namespace Avalonia.Native.Interop.Impl +{ + partial class __MicroComIAvnMenuProxy { private MenuEvents _events; private AvaloniaNativeMenuExporter _exporter; - private List _menuItems = new List(); - private Dictionary _menuItemLookup = new Dictionary(); + private List<__MicroComIAvnMenuItemProxy> _menuItems = new List<__MicroComIAvnMenuItemProxy>(); + private Dictionary _menuItemLookup = new Dictionary(); private CompositeDisposable _propertyDisposables = new CompositeDisposable(); - internal void RaiseNeedsUpdate() + public void RaiseNeedsUpdate() { (ManagedMenu as INativeMenuExporterEventsImplBridge).RaiseNeedsUpdate(); @@ -39,11 +47,11 @@ namespace Avalonia.Native.Interop internal NativeMenu ManagedMenu { get; private set; } - public static IAvnMenu Create(IAvaloniaNativeFactory factory) + public static __MicroComIAvnMenuProxy Create(IAvaloniaNativeFactory factory) { var events = new MenuEvents(); - var menu = factory.CreateMenu(events); + var menu = (__MicroComIAvnMenuProxy)factory.CreateMenu(events); events.Initialise(menu); @@ -60,7 +68,7 @@ namespace Avalonia.Native.Interop } } - private void RemoveAndDispose(IAvnMenuItem item) + private void RemoveAndDispose(__MicroComIAvnMenuItemProxy item) { _menuItemLookup.Remove(item.ManagedMenuItem); _menuItems.Remove(item); @@ -70,7 +78,7 @@ namespace Avalonia.Native.Interop item.Dispose(); } - private void MoveExistingTo(int index, IAvnMenuItem item) + private void MoveExistingTo(int index, __MicroComIAvnMenuItemProxy item) { _menuItems.Remove(item); _menuItems.Insert(index, item); @@ -79,7 +87,7 @@ namespace Avalonia.Native.Interop InsertItem(index, item); } - private IAvnMenuItem CreateNewAt(IAvaloniaNativeFactory factory, int index, NativeMenuItemBase item) + private __MicroComIAvnMenuItemProxy CreateNewAt(IAvaloniaNativeFactory factory, int index, NativeMenuItemBase item) { var result = CreateNew(factory, item); @@ -93,9 +101,11 @@ namespace Avalonia.Native.Interop return result; } - private IAvnMenuItem CreateNew(IAvaloniaNativeFactory factory, NativeMenuItemBase item) + private __MicroComIAvnMenuItemProxy CreateNew(IAvaloniaNativeFactory factory, NativeMenuItemBase item) { - var nativeItem = item is NativeMenuItemSeperator ? factory.CreateMenuItemSeperator() : factory.CreateMenuItem(); + var nativeItem = (__MicroComIAvnMenuItemProxy)(item is NativeMenuItemSeperator ? + factory.CreateMenuItemSeperator() : + factory.CreateMenuItem()); nativeItem.ManagedMenuItem = item; return nativeItem; @@ -108,16 +118,11 @@ namespace Avalonia.Native.Interop ((INotifyCollectionChanged)ManagedMenu.Items).CollectionChanged += OnMenuItemsChanged; - if (!string.IsNullOrWhiteSpace(title)) - { - using (var buffer = new Utf8Buffer(title)) - { - Title = buffer.DangerousGetHandle(); - } - } + if (!string.IsNullOrWhiteSpace(title)) + SetTitle(title); } - internal void Deinitialise() + public void Deinitialise() { ((INotifyCollectionChanged)ManagedMenu.Items).CollectionChanged -= OnMenuItemsChanged; @@ -137,7 +142,7 @@ namespace Avalonia.Native.Interop for (int i = 0; i < menu.Items.Count; i++) { - IAvnMenuItem nativeItem; + __MicroComIAvnMenuItemProxy nativeItem; if (i >= _menuItems.Count) { diff --git a/src/Avalonia.Native/IAvnMenuItem.cs b/src/Avalonia.Native/IAvnMenuItem.cs index c8819d1994..e2feffaa33 100644 --- a/src/Avalonia.Native/IAvnMenuItem.cs +++ b/src/Avalonia.Native/IAvnMenuItem.cs @@ -7,37 +7,35 @@ using Avalonia.Platform.Interop; namespace Avalonia.Native.Interop { - public partial class IAvnMenuItem + partial interface IAvnMenuItem { - private IAvnMenu _subMenu; + + } +} +namespace Avalonia.Native.Interop.Impl +{ + partial class __MicroComIAvnMenuItemProxy + { + private __MicroComIAvnMenuProxy _subMenu; private CompositeDisposable _propertyDisposables = new CompositeDisposable(); private IDisposable _currentActionDisposable; public NativeMenuItemBase ManagedMenuItem { get; set; } - private void UpdateTitle(string title) - { - using (var buffer = new Utf8Buffer(string.IsNullOrWhiteSpace(title) ? "" : title)) - { - Title = buffer.DangerousGetHandle(); - } - } + private void UpdateTitle(string title) => SetTitle(title ?? ""); - private void UpdateIsChecked(bool isChecked) - { - IsChecked = isChecked; - } + private void UpdateIsChecked(bool isChecked) => SetIsChecked(isChecked); private void UpdateToggleType(NativeMenuItemToggleType toggleType) { - ToggleType = (AvnMenuItemToggleType)toggleType; + SetToggleType((AvnMenuItemToggleType)toggleType); } private unsafe void UpdateIcon (IBitmap icon) { if(icon is null) { - SetIcon(IntPtr.Zero, 0); + SetIcon(null, IntPtr.Zero); } else { @@ -49,7 +47,7 @@ namespace Avalonia.Native.Interop fixed(void* ptr = imageData) { - SetIcon(new IntPtr(ptr), imageData.Length); + SetIcon(ptr, new IntPtr(imageData.Length)); } } } @@ -57,12 +55,9 @@ namespace Avalonia.Native.Interop private void UpdateGesture(Input.KeyGesture gesture) { - // todo ensure backend can cope with setting null gesture. - using (var buffer = new Utf8Buffer(gesture == null ? "" : OsxUnicodeKeys.ConvertOSXSpecialKeyCodes(gesture.Key))) - { - var modifiers = gesture == null ? AvnInputModifiers.AvnInputModifiersNone : (AvnInputModifiers)gesture.KeyModifiers; - SetGesture(buffer.DangerousGetHandle(), modifiers); - } + var text = gesture == null ? "" : OsxUnicodeKeys.ConvertOSXSpecialKeyCodes(gesture.Key); + var modifiers = gesture == null ? AvnInputModifiers.AvnInputModifiersNone : (AvnInputModifiers)gesture.KeyModifiers; + SetGesture(text, modifiers); } private void UpdateAction(NativeMenuItem item) @@ -153,7 +148,7 @@ namespace Avalonia.Native.Interop { if (_subMenu == null) { - _subMenu = IAvnMenu.Create(factory); + _subMenu = __MicroComIAvnMenuProxy.Create(factory); _subMenu.Initialise(exporter, item.Menu, item.Header); diff --git a/src/Avalonia.Native/NativeControlHostImpl.cs b/src/Avalonia.Native/NativeControlHostImpl.cs index a46528dc48..2c9c1728d3 100644 --- a/src/Avalonia.Native/NativeControlHostImpl.cs +++ b/src/Avalonia.Native/NativeControlHostImpl.cs @@ -1,5 +1,6 @@ using System; using Avalonia.Controls.Platform; +using Avalonia.MicroCom; using Avalonia.Native.Interop; using Avalonia.Platform; using Avalonia.VisualTree; @@ -28,8 +29,7 @@ namespace Avalonia.Native public DestroyableNSView(IAvnNativeControlHost impl) { - _impl = new IAvnNativeControlHost(impl.NativePointer); - _impl.AddRef(); + _impl = MicroComRuntime.CloneReference(impl); _nsView = _impl.CreateDefaultChild(IntPtr.Zero); } diff --git a/src/Avalonia.Native/PlatformThreadingInterface.cs b/src/Avalonia.Native/PlatformThreadingInterface.cs index 5a81f6a3bf..df69f2eafb 100644 --- a/src/Avalonia.Native/PlatformThreadingInterface.cs +++ b/src/Avalonia.Native/PlatformThreadingInterface.cs @@ -4,11 +4,10 @@ using System.Threading; using Avalonia.Native.Interop; using Avalonia.Platform; using Avalonia.Threading; -using SharpGen.Runtime; namespace Avalonia.Native { - public class PlatformThreadingInterface : IPlatformThreadingInterface + internal class PlatformThreadingInterface : IPlatformThreadingInterface { class TimerCallback : CallbackBase, IAvnActionCallback { @@ -48,7 +47,7 @@ namespace Avalonia.Native { _native = native; using (var cb = new SignaledCallback(this)) - _native.SignaledCallback = cb; + _native.SetSignaledCallback(cb); } public bool CurrentThreadIsLoopThread => _native.CurrentThreadIsLoopThread; diff --git a/src/Avalonia.Native/ScreenImpl.cs b/src/Avalonia.Native/ScreenImpl.cs index f28be52dd5..ae6da01388 100644 --- a/src/Avalonia.Native/ScreenImpl.cs +++ b/src/Avalonia.Native/ScreenImpl.cs @@ -14,7 +14,7 @@ namespace Avalonia.Native _native = native; } - public int ScreenCount => _native.GetScreenCount(); + public int ScreenCount => _native.ScreenCount; public IReadOnlyList AllScreens { diff --git a/src/Avalonia.Native/SystemDialogs.cs b/src/Avalonia.Native/SystemDialogs.cs index 98e3e383dc..0239fc680d 100644 --- a/src/Avalonia.Native/SystemDialogs.cs +++ b/src/Avalonia.Native/SystemDialogs.cs @@ -8,7 +8,7 @@ using Avalonia.Native.Interop; namespace Avalonia.Native { - public class SystemDialogs : ISystemDialogImpl + internal class SystemDialogs : ISystemDialogImpl { IAvnSystemDialogs _native; @@ -62,7 +62,7 @@ namespace Avalonia.Native } } - public class SystemDialogEvents : CallbackBase, IAvnSystemDialogEvents + internal unsafe class SystemDialogEvents : CallbackBase, IAvnSystemDialogEvents { private TaskCompletionSource _tcs; @@ -73,13 +73,13 @@ namespace Avalonia.Native public Task Task => _tcs.Task; - public void OnCompleted(int numResults, IntPtr trFirstResultRef) + public void OnCompleted(int numResults, void* trFirstResultRef) { string[] results = new string[numResults]; unsafe { - var ptr = (IntPtr*)trFirstResultRef.ToPointer(); + var ptr = (IntPtr*)trFirstResultRef; for (int i = 0; i < numResults; i++) { diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index 11a0ebce61..b42831854d 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -10,7 +10,7 @@ using Avalonia.Platform.Interop; namespace Avalonia.Native { - public class WindowImpl : WindowBaseImpl, IWindowImpl, ITopLevelImplWithNativeMenuExporter + internal class WindowImpl : WindowBaseImpl, IWindowImpl, ITopLevelImplWithNativeMenuExporter { private readonly IAvaloniaNativeFactory _factory; private readonly AvaloniaNativePlatformOptions _opts; @@ -69,12 +69,12 @@ namespace Avalonia.Native public void CanResize(bool value) { - _native.CanResize = value; + _native.SetCanResize(value); } public void SetSystemDecorations(Controls.SystemDecorations enabled) { - _native.Decorations = (Interop.SystemDecorations)enabled; + _native.SetDecorations((Interop.SystemDecorations)enabled); } public void SetTitleBarColor(Avalonia.Media.Color color) @@ -82,24 +82,12 @@ namespace Avalonia.Native _native.SetTitleBarColor(new AvnColor { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B }); } - public void SetTitle(string title) - { - using (var buffer = new Utf8Buffer(title)) - { - _native.SetTitle(buffer.DangerousGetHandle()); - } - } + public void SetTitle(string title) => _native.SetTitle(title); public WindowState WindowState { - get - { - return (WindowState)_native.GetWindowState(); - } - set - { - _native.SetWindowState((AvnWindowState)value); - } + get => (WindowState)_native.WindowState; + set => _native.SetWindowState((AvnWindowState)value); } public Action WindowStateChanged { get; set; } @@ -146,7 +134,7 @@ namespace Avalonia.Native } else { - ExtendedMargins = _isExtended ? new Thickness(0, _extendTitleBarHeight == -1 ? _native.GetExtendTitleBarHeight() : _extendTitleBarHeight, 0, 0) : new Thickness(); + ExtendedMargins = _isExtended ? new Thickness(0, _extendTitleBarHeight == -1 ? _native.ExtendTitleBarHeight : _extendTitleBarHeight, 0, 0) : new Thickness(); } ExtendClientAreaToDecorationsChanged?.Invoke(_isExtended); @@ -174,7 +162,7 @@ namespace Avalonia.Native _extendTitleBarHeight = titleBarHeight; _native.SetExtendTitleBarHeight(titleBarHeight); - ExtendedMargins = _isExtended ? new Thickness(0, titleBarHeight == -1 ? _native.GetExtendTitleBarHeight() : titleBarHeight, 0, 0) : new Thickness(); + ExtendedMargins = _isExtended ? new Thickness(0, titleBarHeight == -1 ? _native.ExtendTitleBarHeight : titleBarHeight, 0, 0) : new Thickness(); ExtendClientAreaToDecorationsChanged?.Invoke(_isExtended); } diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 824f62aee5..bc0916c8da 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -15,7 +15,7 @@ using Avalonia.Threading; namespace Avalonia.Native { - public class MacOSTopLevelWindowHandle : IPlatformHandle, IMacOSTopLevelPlatformHandle + internal class MacOSTopLevelWindowHandle : IPlatformHandle, IMacOSTopLevelPlatformHandle { IAvnWindowBase _native; @@ -43,7 +43,7 @@ namespace Avalonia.Native } } - public abstract class WindowBaseImpl : IWindowBaseImpl, + internal abstract class WindowBaseImpl : IWindowBaseImpl, IFramebufferPlatformSurface, ITopLevelImplWithNativeControlHost { protected IInputRoot _inputRoot; @@ -96,7 +96,7 @@ namespace Avalonia.Native { if (_native != null) { - var s = _native.GetClientSize(); + var s = _native.ClientSize; return new Size(s.Width, s.Height); } @@ -137,7 +137,7 @@ namespace Avalonia.Native public IMouseDevice MouseDevice => _mouse; public abstract IPopupImpl CreatePopup(); - protected class WindowBaseEvents : CallbackBase, IAvnWindowBaseEvents + protected unsafe class WindowBaseEvents : CallbackBase, IAvnWindowBaseEvents { private readonly WindowBaseImpl _parent; @@ -172,11 +172,11 @@ namespace Avalonia.Native _parent.Paint?.Invoke(new Rect(0, 0, s.Width, s.Height)); } - void IAvnWindowBaseEvents.Resized(AvnSize size) + void IAvnWindowBaseEvents.Resized(AvnSize* size) { if (_parent._native != null) { - var s = new Size(size.Width, size.Height); + var s = new Size(size->Width, size->Height); _parent._savedLogicalSize = s; _parent.Resized?.Invoke(s); } @@ -359,7 +359,7 @@ namespace Avalonia.Native public PixelPoint Position { - get => _native.GetPosition().ToAvaloniaPixelPoint(); + get => _native.Position.ToAvaloniaPixelPoint(); set => _native.SetPosition(value.ToAvnPoint()); } @@ -391,7 +391,7 @@ namespace Avalonia.Native _native.SetTopMost(value); } - public double RenderScaling => _native?.GetScaling() ?? 1; + public double RenderScaling => _native?.Scaling ?? 1; public double DesktopScaling => 1; @@ -407,7 +407,7 @@ namespace Avalonia.Native var newCursor = cursor as AvaloniaNativeCursor; newCursor = newCursor ?? (_cursorFactory.GetCursor(StandardCursorType.Arrow) as AvaloniaNativeCursor); - _native.Cursor = newCursor.Cursor; + _native.SetCursor(newCursor.Cursor); } public Action PositionChanged { get; set; } diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index c763007826..dc139cf8e3 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -1,4 +1,4 @@ -@clr-namespace Avalonia.Native.MicroCom +@clr-namespace Avalonia.Native.Interop @clr-access internal @cpp-preamble @@ #include "com.h" @@ -244,13 +244,13 @@ interface IAvnWindowBase : IUnknown HRESULT SetCursor(IAvnCursor* cursor); HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret); HRESULT SetMainMenu(IAvnMenu* menu); - HRESULT ObtainNSWindowHandle(void** retOut); - HRESULT ObtainNSWindowHandleRetained(void** retOut); - HRESULT ObtainNSViewHandle(void** retOut); - HRESULT ObtainNSViewHandleRetained(void** retOut); + HRESULT ObtainNSWindowHandle([intptr]void** retOut); + HRESULT ObtainNSWindowHandleRetained([intptr]void** retOut); + HRESULT ObtainNSViewHandle([intptr]void** retOut); + HRESULT ObtainNSViewHandleRetained([intptr]void** retOut); HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut); HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, - IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle); + IAvnClipboard* clipboard, IAvnDndResultCallback* cb, [intptr]void* sourceHandle); HRESULT SetBlurEnabled(bool enable); } @@ -267,7 +267,7 @@ interface IAvnWindow : IAvnWindowBase HRESULT SetParent(IAvnWindow* parent); HRESULT SetCanResize(bool value); HRESULT SetDecorations(SystemDecorations value); - HRESULT SetTitle(void* utf8Title); + HRESULT SetTitle(char* utf8Title); HRESULT SetTitleBarColor(AvnColor color); HRESULT SetWindowState(AvnWindowState state); HRESULT GetWindowState(AvnWindowState*ret); @@ -299,7 +299,7 @@ interface IAvnWindowBaseEvents : IUnknown void LostFocus(); AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position, AvnInputModifiers modifiers, AvnDragDropEffects effects, - IAvnClipboard* clipboard, void* dataObjectHandle); + IAvnClipboard* clipboard, [intptr]void* dataObjectHandle); } [uuid(1ae178ee-1fcc-447f-b6dd-b7bb727f934c)] @@ -321,7 +321,7 @@ interface IAvnWindowEvents : IAvnWindowBaseEvents interface IAvnMacOptions : IUnknown { HRESULT SetShowInDock(int show); - HRESULT SetApplicationTitle(void* utf8string); + HRESULT SetApplicationTitle(char* utf8string); } [uuid(04c1b049-1f43-418a-9159-cae627ec1367)] @@ -395,7 +395,7 @@ interface IAvnScreens : IUnknown interface IAvnClipboard : IUnknown { HRESULT GetText(char* type, IAvnString**ppv); - HRESULT SetText(char* type, void* utf8Text); + HRESULT SetText(char* type, char* utf8Text); HRESULT ObtainFormats(IAvnStringArray**ppv); HRESULT GetStrings(char* type, IAvnStringArray**ppv); HRESULT SetBytes(char* type, void* utf8Text, int len); @@ -420,8 +420,8 @@ interface IAvnGlDisplay : IUnknown { HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv); void LegacyClearCurrentContext(); - HRESULT WrapContext(void* native, IAvnGlContext**ppv); - void* GetProcAddress(char* proc); + HRESULT WrapContext([intptr]void* native, IAvnGlContext**ppv); + [intptr]void* GetProcAddress(char* proc); } [uuid(78c5711e-2a98-40d2-bac4-0cc9a49dc4f3)] @@ -431,7 +431,7 @@ interface IAvnGlContext : IUnknown HRESULT LegacyMakeCurrent(); int GetSampleCount(); int GetStencilSize(); - void* GetNativeHandle(); + [intptr]void* GetNativeHandle(); } [uuid(931062d2-5bc8-4062-8588-83dd8deb99c2)] @@ -452,7 +452,7 @@ interface IAvnMenu : IUnknown { HRESULT InsertItem(int index, IAvnMenuItem* item); HRESULT RemoveItem(IAvnMenuItem* item); - HRESULT SetTitle(void* utf8String); + HRESULT SetTitle(char* utf8String); HRESULT Clear(); } @@ -466,8 +466,8 @@ interface IAvnPredicateCallback : IUnknown interface IAvnMenuItem : IUnknown { HRESULT SetSubMenu(IAvnMenu* menu); - HRESULT SetTitle(void* utf8String); - HRESULT SetGesture(void* utf8String, AvnInputModifiers modifiers); + HRESULT SetTitle(char* utf8String); + HRESULT SetGesture(char* utf8String, AvnInputModifiers modifiers); HRESULT SetAction(IAvnPredicateCallback* predicate, IAvnActionCallback* callback); HRESULT SetIsChecked(bool isChecked); HRESULT SetToggleType(AvnMenuItemToggleType toggleType); @@ -499,22 +499,22 @@ interface IAvnDndResultCallback : IUnknown [uuid(f07c608e-52e9-422d-836e-c70f6e9b80f5)] interface IAvnGCHandleDeallocatorCallback : IUnknown { - void FreeGCHandle(void* handle); + void FreeGCHandle([intptr]void* handle); } [uuid(91c7f677-f26b-4ff3-93cc-cf15aa966ffa)] interface IAvnNativeControlHost : IUnknown { - HRESULT CreateDefaultChild(void* parent, void** retOut); + HRESULT CreateDefaultChild([intptr]void* parent, [intptr]void** retOut); IAvnNativeControlHostTopLevelAttachment* CreateAttachment(); - void DestroyDefaultChild(void* child); + void DestroyDefaultChild([intptr]void* child); } [uuid(14a9e164-1aae-4271-bb78-7b5230999b52)] interface IAvnNativeControlHostTopLevelAttachment : IUnknown { - void* GetParentHandle(); - HRESULT InitializeWithChildHandle(void* child); + [intptr]void* GetParentHandle(); + HRESULT InitializeWithChildHandle([intptr]void* child); HRESULT AttachTo(IAvnNativeControlHost* host); void ShowInBounds(float x, float y, float width, float height); void HideWithSize(float width, float height); diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs index 8613cbba88..2c366b143d 100644 --- a/src/tools/MicroComGenerator/Ast.cs +++ b/src/tools/MicroComGenerator/Ast.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Linq; namespace MicroComGenerator.Ast { @@ -14,13 +16,38 @@ namespace MicroComGenerator.Ast } public override string ToString() => $"{Name} = {Value}"; + public AstAttributeNode Clone() => new AstAttributeNode(Name, Value); } - public class AstEnumNode : List + public class AstAttributes : List { - public List Attributes { get; set; } = new List(); + public bool HasAttribute(string a) => this.Any(x => x.Name == a); + + public AstAttributes Clone() + { + var rv= new AstAttributes(); + rv.AddRange(this.Select(x => x.Clone())); + return rv; + } + } + + public interface IAstNodeWithAttributes + { + public AstAttributes Attributes { get; set; } + } + + public class AstEnumNode : List, IAstNodeWithAttributes + { + public AstAttributes Attributes { get; set; } = new AstAttributes(); public string Name { get; set; } - public override string ToString() => Name; + public override string ToString() => "Enum " + Name; + + public AstEnumNode Clone() + { + var rv = new AstEnumNode { Name = Name, Attributes = Attributes.Clone() }; + rv.AddRange(this.Select(x => x.Clone())); + return rv; + } } public class AstEnumMemberNode @@ -34,14 +61,22 @@ namespace MicroComGenerator.Ast Value = value; } - public override string ToString() => $"{Name} = {Value}"; + public override string ToString() => $"Enum member {Name} = {Value}"; + public AstEnumMemberNode Clone() => new AstEnumMemberNode(Name, Value); } - public class AstStructNode : List + public class AstStructNode : List, IAstNodeWithAttributes { - public List Attributes { get; set; } = new List(); + public AstAttributes Attributes { get; set; } = new AstAttributes(); public string Name { get; set; } - public override string ToString() => Name; + public override string ToString() => "Struct " + Name; + + public AstStructNode Clone() + { + var rv = new AstStructNode { Name = Name, Attributes = Attributes.Clone() }; + rv.AddRange(this.Select(x => x.Clone())); + return rv; + } } public class AstTypeNode @@ -49,20 +84,24 @@ namespace MicroComGenerator.Ast public string Name { get; set; } public int PointerLevel { get; set; } - public override string ToString() => Name + new string('*', PointerLevel); + public string Format() => Name + new string('*', PointerLevel); + public override string ToString() => Format(); + public AstTypeNode Clone() => new AstTypeNode() { Name = Name, PointerLevel = PointerLevel }; } - public class AstStructMemberNode + public class AstStructMemberNode : IAstNodeWithAttributes { public string Name { get; set; } public AstTypeNode Type { get; set; } - public override string ToString() => $"{Type} {Name}"; + public override string ToString() => $"Struct member {Type.Format()} {Name}"; + public AstStructMemberNode Clone() => new AstStructMemberNode() { Name = Name, Type = Type.Clone() }; + public AstAttributes Attributes { get; set; } = new AstAttributes(); } - public class AstInterfaceNode : List + public class AstInterfaceNode : List, IAstNodeWithAttributes { - public List Attributes { get; set; } = new List(); + public AstAttributes Attributes { get; set; } = new AstAttributes(); public string Name { get; set; } public string Inherits { get; set; } @@ -70,33 +109,127 @@ namespace MicroComGenerator.Ast { if (Inherits == null) return Name; - return $"{Name} : {Inherits}"; + return $"Interface {Name} : {Inherits}"; + } + public AstInterfaceNode Clone() + { + var rv = new AstInterfaceNode { Name = Name, Inherits = Inherits, Attributes = Attributes.Clone() }; + rv.AddRange(this.Select(x => x.Clone())); + return rv; } } - public class AstInterfaceMemberNode : List + public class AstInterfaceMemberNode : List, IAstNodeWithAttributes { public string Name { get; set; } public AstTypeNode ReturnType { get; set; } - public List Attributes { get; set; } = new List(); + public AstAttributes Attributes { get; set; } = new AstAttributes(); - public override string ToString() => $"{ReturnType} {Name} ({string.Join(", ", this)})"; + public AstInterfaceMemberNode Clone() + { + var rv = new AstInterfaceMemberNode() + { + Name = Name, Attributes = Attributes.Clone(), ReturnType = ReturnType + }; + rv.AddRange(this.Select(x => x.Clone())); + return rv; + } + + public override string ToString() => + $"Interface member {ReturnType.Format()} {Name} ({string.Join(", ", this.Select(x => x.Format()))})"; } - public class AstInterfaceMemberArgumentNode + public class AstInterfaceMemberArgumentNode : IAstNodeWithAttributes { public string Name { get; set; } public AstTypeNode Type { get; set; } - public List Attributes { get; set; } = new List(); + public AstAttributes Attributes { get; set; } = new AstAttributes(); + + + public string Format() => $"{Type.Format()} {Name}"; + public override string ToString() => "Argument " + Format(); - public override string ToString() => $"{Type} {Name}"; + public AstInterfaceMemberArgumentNode Clone() => new AstInterfaceMemberArgumentNode + { + Name = Name, Type = Type.Clone(), Attributes = Attributes.Clone() + }; } - public class AstIdlNode + public static class AstExtensions { - public List Attributes { get; set; } = new List(); + public static bool HasAttribute(this IAstNodeWithAttributes node, string s) => node.Attributes.HasAttribute(s); + + public static string GetAttribute(this IAstNodeWithAttributes node, string s) + { + var value = node.Attributes.FirstOrDefault(a => a.Name == s)?.Value; + if (value == null) + throw new CodeGenException("Expected attribute " + s + " for node " + node); + return value; + } + + public static string GetAttributeOrDefault(this IAstNodeWithAttributes node, string s) + => node.Attributes.FirstOrDefault(a => a.Name == s)?.Value; + } + + class AstVisitor + { + protected virtual void VisitType(AstTypeNode type) + { + } + + protected virtual void VisitArgument(AstInterfaceMemberArgumentNode argument) + { + VisitType(argument.Type); + } + + protected virtual void VisitInterfaceMember(AstInterfaceMemberNode member) + { + foreach(var a in member) + VisitArgument(a); + VisitType(member.ReturnType); + } + + protected virtual void VisitInterface(AstInterfaceNode iface) + { + foreach(var m in iface) + VisitInterfaceMember(m); + } + + protected virtual void VisitStructMember(AstStructMemberNode member) + { + VisitType(member.Type); + } + + protected virtual void VisitStruct(AstStructNode node) + { + foreach(var m in node) + VisitStructMember(m); + } + + public virtual void VisitAst(AstIdlNode ast) + { + foreach(var iface in ast.Interfaces) + VisitInterface(iface); + foreach (var s in ast.Structs) + VisitStruct(s); + } + + + } + + public class AstIdlNode : IAstNodeWithAttributes + { + public AstAttributes Attributes { get; set; } = new AstAttributes(); public List Enums { get; set; } = new List(); public List Structs { get; set; } = new List(); public List Interfaces { get; set; } = new List(); + + public AstIdlNode Clone() => new AstIdlNode() + { + Attributes = Attributes.Clone(), + Enums = Enums.Select(x => x.Clone()).ToList(), + Structs = Structs.Select(x => x.Clone()).ToList(), + Interfaces = Interfaces.Select(x => x.Clone()).ToList() + }; } } diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs index 46404da3d7..a003fb3096 100644 --- a/src/tools/MicroComGenerator/AstParser.cs +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -27,9 +27,9 @@ namespace MicroComGenerator return idl; } - static List ParseGlobalAttributes(ref TokenParser parser) + static AstAttributes ParseGlobalAttributes(ref TokenParser parser) { - var rv = new List(); + var rv = new AstAttributes(); while (!parser.Eof) { parser.SkipWhitespace(); @@ -61,9 +61,9 @@ namespace MicroComGenerator return rv; } - static List ParseLocalAttributes(ref TokenParser parser) + static AstAttributes ParseLocalAttributes(ref TokenParser parser) { - var rv = new List(); + var rv = new AstAttributes(); if (parser.TryConsume("[")) { while (!parser.TryConsume("]") && !parser.Eof) @@ -107,7 +107,7 @@ namespace MicroComGenerator throw new ParseException("{ expected", ref parser); } - static AstEnumNode ParseEnum(List attrs, ref TokenParser parser) + static AstEnumNode ParseEnum(AstAttributes attrs, ref TokenParser parser) { var name = parser.ParseIdentifier(); EnsureOpenBracket(ref parser); @@ -149,13 +149,14 @@ namespace MicroComGenerator return t; } - static AstStructNode ParseStruct(List attrs, ref TokenParser parser) + static AstStructNode ParseStruct(AstAttributes attrs, ref TokenParser parser) { var name = parser.ParseIdentifier(); EnsureOpenBracket(ref parser); var rv = new AstStructNode { Name = name, Attributes = attrs }; while (!parser.TryConsume('}') && !parser.Eof) { + var memberAttrs = ParseLocalAttributes(ref parser); var t = ParseType(ref parser); bool parsedAtLeastOneMember = false; while (!parser.TryConsume(';')) @@ -165,7 +166,7 @@ namespace MicroComGenerator var ident = parser.ParseIdentifier(); parsedAtLeastOneMember = true; - rv.Add(new AstStructMemberNode { Name = ident, Type = t }); + rv.Add(new AstStructMemberNode { Name = ident, Type = t, Attributes = memberAttrs}); } if (!parsedAtLeastOneMember) @@ -175,7 +176,7 @@ namespace MicroComGenerator return rv; } - static AstInterfaceNode ParseInterface(List interfaceAttrs, ref TokenParser parser) + static AstInterfaceNode ParseInterface(AstAttributes interfaceAttrs, ref TokenParser parser) { var interfaceName = parser.ParseIdentifier(); string inheritsFrom = null; diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index 2fcf1b404b..d6848dc48e 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -167,12 +167,12 @@ namespace MicroComGenerator if (type.PointerLevel == 2) { - if (type.Name.StartsWith("I")) + if (IsInterface(type)) return new InterfaceReturnArg { Name = name, InterfaceType = type.Name, NativeType = "void**" }; } else if (type.PointerLevel == 1) { - if (type.Name.StartsWith("I")) + if (IsInterface(type)) return new InterfaceArg { Name = name, InterfaceType = type.Name, NativeType = "void*" }; if (type.Name == "char") return new StringArg { Name = name, NativeType = "byte*" }; @@ -197,8 +197,7 @@ namespace MicroComGenerator && args.Count > 0 && (args.Last().Name == "ppv" || args.Last().Name == "retOut" || args.Last().Name == "ret") && ((member.Last().Type.PointerLevel > 0 - && !member.Last().Type.Name - .StartsWith("I")) + && !IsInterface(member.Last().Type)) || member.Last().Type.PointerLevel == 2); bool isVoidReturn = member.ReturnType.Name == "void" && member.ReturnType.PointerLevel == 0; @@ -390,21 +389,20 @@ namespace MicroComGenerator void GenerateInterface(ref NamespaceDeclarationSyntax ns, ref NamespaceDeclarationSyntax implNs, AstInterfaceNode iface) { - var guidString = iface.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value; - if (guidString == null) - throw new CodeGenException("Missing GUID for " + iface.Name); + var guidString = iface.GetAttribute("uuid"); var inheritsUnknown = iface.Inherits == null || iface.Inherits == "IUnknown"; var ifaceDec = InterfaceDeclaration(iface.Name) .WithBaseType(inheritsUnknown ? "Avalonia.MicroCom.IUnknown" : iface.Inherits) - .AddModifiers(Token(_visibility), Token(SyntaxKind.UnsafeKeyword)); + .AddModifiers(Token(_visibility), Token(SyntaxKind.UnsafeKeyword), Token(SyntaxKind.PartialKeyword)); var proxyClassName = "__MicroCom" + iface.Name + "Proxy"; var proxy = ClassDeclaration(proxyClassName) - .AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility)) + .AddModifiers(Token(SyntaxKind.UnsafeKeyword), Token(_visibility), Token(SyntaxKind.PartialKeyword)) .WithBaseType(inheritsUnknown ? "Avalonia.MicroCom.MicroComProxyBase" : - ("__MicroCom" + iface.Inherits + "Proxy")); + ("__MicroCom" + iface.Inherits + "Proxy")) + .AddBaseListTypes(SimpleBaseType(ParseTypeName(iface.Name))); // Generate vtable diff --git a/src/tools/MicroComGenerator/CSharpGen.Utils.cs b/src/tools/MicroComGenerator/CSharpGen.Utils.cs index ed2bcdd6d8..3a62220d12 100644 --- a/src/tools/MicroComGenerator/CSharpGen.Utils.cs +++ b/src/tools/MicroComGenerator/CSharpGen.Utils.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using MicroComGenerator.Ast; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Formatting; @@ -23,13 +24,16 @@ namespace MicroComGenerator string Format(CompilationUnitSyntax unit) { var cw = new AdhocWorkspace(); - return Microsoft.CodeAnalysis.Formatting.Formatter.Format(unit.NormalizeWhitespace(), cw, cw.Options - .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, true) - .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, true) - .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, true) - .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true) + return + "#pragma warning disable 108\n" + + Microsoft.CodeAnalysis.Formatting.Formatter.Format(unit.NormalizeWhitespace(), cw, cw.Options + .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, true) + .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, + true) + .WithChangedOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, true) + .WithChangedOption(CSharpFormattingOptions.NewLinesForBracesInMethods, true) - ).ToFullString(); + ).ToFullString(); } @@ -93,5 +97,14 @@ namespace MicroComGenerator return decl.ReplaceNodes(replace.Keys, (m, m2) => replace[m]); } + bool IsInterface(string name) + { + if (name == "IUnknown") + return true; + return _idl.Interfaces.Any(i => i.Name == name); + } + + private bool IsInterface(AstTypeNode type) => IsInterface(type.Name); + } } diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 49e4f7a09e..93fce16dfc 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; @@ -20,14 +21,12 @@ namespace MicroComGenerator public CSharpGen(AstIdlNode idl) { - _idl = idl; + _idl = idl.Clone(); + new AstRewriter().VisitAst(_idl); _extraUsings = _idl.Attributes.Where(u => u.Name == "clr-using").Select(u => u.Value).ToList(); - _namespace = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-namespace")?.Value; - if (_namespace == null) - throw new CodeGenException("Missing clr-namespace attribute"); - var visibilityString = _idl.Attributes.FirstOrDefault(x => x.Name == "clr-access")?.Value; - if (visibilityString == null) - throw new CodeGenException("Missing clr-visibility attribute"); + _namespace = _idl.GetAttribute("clr-namespace"); + var visibilityString = _idl.GetAttribute("clr-access"); + if (visibilityString == "internal") _visibility = SyntaxKind.InternalKeyword; else if (visibilityString == "public") @@ -36,6 +35,45 @@ namespace MicroComGenerator throw new CodeGenException("Invalid clr-access attribute"); } + class AstRewriter : AstVisitor + { + void ConvertIntPtr(AstTypeNode type) + { + if (type.Name == "void" && type.PointerLevel > 0) + { + type.Name = "IntPtr"; + type.PointerLevel--; + } + } + + protected override void VisitStructMember(AstStructMemberNode member) + { + if (member.HasAttribute("intptr")) + ConvertIntPtr(member.Type); + base.VisitStructMember(member); + } + + protected override void VisitArgument(AstInterfaceMemberArgumentNode argument) + { + if (argument.HasAttribute("intptr")) + { + if(argument.Name == "retOut") + Console.WriteLine(); + ConvertIntPtr(argument.Type); + } + + base.VisitArgument(argument); + } + + protected override void VisitInterfaceMember(AstInterfaceMemberNode member) + { + if (member.HasAttribute("intptr")) + ConvertIntPtr(member.ReturnType); + base.VisitInterfaceMember(member); + } + } + + public string Generate() { var ns = NamespaceDeclaration(ParseName(_namespace)); diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs index 133902f764..f2b748787f 100644 --- a/src/tools/MicroComGenerator/CppGen.cs +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -20,7 +20,7 @@ namespace MicroComGenerator public static string GenerateCpp(AstIdlNode idl) { var sb = new StringBuilder(); - var preamble = idl.Attributes.FirstOrDefault(x => x.Name == "cpp-preamble")?.Value; + var preamble = idl.GetAttributeOrDefault("cpp-preamble"); if (preamble != null) sb.AppendLine(preamble); @@ -60,10 +60,7 @@ namespace MicroComGenerator foreach (var i in idl.Interfaces) { - var guidString = i.Attributes.FirstOrDefault(x => x.Name == "uuid")?.Value; - if (guidString == null) - throw new CodeGenException("Missing uuid for " + i.Name); - + var guidString = i.GetAttribute("uuid"); var guid = Guid.Parse(guidString).ToString().Replace("-", ""); diff --git a/src/tools/MicroComGenerator/MicroComGenerator.csproj b/src/tools/MicroComGenerator/MicroComGenerator.csproj index 193bb9a100..5ae431b4b9 100644 --- a/src/tools/MicroComGenerator/MicroComGenerator.csproj +++ b/src/tools/MicroComGenerator/MicroComGenerator.csproj @@ -1,5 +1,4 @@ - Exe netcoreapp3.1 @@ -8,5 +7,4 @@ - From a8c871963960b8ecf56edc6d8e992984605ecbea Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 17:19:59 +0300 Subject: [PATCH 034/314] Module initializer hooks should be called before ret --- src/Avalonia.Build.Tasks/ComInteropHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Build.Tasks/ComInteropHelper.cs b/src/Avalonia.Build.Tasks/ComInteropHelper.cs index 2f92ddc116..007231417d 100644 --- a/src/Avalonia.Build.Tasks/ComInteropHelper.cs +++ b/src/Avalonia.Build.Tasks/ComInteropHelper.cs @@ -47,7 +47,7 @@ namespace Avalonia.Build.Tasks } foreach (var i in initializers) - staticCtor.Body.Instructions.Add(Instruction.Create(OpCodes.Call, i)); + staticCtor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, i)); } } From 96eaa26d1dd87e9015b440e68a4cbd12e6832e72 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 28 Oct 2020 19:54:30 +0300 Subject: [PATCH 035/314] Add System.Runtime.InteropServices.UnmanagedFunctionPointer --- src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs | 7 ++++--- src/tools/MicroComGenerator/CSharpGen.cs | 7 +------ src/tools/MicroComGenerator/Extensions.cs | 7 +++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index d6848dc48e..b4a0770e73 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -278,11 +278,12 @@ namespace MicroComGenerator // Generate VTable method - - var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name+"Delegate") + var shadowDelegate = DelegateDeclaration(ParseTypeName(returnArg.NativeType), member.Name + "Delegate") .AddParameterListParameters(Parameter(Identifier("@this")).WithType(ParseTypeName("IntPtr"))) .AddParameterListParameters(args.Select(x => - Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()); + Parameter(Identifier(x.Name)).WithType(ParseTypeName(x.NativeType))).ToArray()) + .AddAttribute("System.Runtime.InteropServices.UnmanagedFunctionPointer", + "System.Runtime.InteropServices.CallingConvention.StdCall"); var shadowMethod = MethodDeclaration(shadowDelegate.ReturnType, member.Name) .WithParameterList(shadowDelegate.ParameterList) diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 93fce16dfc..8806531b19 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -109,13 +109,8 @@ namespace MicroComGenerator return ns.AddMembers(_idl.Structs.Select(e => StructDeclaration(e.Name) .WithModifiers(TokenList(Token(_visibility))) + .AddAttribute("System.Runtime.InteropServices.StructLayout", "System.Runtime.InteropServices.LayoutKind.Sequential") .AddModifiers(Token(SyntaxKind.UnsafeKeyword)) - .AddAttributeLists(AttributeList(SingletonSeparatedList( - Attribute(ParseName("System.Runtime.InteropServices.StructLayout"), - AttributeArgumentList(SingletonSeparatedList( - AttributeArgument( - ParseExpression("System.Runtime.InteropServices.LayoutKind.Sequential")))) - )))) .WithMembers(new SyntaxList(SeparatedList(e.Select(m => DeclareField(m.Type.ToString(), m.Name, SyntaxKind.PublicKeyword))))) ).ToArray()); diff --git a/src/tools/MicroComGenerator/Extensions.cs b/src/tools/MicroComGenerator/Extensions.cs index 4942442d1b..c8a4c8f45c 100644 --- a/src/tools/MicroComGenerator/Extensions.cs +++ b/src/tools/MicroComGenerator/Extensions.cs @@ -81,6 +81,13 @@ namespace MicroComGenerator return cl.AddBaseListTypes(SimpleBaseType(SyntaxFactory.ParseTypeName(bt))); } + public static T AddAttribute(this T member, string attribute, params string[] args) where T : MemberDeclarationSyntax + { + return (T)member.AddAttributeLists(AttributeList(SingletonSeparatedList( + Attribute(ParseName(attribute), AttributeArgumentList( + SeparatedList(args.Select(a => AttributeArgument(ParseExpression(a))))))))); + } + public static string StripPrefix(this string s, string prefix) => string.IsNullOrEmpty(s) ? s : s.StartsWith(prefix) From c404dcf1c70357d07c5529212b4e8f492be6f491 Mon Sep 17 00:00:00 2001 From: artyom Date: Wed, 28 Oct 2020 22:36:56 +0300 Subject: [PATCH 036/314] Use GetObservable and AvaProperty.UnSet --- .../ReactiveUserControl.cs | 27 +++++-- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 27 +++++-- .../ReactiveUserControlTest.cs | 71 +++++++++++++++++++ 3 files changed, 117 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 31f4691c90..416f0a2165 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -29,10 +29,29 @@ namespace Avalonia.ReactiveUI // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.ObservableForProperty(x => x.ViewModel, false, true) - .Subscribe(args => DataContext = args.Value); - this.ObservableForProperty(x => x.DataContext, false, true) - .Subscribe(args => ViewModel = args.Value as TViewModel); + this.GetObservable(DataContextProperty).Subscribe(value => + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + }); + + this.GetObservable(ViewModelProperty).Subscribe(value => + { + if (value == null) + { + DataContext = AvaloniaProperty.UnsetValue; + } + else + { + DataContext = value; + } + }); } /// diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index 1204266b63..fcef0a019f 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -29,10 +29,29 @@ namespace Avalonia.ReactiveUI // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.ObservableForProperty(x => x.ViewModel, false, true) - .Subscribe(args => DataContext = args.Value); - this.ObservableForProperty(x => x.DataContext, false, true) - .Subscribe(args => ViewModel = args.Value as TViewModel); + this.GetObservable(DataContextProperty).Subscribe(value => + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + }); + + this.GetObservable(ViewModelProperty).Subscribe(value => + { + if (value == null) + { + DataContext = AvaloniaProperty.UnsetValue; + } + else + { + DataContext = value; + } + }); } /// diff --git a/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs index 5d257f75f2..4dd60e21c5 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/ReactiveUserControlTest.cs @@ -1,4 +1,5 @@ using System.Reactive.Disposables; +using Avalonia.Controls; using Avalonia.UnitTests; using ReactiveUI; using Splat; @@ -100,5 +101,75 @@ namespace Avalonia.ReactiveUI.UnitTests Assert.NotNull(view.DataContext); Assert.False(view.ViewModel.IsActive); } + + [Fact] + public void Should_Inherit_DataContext() + { + var vm1 = new ExampleViewModel(); + var vm2 = new ExampleViewModel(); + var view = new ExampleView(); + var root = new TestRoot(view); + + Assert.Null(view.DataContext); + Assert.Null(view.ViewModel); + + root.DataContext = vm1; + + Assert.Same(vm1, view.DataContext); + Assert.Same(vm1, view.ViewModel); + + root.DataContext = null; + + Assert.Null(view.DataContext); + Assert.Null(view.ViewModel); + + root.DataContext = vm2; + + Assert.Same(vm2, view.DataContext); + Assert.Same(vm2, view.ViewModel); + } + + [Fact] + public void Should_Not_Overlap_Change_Notifications() + { + var vm1 = new ExampleViewModel(); + var vm2 = new ExampleViewModel(); + + var view1 = new ExampleView(); + var view2 = new ExampleView(); + + Assert.Null(view1.DataContext); + Assert.Null(view2.DataContext); + Assert.Null(view1.ViewModel); + Assert.Null(view2.ViewModel); + + view1.DataContext = vm1; + + Assert.Same(vm1, view1.DataContext); + Assert.Same(vm1, view1.ViewModel); + Assert.Null(view2.DataContext); + Assert.Null(view2.ViewModel); + + view2.DataContext = vm2; + + Assert.Same(vm1, view1.DataContext); + Assert.Same(vm1, view1.ViewModel); + Assert.Same(vm2, view2.DataContext); + Assert.Same(vm2, view2.ViewModel); + + view1.ViewModel = null; + + Assert.Null(view1.DataContext); + Assert.Null(view1.ViewModel); + Assert.Same(vm2, view2.DataContext); + Assert.Same(vm2, view2.ViewModel); + + view2.ViewModel = null; + + Assert.Null(view1.DataContext); + Assert.Null(view2.DataContext); + Assert.Null(view1.ViewModel); + Assert.Null(view2.ViewModel); + } } } From b8ad5a6dd152e4e80ef622d5c6fd0ed91bc2b607 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 19:47:20 +0000 Subject: [PATCH 037/314] change template for datavalidation errors. --- .../DataValidationErrors.xaml | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml b/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml index 902fc74c0c..1161a92e30 100644 --- a/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml +++ b/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml @@ -14,39 +14,31 @@ - - + + - - - - - - - - - - + + + + + + + From a6d83bb7ce306388d18bee75c338f2d7f535ea3b Mon Sep 17 00:00:00 2001 From: artyom Date: Wed, 28 Oct 2020 23:11:10 +0300 Subject: [PATCH 038/314] Correct change notification listeners --- .../ReactiveUserControl.cs | 50 ++++++++++--------- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 50 ++++++++++--------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 416f0a2165..40d9666c3e 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -28,30 +28,8 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - - this.GetObservable(DataContextProperty).Subscribe(value => - { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } - }); - - this.GetObservable(ViewModelProperty).Subscribe(value => - { - if (value == null) - { - DataContext = AvaloniaProperty.UnsetValue; - } - else - { - DataContext = value; - } - }); + this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); + this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } /// @@ -68,5 +46,29 @@ namespace Avalonia.ReactiveUI get => ViewModel; set => ViewModel = (TViewModel)value; } + + private void OnDataContextChanged(object value) + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + } + + private void OnViewModelChanged(object value) + { + if (value == null) + { + ClearValue(DataContextProperty); + } + else if (DataContext != value) + { + DataContext = value; + } + } } } diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index fcef0a019f..758a807bfc 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -28,30 +28,8 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - - this.GetObservable(DataContextProperty).Subscribe(value => - { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } - }); - - this.GetObservable(ViewModelProperty).Subscribe(value => - { - if (value == null) - { - DataContext = AvaloniaProperty.UnsetValue; - } - else - { - DataContext = value; - } - }); + this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); + this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } /// @@ -68,5 +46,29 @@ namespace Avalonia.ReactiveUI get => ViewModel; set => ViewModel = (TViewModel)value; } + + private void OnDataContextChanged(object value) + { + if (value is TViewModel viewModel) + { + ViewModel = viewModel; + } + else + { + ViewModel = null; + } + } + + private void OnViewModelChanged(object value) + { + if (value == null) + { + ClearValue(DataContextProperty); + } + else if (DataContext != value) + { + DataContext = value; + } + } } } From 9e0b33b542b2c33bdb3526bef5c7f988d43a6e07 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 20:40:52 +0000 Subject: [PATCH 039/314] add an example of datavalidation errors on textbox. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 8b07ac3f85..4958174f40 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -1,6 +1,7 @@ + x:Class="ControlCatalog.Pages.TextBoxPage" + xmlns:sys="clr-namespace:System;assembly=netstandard"> @@ -11,12 +12,18 @@ Spacing="16"> - + + + + + + + Date: Wed, 28 Oct 2020 20:41:14 +0000 Subject: [PATCH 040/314] position datavalidation errors underneath textbox. --- src/Avalonia.Themes.Fluent/TextBox.xaml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/TextBox.xaml b/src/Avalonia.Themes.Fluent/TextBox.xaml index 162835ae10..2303c438fc 100644 --- a/src/Avalonia.Themes.Fluent/TextBox.xaml +++ b/src/Avalonia.Themes.Fluent/TextBox.xaml @@ -37,15 +37,8 @@ - - - - + + - - - + - From cc712b6e0f8e3eab9e275f036a838fdf6dab6715 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 20:49:30 +0000 Subject: [PATCH 041/314] wrap control in datavalidation errors so it can be applied consistently. --- src/Avalonia.Themes.Fluent/DataValidationErrors.xaml | 2 +- src/Avalonia.Themes.Fluent/TextBox.xaml | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml b/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml index 1161a92e30..ed31f7b573 100644 --- a/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml +++ b/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml @@ -14,7 +14,7 @@ - - - - + - + From 76d3d013e34e0a1d9cd91daf0a319910f77f60c5 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 21:36:35 +0000 Subject: [PATCH 042/314] add datavalidations to button spinner. --- .../Pages/ButtonSpinnerPage.xaml | 11 ++- src/Avalonia.Themes.Fluent/ButtonSpinner.xaml | 99 ++++++++++--------- 2 files changed, 61 insertions(+), 49 deletions(-) diff --git a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml index c3f9f65dd9..4ac2330403 100644 --- a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml +++ b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml @@ -1,6 +1,7 @@  + x:Class="ControlCatalog.Pages.ButtonSpinnerPage" + xmlns:sys="clr-namespace:System;assembly=netstandard"> ButtonSpinner @@ -19,6 +20,14 @@ ShowButtonSpinner="{Binding #showSpinCheck.IsChecked}"> + + + + + + diff --git a/src/Avalonia.Themes.Fluent/ButtonSpinner.xaml b/src/Avalonia.Themes.Fluent/ButtonSpinner.xaml index 82265ea282..12b4845522 100644 --- a/src/Avalonia.Themes.Fluent/ButtonSpinner.xaml +++ b/src/Avalonia.Themes.Fluent/ButtonSpinner.xaml @@ -65,56 +65,59 @@ - - - + + + + - - - - + + + + - - - - - - + + + + + + + From 62ca81e9fbfbba9a3436553d4a4d8bb4f108b98b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 21:49:41 +0000 Subject: [PATCH 043/314] add datavalidation errors to combobox. --- .../ControlCatalog/Pages/ComboBoxPage.xaml | 13 +- src/Avalonia.Controls/Primitives/Popup.cs | 1 + src/Avalonia.Themes.Fluent/ComboBox.xaml | 201 +++++++++--------- 3 files changed, 117 insertions(+), 98 deletions(-) diff --git a/samples/ControlCatalog/Pages/ComboBoxPage.xaml b/samples/ControlCatalog/Pages/ComboBoxPage.xaml index 369f703718..025b85492c 100644 --- a/samples/ControlCatalog/Pages/ComboBoxPage.xaml +++ b/samples/ControlCatalog/Pages/ComboBoxPage.xaml @@ -1,6 +1,7 @@ + x:Class="ControlCatalog.Pages.ComboBoxPage" + xmlns:sys="clr-namespace:System;assembly=netstandard"> ComboBox A drop-down list. @@ -35,6 +36,16 @@ + + + Inline Items + Inline Item 2 + Inline Item 3 + Inline Item 4 + + + + diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index becb489557..b445de0472 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -265,6 +265,7 @@ namespace Avalonia.Controls.Primitives /// /// Gets or sets the control that is used to determine the popup's position. /// + [ResolveByName] public Control? PlacementTarget { get { return GetValue(PlacementTargetProperty); } diff --git a/src/Avalonia.Themes.Fluent/ComboBox.xaml b/src/Avalonia.Themes.Fluent/ComboBox.xaml index 8155264f18..2eee656dc6 100644 --- a/src/Avalonia.Themes.Fluent/ComboBox.xaml +++ b/src/Avalonia.Themes.Fluent/ComboBox.xaml @@ -44,105 +44,107 @@ - - + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - + Grid.Column="1" + IsHitTestVisible="False" + Margin="0,0,10,0" + Height="12" + Width="12" + HorizontalAlignment="Right" + VerticalAlignment="Center"> + + + + + + + + + + + + + + @@ -232,4 +234,9 @@ + + + From 18ac4010070cfb1e77502fb34840da45bce67958 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 21:56:12 +0000 Subject: [PATCH 044/314] add example of datavalidation on autocomplete box. --- samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml index a49616e543..1a53217842 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml @@ -1,5 +1,6 @@ AutoCompleteBox @@ -56,6 +57,16 @@ Width="200" Margin="0,0,0,8" FilterMode="None"/> + + + + + + + From a0ce794c41a15aa336e36d96af45361b9ebc27dc Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 28 Oct 2020 22:02:49 +0000 Subject: [PATCH 045/314] make numeric up down work with validation errors. --- samples/ControlCatalog/Pages/NumericUpDownPage.xaml | 10 ++++++++++ src/Avalonia.Themes.Fluent/NumericUpDown.xaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index 0d7e5da17f..d75622f1fb 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -1,5 +1,6 @@  Numeric up-down control @@ -75,6 +76,15 @@ + + NumericUpDown with Validation Errors: + + + + + diff --git a/src/Avalonia.Themes.Fluent/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/NumericUpDown.xaml index cc5e2234f8..1da48ebd8a 100644 --- a/src/Avalonia.Themes.Fluent/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/NumericUpDown.xaml @@ -39,6 +39,7 @@ VerticalContentAlignment="Stretch" AllowSpin="{TemplateBinding AllowSpin}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" + DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"> Date: Wed, 28 Oct 2020 22:22:43 +0000 Subject: [PATCH 046/314] add datavalidation to date and time pickers. --- .../Pages/DateTimePickerPage.xaml | 20 +++ src/Avalonia.Themes.Fluent/DatePicker.xaml | 143 +++++++-------- src/Avalonia.Themes.Fluent/TimePicker.xaml | 164 +++++++++--------- 3 files changed, 180 insertions(+), 147 deletions(-) diff --git a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml index af6b6e8605..45056a9a76 100644 --- a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml +++ b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:sys="clr-namespace:System;assembly=netstandard" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ControlCatalog.Pages.DateTimePickerPage"> @@ -30,6 +31,16 @@ + + + + + + + + + A DatePicker with day formatted and year hidden. + + + + + + + + A TimePicker with a header and minute increments specified. diff --git a/src/Avalonia.Themes.Fluent/DatePicker.xaml b/src/Avalonia.Themes.Fluent/DatePicker.xaml index 6fbfa1bbf7..b6e36861e0 100644 --- a/src/Avalonia.Themes.Fluent/DatePicker.xaml +++ b/src/Avalonia.Themes.Fluent/DatePicker.xaml @@ -125,77 +125,79 @@ - - + + + - + - - - + + + - + + @@ -228,6 +230,11 @@ + + + @@ -161,6 +163,10 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -102,56 +104,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -260,4 +264,8 @@ + + From 233fdc9289cb6125f18c8566e157c711224eb576 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 11:30:18 +0000 Subject: [PATCH 048/314] make slider track red when there is an error. --- src/Avalonia.Themes.Fluent/Slider.xaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml index 8abba461e7..d70eb1abe3 100644 --- a/src/Avalonia.Themes.Fluent/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Slider.xaml @@ -268,4 +268,8 @@ + + From d3b43efe161c3ff12cd8939cff6a821bbc8f94aa Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 11:33:41 +0000 Subject: [PATCH 049/314] if TreeView has a selecteditem that isnt really part of the tree... then do not crash tab navigation. --- src/Avalonia.Controls/TreeView.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index b2bd5ab2e5..f020280496 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -378,10 +378,11 @@ namespace Avalonia.Controls { if (!this.IsVisualAncestorOf(element)) { - IControl result = _selectedItem != null ? + var result = _selectedItem != null ? ItemContainerGenerator.Index.ContainerFromItem(_selectedItem) : ItemContainerGenerator.ContainerFromIndex(0); - return (true, result); + + return (result is {}, result); // SelectedItem may not be in the treeview. } return (true, null); From 27c58c45e15847239b197a89d8407aaa56d390b1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 11:36:08 +0000 Subject: [PATCH 050/314] treeview navigation never return handled... if returning null. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index f020280496..7bd82322d1 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -385,7 +385,7 @@ namespace Avalonia.Controls return (result is {}, result); // SelectedItem may not be in the treeview. } - return (true, null); + return (false, null); } return (false, null); From 3db5e1bc5abacd72e78da9d8f899b2749b7e383a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 12:13:41 +0000 Subject: [PATCH 051/314] Revert "treeview navigation never return handled... if returning null." This reverts commit 27c58c45e15847239b197a89d8407aaa56d390b1. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 7bd82322d1..f020280496 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -385,7 +385,7 @@ namespace Avalonia.Controls return (result is {}, result); // SelectedItem may not be in the treeview. } - return (false, null); + return (true, null); } return (false, null); From f8d5ae59cccb58f95f00e1c032627066f653f141 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 15:22:46 +0300 Subject: [PATCH 052/314] Fix microcom target? --- build/CoreLibraries.props | 1 + packages/Avalonia/Avalonia.csproj | 2 -- src/Avalonia.Native/Avalonia.Native.csproj | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build/CoreLibraries.props b/build/CoreLibraries.props index d17eec0135..fff00041c3 100644 --- a/build/CoreLibraries.props +++ b/build/CoreLibraries.props @@ -15,6 +15,7 @@ + diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj index 90c1c67956..75ee4a05cb 100644 --- a/packages/Avalonia/Avalonia.csproj +++ b/packages/Avalonia/Avalonia.csproj @@ -7,8 +7,6 @@ - - diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index a3e99595c2..ecd245966e 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -34,7 +34,11 @@ - + From 334f5f0a8645f9ef4fe0ed2ef573576a2d4377e4 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 15:22:54 +0300 Subject: [PATCH 053/314] Fix microcom registration --- src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index b4a0770e73..10c44bea21 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -437,7 +437,7 @@ namespace MicroComGenerator .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) .WithBody(Block( ParseStatement("Avalonia.MicroCom.MicroComRuntime.Register(typeof(" + - proxyClassName + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + + iface.Name + "), new Guid(\"" + guidString + "\"), (p, owns) => new " + proxyClassName + "(p, owns));") ))) .AddMembers(ParseMemberDeclaration("public " + proxyClassName + From d3c44a89c0e5c15ac5ef0e3066fabe8b1fde80ba Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 13:13:15 +0000 Subject: [PATCH 054/314] revert fix and add failing unit test. --- src/Avalonia.Controls/TreeView.cs | 2 +- .../TreeViewTests.cs | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index f020280496..558bcddfbe 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -382,7 +382,7 @@ namespace Avalonia.Controls ItemContainerGenerator.Index.ContainerFromItem(_selectedItem) : ItemContainerGenerator.ContainerFromIndex(0); - return (result is {}, result); // SelectedItem may not be in the treeview. + return (true, result); // SelectedItem may not be in the treeview. } return (true, null); diff --git a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs index b805683393..cea77bb7c9 100644 --- a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs @@ -675,6 +675,50 @@ namespace Avalonia.Controls.UnitTests Assert.Same(node, focus.Current); } } + + [Fact] + public void Keyboard_Navigation_Should_Not_Crash_If_Selected_Item_Is_not_In_Tree() + { + using (Application()) + { + var focus = FocusManager.Instance; + var navigation = AvaloniaLocator.Current.GetService(); + var data = CreateTestTreeData(); + + var selectedNode = new Node { Value = "Out of Tree Selected Item" }; + + var target = new TreeView + { + Template = CreateTreeViewTemplate(), + Items = data, + SelectedItem = selectedNode + }; + + var button = new Button(); + + var root = new TestRoot + { + Child = new StackPanel + { + Children = { target, button }, + } + }; + + CreateNodeDataTemplate(target); + ApplyTemplates(target); + ExpandAll(target); + + var item = data[0].Children[0]; + var node = target.ItemContainerGenerator.Index.ContainerFromItem(item); + Assert.NotNull(node); + + target.SelectedItem = selectedNode; + node.Focus(); + Assert.Same(node, focus.Current); + + var next = KeyboardNavigationHandler.GetNext(node, NavigationDirection.Previous); + } + } [Fact] public void Pressing_SelectAll_Gesture_Should_Select_All_Nodes() From 22605e52e9d15e9127f308d8e60a70abe38a4770 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 13:14:00 +0000 Subject: [PATCH 055/314] add fix for treeview navigation when SelectedItem is not in the tree. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 558bcddfbe..f020280496 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -382,7 +382,7 @@ namespace Avalonia.Controls ItemContainerGenerator.Index.ContainerFromItem(_selectedItem) : ItemContainerGenerator.ContainerFromIndex(0); - return (true, result); // SelectedItem may not be in the treeview. + return (result is {}, result); // SelectedItem may not be in the treeview. } return (true, null); From 8de6823e5ddd6a189bc3a8dff94573a6cceb1c0a Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 16:52:47 +0300 Subject: [PATCH 056/314] IT'S ALIVE --- packages/Avalonia/AvaloniaBuildTasks.targets | 2 + .../CompileAvaloniaXamlTask.cs | 3 +- .../XamlCompilerTaskExecutor.cs | 57 +++++++++++++------ .../Avalonia.MicroCom.csproj | 14 +++-- src/Avalonia.MicroCom/MicroComRuntime.cs | 3 + src/Avalonia.MicroCom/MicroComVtblBase.cs | 1 + src/Avalonia.Native/Avalonia.Native.csproj | 8 ++- .../CSharpGen.InterfaceGen.cs | 13 ++++- 8 files changed, 71 insertions(+), 30 deletions(-) diff --git a/packages/Avalonia/AvaloniaBuildTasks.targets b/packages/Avalonia/AvaloniaBuildTasks.targets index 57b4cb04e3..45a7f1aa44 100644 --- a/packages/Avalonia/AvaloniaBuildTasks.targets +++ b/packages/Avalonia/AvaloniaBuildTasks.targets @@ -4,6 +4,7 @@ <_AvaloniaUseExternalMSBuild Condition="'$(_AvaloniaForceInternalMSBuild)' == 'true'">false low <_AvaloniaPatchComInterop Condition="'$(_AvaloniaPatchComInterop)' == ''">false + <_AvaloniaSkipXamlCompilation Condition="'$(_AvaloniaSkipXamlCompilation)' == ''">false @@ -92,6 +93,7 @@ SignAssembly="$(SignAssembly)" DelaySign="$(DelaySign)" EnableComInteropPatching="$(_AvaloniaPatchComInterop)" + SkipXamlCompilation="$(_AvaloniaSkipXamlCompilation)" /> !string.IsNullOrWhiteSpace(l)).ToArray(), ProjectDirectory, OutputPath, VerifyIl, outputImportance, (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null, - EnableComInteropPatching); + EnableComInteropPatching, SkipXamlCompilation); if (!res.Success) return false; if (!res.WrittenFile) @@ -77,6 +77,7 @@ namespace Avalonia.Build.Tasks public bool VerifyIl { get; set; } public bool EnableComInteropPatching { get; set; } + public bool SkipXamlCompilation { get; set; } public string AssemblyOriginatorKeyFile { get; set; } public bool SignAssembly { get; set; } diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 938732cfe1..0b9b50e771 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -40,17 +40,48 @@ namespace Avalonia.Build.Tasks WrittenFile = writtenFile; } } + + public static CompileResult Compile(IBuildEngine engine, string input, string[] references, + string projectDirectory, + string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom, + bool skipXamlCompilation) + { + var typeSystem = new CecilTypeSystem(references.Concat(new[] { input }), input); + + var asm = typeSystem.TargetAssemblyDefinition; + + if (!skipXamlCompilation) + { + var compileRes = CompileCore(engine, typeSystem, projectDirectory, verifyIl, logImportance); + if (compileRes == null && !patchCom) + return new CompileResult(true); + if (compileRes == false) + return new CompileResult(false); + } + + if (patchCom) + ComInteropHelper.PatchAssembly(asm, typeSystem); + + var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; + if (!string.IsNullOrWhiteSpace(strongNameKey)) + writerParameters.StrongNameKeyBlob = File.ReadAllBytes(strongNameKey); + + asm.Write(output, writerParameters); + + return new CompileResult(true, true); + + } - public static CompileResult Compile(IBuildEngine engine, string input, string[] references, string projectDirectory, - string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom) + static bool? CompileCore(IBuildEngine engine, CecilTypeSystem typeSystem, + string projectDirectory, bool verifyIl, + MessageImportance logImportance) { - var typeSystem = new CecilTypeSystem(references.Concat(new[] {input}), input); var asm = typeSystem.TargetAssemblyDefinition; var emres = new EmbeddedResources(asm); var avares = new AvaloniaResources(asm, projectDirectory); - if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0 && !patchCom) + if (avares.Resources.Count(CheckXamlName) == 0 && emres.Resources.Count(CheckXamlName) == 0) // Nothing to do - return new CompileResult(true); + return null; var clrPropertiesDef = new TypeDefinition("CompiledAvaloniaXaml", "XamlIlHelpers", TypeAttributes.Class, asm.MainModule.TypeSystem.Object); @@ -364,27 +395,17 @@ namespace Avalonia.Build.Tasks if (emres.Resources.Count(CheckXamlName) != 0) if (!CompileGroup(emres)) - return new CompileResult(false); + return false; if (avares.Resources.Count(CheckXamlName) != 0) { if (!CompileGroup(avares)) - return new CompileResult(false); + return false; avares.Save(); } loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldnull)); loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); - - if (patchCom) - ComInteropHelper.PatchAssembly(asm, typeSystem); - - var writerParameters = new WriterParameters { WriteSymbols = asm.MainModule.HasSymbols }; - if (!string.IsNullOrWhiteSpace(strongNameKey)) - writerParameters.StrongNameKeyBlob = File.ReadAllBytes(strongNameKey); - - asm.Write(output, writerParameters); - - return new CompileResult(true, true); + return true; } } diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj index aaf54ed80e..7994a74f76 100644 --- a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -1,8 +1,10 @@ - - - netstandard2.0 - true - - + + netstandard2.0 + true + + + <_AvaloniaPatchComInterop>true + + diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs index d43568631a..9d2c23f40a 100644 --- a/src/Avalonia.MicroCom/MicroComRuntime.cs +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -41,6 +41,8 @@ namespace Avalonia.MicroCom public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown { + if (obj == null) + return null; if (obj is MicroComProxyBase proxy) return (void*)proxy.NativePointer; if (obj is IMicroComShadowContainer container) @@ -55,6 +57,7 @@ namespace Avalonia.MicroCom res); if (owned) container.Shadow.AddRef((Ccw*)ptr); + return ptr; } throw new ArgumentException("Unable to get a native pointer for " + obj); } diff --git a/src/Avalonia.MicroCom/MicroComVtblBase.cs b/src/Avalonia.MicroCom/MicroComVtblBase.cs index 4cd419cdaf..e06e2d4934 100644 --- a/src/Avalonia.MicroCom/MicroComVtblBase.cs +++ b/src/Avalonia.MicroCom/MicroComVtblBase.cs @@ -18,6 +18,7 @@ namespace Avalonia.MicroCom { AddMethod((QueryInterfaceDelegate)QueryInterface); AddMethod((AddRefDelegate)AddRef); + AddMethod((AddRefDelegate)Release); } protected void AddMethod(Delegate d) diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index ecd245966e..f0c747504b 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -37,7 +37,7 @@ @@ -47,8 +47,12 @@ + + + + <_AvaloniaPatchComInterop>true - \ No newline at end of file + diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index 10c44bea21..91ece81bd0 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -135,7 +135,7 @@ namespace MicroComGenerator public override void PreMarshal(List body) { body.Add(ParseStatement($"var {BName} = new byte[System.Text.Encoding.UTF8.GetByteCount({Name})+1];")); - body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name.Length}, {BName}, 0);")); + body.Add(ParseStatement($"System.Text.Encoding.UTF8.GetBytes({Name}, 0, {Name}.Length, {BName}, 0);")); } public override StatementSyntax CreateFixed(StatementSyntax inner) @@ -238,8 +238,11 @@ namespace MicroComGenerator .AddArgumentListArguments(Argument(ParseExpression("PPV"))) .AddArgumentListArguments(args .Select((a, i) => Argument(a.Value(isHresultLastArgumentReturn && i == args.Count - 1))).ToArray()) - .AddArgumentListArguments(Argument(ParseExpression("PPV[base.VTableSize + " + num + "]"))); + .AddArgumentListArguments(Argument(ParseExpression("(*PPV)[base.VTableSize + " + num + "]"))); + if (!isVoidReturn) + callExpr = CastExpression(ParseTypeName(returnArg.NativeType), callExpr); + // Save call result if needed if (!isVoidReturn) callExpr = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, ParseExpression("__result"), @@ -369,6 +372,10 @@ namespace MicroComGenerator public ExpressionSyntax GetCaller(string returnType, List args) { + string ConvertType(string t) => t.EndsWith("*") ? "void*" : t; + returnType = ConvertType(returnType); + args = args.Select(ConvertType).ToList(); + var name = "CalliStdCall" + returnType.Replace("*", "_ptr"); var signature = returnType + "::" + name + "::" + string.Join("::", args); if (_existing.Add(signature)) @@ -427,7 +434,7 @@ namespace MicroComGenerator .AddModifiers(Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.InternalKeyword)) .WithExpressionBody(ArrowExpressionClause( ParseExpression("Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(" + - proxyClassName + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) + iface.Name + "), new " + vtbl.Identifier.Text + "().CreateVTable())"))) .WithSemicolonToken(Semicolon())); From 7460c429feef2a2b9e5cc15701c6515c084b3764 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 16:55:05 +0300 Subject: [PATCH 057/314] Calling Dispose multiple times should be valid --- src/Avalonia.MicroCom/MicroComProxyBase.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs index 6a13fb10c4..681e278104 100644 --- a/src/Avalonia.MicroCom/MicroComProxyBase.cs +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -65,8 +65,13 @@ namespace Avalonia.MicroCom protected virtual void Dispose(bool disposing) { + if(_nativePointer == null) + return; if (_ownsHandle) + { Release(); + _ownsHandle = false; + } _nativePointer = IntPtr.Zero; GC.SuppressFinalize(this); } From addcc6674d5a341f5a821a00f1deacdf9c7fa6f3 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 17:40:44 +0300 Subject: [PATCH 058/314] Generate avalonia-native.h from avn.idl --- azure-pipelines.yml | 6 + native/Avalonia.Native/inc/.gitignore | 1 + native/Avalonia.Native/inc/avalonia-native.h | 516 ------------------- native/Avalonia.Native/src/OSX/clipboard.mm | 2 +- native/Avalonia.Native/src/OSX/main.mm | 4 +- native/Avalonia.Native/src/OSX/menu.h | 6 +- native/Avalonia.Native/src/OSX/menu.mm | 6 +- native/Avalonia.Native/src/OSX/window.mm | 2 +- nukebuild/MicroComGen.cs | 14 + nukebuild/_build.csproj | 4 + src/Avalonia.Native/avn.idl | 6 +- src/tools/MicroComGenerator/Ast.cs | 10 +- src/tools/MicroComGenerator/AstParser.cs | 2 + src/tools/MicroComGenerator/CSharpGen.cs | 11 + src/tools/MicroComGenerator/CppGen.cs | 43 +- 15 files changed, 86 insertions(+), 547 deletions(-) create mode 100644 native/Avalonia.Native/inc/.gitignore delete mode 100644 native/Avalonia.Native/inc/avalonia-native.h create mode 100644 nukebuild/MicroComGen.cs diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e67fa14c57..5d6c561bc6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -48,6 +48,12 @@ jobs: curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg sudo installer -verbose -pkg ./mono.pkg -target / + - task: CmdLine@2 + displayName: 'Generate avalonia-native' + inputs: + script: | + cd src/tools/MicroComGenerator; dotnet run -i ../../Avalonia.Native/avn.idl --cpp ../../../native/Avalonia.Native/inc/avalonia-native.h + - task: Xcode@5 inputs: actions: 'build' diff --git a/native/Avalonia.Native/inc/.gitignore b/native/Avalonia.Native/inc/.gitignore new file mode 100644 index 0000000000..e7aa7fc6a5 --- /dev/null +++ b/native/Avalonia.Native/inc/.gitignore @@ -0,0 +1 @@ +avalonia-native.h diff --git a/native/Avalonia.Native/inc/avalonia-native.h b/native/Avalonia.Native/inc/avalonia-native.h deleted file mode 100644 index 9ff6130e5f..0000000000 --- a/native/Avalonia.Native/inc/avalonia-native.h +++ /dev/null @@ -1,516 +0,0 @@ -#include "com.h" -#include "key.h" -#include "stddef.h" - -#define AVNCOM(name, id) COMINTERFACE(name, 2e2cda0a, 9ae5, 4f1b, 8e, 20, 08, 1a, 04, 27, 9f, id) - -struct IAvnWindowEvents; -struct IAvnWindow; -struct IAvnPopup; -struct IAvnMacOptions; -struct IAvnPlatformThreadingInterface; -struct IAvnSystemDialogEvents; -struct IAvnSystemDialogs; -struct IAvnScreens; -struct IAvnClipboard; -struct IAvnCursor; -struct IAvnCursorFactory; -struct IAvnGlFeature; -struct IAvnGlContext; -struct IAvnGlDisplay; -struct IAvnGlSurfaceRenderTarget; -struct IAvnGlSurfaceRenderingSession; -struct IAvnMenu; -struct IAvnMenuItem; -struct IAvnStringArray; -struct IAvnDndResultCallback; -struct IAvnGCHandleDeallocatorCallback; -struct IAvnMenuEvents; -struct IAvnNativeControlHost; -struct IAvnNativeControlHostTopLevelAttachment; -enum SystemDecorations { - SystemDecorationsNone = 0, - SystemDecorationsBorderOnly = 1, - SystemDecorationsFull = 2, -}; - -struct AvnSize -{ - double Width, Height; -}; - -struct AvnPixelSize -{ - int Width, Height; -}; - -struct AvnRect -{ - double X, Y, Width, Height; -}; - -struct AvnVector -{ - double X, Y; -}; - -struct AvnPoint -{ - double X, Y; -}; - -struct AvnScreen -{ - AvnRect Bounds; - AvnRect WorkingArea; - float PixelDensity; - bool Primary; -}; - -enum AvnPixelFormat -{ - kAvnRgb565, - kAvnRgba8888, - kAvnBgra8888 -}; - -struct AvnFramebuffer -{ - void* Data; - int Width; - int Height; - int Stride; - AvnVector Dpi; - AvnPixelFormat PixelFormat; -}; - -struct AvnColor -{ - unsigned char Alpha; - unsigned char Red; - unsigned char Green; - unsigned char Blue; -}; - -enum AvnRawMouseEventType -{ - LeaveWindow, - LeftButtonDown, - LeftButtonUp, - RightButtonDown, - RightButtonUp, - MiddleButtonDown, - MiddleButtonUp, - XButton1Down, - XButton1Up, - XButton2Down, - XButton2Up, - Move, - Wheel, - NonClientLeftButtonDown, - TouchBegin, - TouchUpdate, - TouchEnd, - TouchCancel -}; - -enum AvnRawKeyEventType -{ - KeyDown, - KeyUp -}; - -enum AvnInputModifiers -{ - AvnInputModifiersNone = 0, - Alt = 1, - Control = 2, - Shift = 4, - Windows = 8, - LeftMouseButton = 16, - RightMouseButton = 32, - MiddleMouseButton = 64, - XButton1MouseButton = 128, - XButton2MouseButton = 256 -}; - -enum class AvnDragDropEffects -{ - None = 0, - Copy = 1, - Move = 2, - Link = 4, -}; - -enum class AvnDragEventType -{ - Enter, - Over, - Leave, - Drop -}; - -enum AvnWindowState -{ - Normal, - Minimized, - Maximized, - FullScreen, -}; - -enum AvnStandardCursorType -{ - CursorArrow, - CursorIbeam, - CursorWait, - CursorCross, - CursorUpArrow, - CursorSizeWestEast, - CursorSizeNorthSouth, - CursorSizeAll, - CursorNo, - CursorHand, - CursorAppStarting, - CursorHelp, - CursorTopSide, - CursorBottomSize, - CursorLeftSide, - CursorRightSide, - CursorTopLeftCorner, - CursorTopRightCorner, - CursorBottomLeftCorner, - CursorBottomRightCorner, - CursorDragMove, - CursorDragCopy, - CursorDragLink, - CursorNone -}; - -enum AvnWindowEdge -{ - WindowEdgeNorthWest, - WindowEdgeNorth, - WindowEdgeNorthEast, - WindowEdgeWest, - WindowEdgeEast, - WindowEdgeSouthWest, - WindowEdgeSouth, - WindowEdgeSouthEast -}; - -enum AvnMenuItemToggleType -{ - None, - CheckMark, - Radio -}; - -enum AvnExtendClientAreaChromeHints -{ - AvnNoChrome = 0, - AvnSystemChrome = 0x01, - AvnPreferSystemChrome = 0x02, - AvnOSXThickTitleBar = 0x08, - AvnDefaultChrome = AvnSystemChrome, -}; - -AVNCOM(IAvaloniaNativeFactory, 01) : IUnknown -{ -public: - virtual HRESULT Initialize(IAvnGCHandleDeallocatorCallback* deallocator) = 0; - virtual IAvnMacOptions* GetMacOptions() = 0; - virtual HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnWindow** ppv) = 0; - virtual HRESULT CreatePopup (IAvnWindowEvents* cb, IAvnGlContext* gl, IAvnPopup** ppv) = 0; - virtual HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv) = 0; - virtual HRESULT CreateSystemDialogs (IAvnSystemDialogs** ppv) = 0; - virtual HRESULT CreateScreens (IAvnScreens** ppv) = 0; - virtual HRESULT CreateClipboard(IAvnClipboard** ppv) = 0; - virtual HRESULT CreateDndClipboard(IAvnClipboard** ppv) = 0; - virtual HRESULT CreateCursorFactory(IAvnCursorFactory** ppv) = 0; - virtual HRESULT ObtainGlDisplay(IAvnGlDisplay** ppv) = 0; - virtual HRESULT SetAppMenu(IAvnMenu* menu) = 0; - virtual HRESULT CreateMenu (IAvnMenuEvents* cb, IAvnMenu** ppv) = 0; - virtual HRESULT CreateMenuItem (IAvnMenuItem** ppv) = 0; - virtual HRESULT CreateMenuItemSeperator (IAvnMenuItem** ppv) = 0; -}; - -AVNCOM(IAvnString, 17) : IUnknown -{ - virtual HRESULT Pointer(void**retOut) = 0; - virtual HRESULT Length(int*ret) = 0; -}; - -AVNCOM(IAvnWindowBase, 02) : IUnknown -{ - virtual HRESULT Show() = 0; - virtual HRESULT Hide () = 0; - virtual HRESULT Close() = 0; - virtual HRESULT Activate () = 0; - virtual HRESULT GetClientSize(AvnSize*ret) = 0; - virtual HRESULT GetScaling(double*ret)=0; - virtual HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize) = 0; - virtual HRESULT Resize(double width, double height) = 0; - virtual HRESULT Invalidate (AvnRect rect) = 0; - virtual HRESULT BeginMoveDrag () = 0; - virtual HRESULT BeginResizeDrag (AvnWindowEdge edge) = 0; - virtual HRESULT GetPosition (AvnPoint*ret) = 0; - virtual HRESULT SetPosition (AvnPoint point) = 0; - virtual HRESULT PointToClient (AvnPoint point, AvnPoint*ret) = 0; - virtual HRESULT PointToScreen (AvnPoint point, AvnPoint*ret) = 0; - virtual HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose) = 0; - virtual HRESULT SetTopMost (bool value) = 0; - virtual HRESULT SetCursor(IAvnCursor* cursor) = 0; - virtual HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret) = 0; - virtual HRESULT SetMainMenu(IAvnMenu* menu) = 0; - virtual HRESULT ObtainNSWindowHandle(void** retOut) = 0; - virtual HRESULT ObtainNSWindowHandleRetained(void** retOut) = 0; - virtual HRESULT ObtainNSViewHandle(void** retOut) = 0; - virtual HRESULT ObtainNSViewHandleRetained(void** retOut) = 0; - virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut) = 0; - virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, - IAvnClipboard* clipboard, IAvnDndResultCallback* cb, void* sourceHandle) = 0; - virtual HRESULT SetBlurEnabled (bool enable) = 0; -}; - -AVNCOM(IAvnPopup, 03) : virtual IAvnWindowBase -{ - -}; - -AVNCOM(IAvnWindow, 04) : virtual IAvnWindowBase -{ - virtual HRESULT SetEnabled (bool enable) = 0; - virtual HRESULT SetParent (IAvnWindow* parent) = 0; - virtual HRESULT SetCanResize(bool value) = 0; - virtual HRESULT SetDecorations(SystemDecorations value) = 0; - virtual HRESULT SetTitle (void* utf8Title) = 0; - virtual HRESULT SetTitleBarColor (AvnColor color) = 0; - virtual HRESULT SetWindowState(AvnWindowState state) = 0; - virtual HRESULT GetWindowState(AvnWindowState*ret) = 0; - virtual HRESULT TakeFocusFromChildren() = 0; - virtual HRESULT SetExtendClientArea (bool enable) = 0; - virtual HRESULT SetExtendClientAreaHints (AvnExtendClientAreaChromeHints hints) = 0; - virtual HRESULT GetExtendTitleBarHeight (double*ret) = 0; - virtual HRESULT SetExtendTitleBarHeight (double value) = 0; -}; - -AVNCOM(IAvnWindowBaseEvents, 05) : IUnknown -{ - virtual HRESULT Paint() = 0; - virtual void Closed() = 0; - virtual void Activated() = 0; - virtual void Deactivated() = 0; - virtual void Resized(const AvnSize& size) = 0; - virtual void PositionChanged (AvnPoint position) = 0; - virtual void RawMouseEvent (AvnRawMouseEventType type, - unsigned int timeStamp, - AvnInputModifiers modifiers, - AvnPoint point, - AvnVector delta) = 0; - virtual bool RawKeyEvent (AvnRawKeyEventType type, unsigned int timeStamp, AvnInputModifiers modifiers, unsigned int key) = 0; - virtual bool RawTextInputEvent (unsigned int timeStamp, const char* text) = 0; - virtual void ScalingChanged(double scaling) = 0; - virtual void RunRenderPriorityJobs() = 0; - virtual void LostFocus() = 0; - virtual AvnDragDropEffects DragEvent(AvnDragEventType type, AvnPoint position, - AvnInputModifiers modifiers, AvnDragDropEffects effects, - IAvnClipboard* clipboard, void* dataObjectHandle) = 0; -}; - - -AVNCOM(IAvnWindowEvents, 06) : IAvnWindowBaseEvents -{ - /** - * Closing Event - * Called when the user presses the OS window close button. - * return true to allow the close, return false to prevent close. - */ - virtual bool Closing () = 0; - - virtual void WindowStateChanged (AvnWindowState state) = 0; - - virtual void GotInputWhenDisabled () = 0; -}; - -AVNCOM(IAvnMacOptions, 07) : IUnknown -{ - virtual HRESULT SetShowInDock(int show) = 0; - virtual HRESULT SetApplicationTitle (void* utf8string) = 0; -}; - -AVNCOM(IAvnActionCallback, 08) : IUnknown -{ - virtual void Run() = 0; -}; - -AVNCOM(IAvnSignaledCallback, 09) : IUnknown -{ - virtual void Signaled(int priority, bool priorityContainsMeaningfulValue) = 0; -}; - -AVNCOM(IAvnLoopCancellation, 0a) : IUnknown -{ - virtual void Cancel() = 0; -}; - -AVNCOM(IAvnPlatformThreadingInterface, 0b) : IUnknown -{ - virtual bool GetCurrentThreadIsLoopThread() = 0; - virtual void SetSignaledCallback(IAvnSignaledCallback* cb) = 0; - virtual IAvnLoopCancellation* CreateLoopCancellation() = 0; - virtual HRESULT RunLoop(IAvnLoopCancellation* cancel) = 0; - // Can't pass int* to sharpgentools for some reason - virtual void Signal(int priority) = 0; - virtual IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback) = 0; -}; - -AVNCOM(IAvnSystemDialogEvents, 0c) : IUnknown -{ - virtual void OnCompleted (int numResults, void* ptrFirstResult) = 0; -}; - -AVNCOM(IAvnSystemDialogs, 0d) : IUnknown -{ - virtual void SelectFolderDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - const char* title, - const char* initialPath) = 0; - - virtual void OpenFileDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - bool allowMultiple, - const char* title, - const char* initialDirectory, - const char* initialFile, - const char* filters) = 0; - - virtual void SaveFileDialog (IAvnWindow* parentWindowHandle, - IAvnSystemDialogEvents* events, - const char* title, - const char* initialDirectory, - const char* initialFile, - const char* filters) = 0; -}; - -AVNCOM(IAvnScreens, 0e) : IUnknown -{ - virtual HRESULT GetScreenCount (int* ret) = 0; - virtual HRESULT GetScreen (int index, AvnScreen* ret) = 0; -}; - -AVNCOM(IAvnClipboard, 0f) : IUnknown -{ - virtual HRESULT GetText (char* type, IAvnString**ppv) = 0; - virtual HRESULT SetText (char* type, void* utf8Text) = 0; - virtual HRESULT ObtainFormats(IAvnStringArray**ppv) = 0; - virtual HRESULT GetStrings(char* type, IAvnStringArray**ppv) = 0; - virtual HRESULT SetBytes(char* type, void* utf8Text, int len) = 0; - virtual HRESULT GetBytes(char* type, IAvnString**ppv) = 0; - - virtual HRESULT Clear() = 0; -}; - -AVNCOM(IAvnCursor, 10) : IUnknown -{ -}; - -AVNCOM(IAvnCursorFactory, 11) : IUnknown -{ - virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) = 0; -}; - -AVNCOM(IAvnGlDisplay, 13) : IUnknown -{ - virtual HRESULT CreateContext(IAvnGlContext* share, IAvnGlContext**ppv) = 0; - virtual void LegacyClearCurrentContext() = 0; - virtual HRESULT WrapContext(void* native, IAvnGlContext**ppv) = 0; - virtual void* GetProcAddress(char* proc) = 0; -}; - -AVNCOM(IAvnGlContext, 14) : IUnknown -{ - virtual HRESULT MakeCurrent(IUnknown** ppv) = 0; - virtual HRESULT LegacyMakeCurrent() = 0; - virtual int GetSampleCount() = 0; - virtual int GetStencilSize() = 0; - virtual void* GetNativeHandle() = 0; -}; - -AVNCOM(IAvnGlSurfaceRenderTarget, 15) : IUnknown -{ - virtual HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret) = 0; -}; - -AVNCOM(IAvnGlSurfaceRenderingSession, 16) : IUnknown -{ - virtual HRESULT GetPixelSize(AvnPixelSize* ret) = 0; - virtual HRESULT GetScaling(double* ret) = 0; -}; - -AVNCOM(IAvnMenu, 17) : IUnknown -{ - virtual HRESULT InsertItem (int index, IAvnMenuItem* item) = 0; - virtual HRESULT RemoveItem (IAvnMenuItem* item) = 0; - virtual HRESULT SetTitle (void* utf8String) = 0; - virtual HRESULT Clear () = 0; -}; - -AVNCOM(IAvnPredicateCallback, 18) : IUnknown -{ - virtual bool Evaluate() = 0; -}; - -AVNCOM(IAvnMenuItem, 19) : IUnknown -{ - virtual HRESULT SetSubMenu (IAvnMenu* menu) = 0; - virtual HRESULT SetTitle (void* utf8String) = 0; - virtual HRESULT SetGesture (void* utf8String, AvnInputModifiers modifiers) = 0; - virtual HRESULT SetAction (IAvnPredicateCallback* predicate, IAvnActionCallback* callback) = 0; - virtual HRESULT SetIsChecked (bool isChecked) = 0; - virtual HRESULT SetToggleType (AvnMenuItemToggleType toggleType) = 0; - virtual HRESULT SetIcon (void* data, size_t length) = 0; -}; - -AVNCOM(IAvnMenuEvents, 1A) : IUnknown -{ - /** - * NeedsUpdate - */ - virtual void NeedsUpdate () = 0; -}; - -AVNCOM(IAvnStringArray, 20) : IUnknown -{ - virtual unsigned int GetCount() = 0; - virtual HRESULT Get(unsigned int index, IAvnString**ppv) = 0; -}; - -AVNCOM(IAvnDndResultCallback, 21) : IUnknown -{ - virtual void OnDragAndDropComplete(AvnDragDropEffects effecct) = 0; -}; - -AVNCOM(IAvnGCHandleDeallocatorCallback, 22) : IUnknown -{ - virtual void FreeGCHandle(void* handle) = 0; -}; - -AVNCOM(IAvnNativeControlHost, 20) : IUnknown -{ - virtual HRESULT CreateDefaultChild(void* parent, void** retOut) = 0; - virtual IAvnNativeControlHostTopLevelAttachment* CreateAttachment() = 0; - virtual void DestroyDefaultChild(void* child) = 0; -}; - -AVNCOM(IAvnNativeControlHostTopLevelAttachment, 21) : IUnknown -{ - virtual void* GetParentHandle() = 0; - virtual HRESULT InitializeWithChildHandle(void* child) = 0; - virtual HRESULT AttachTo(IAvnNativeControlHost* host) = 0; - virtual void ShowInBounds(float x, float y, float width, float height) = 0; - virtual void HideWithSize(float width, float height) = 0; - virtual void ReleaseChild() = 0; -}; - - -extern "C" IAvaloniaNativeFactory* CreateAvaloniaNative(); diff --git a/native/Avalonia.Native/src/OSX/clipboard.mm b/native/Avalonia.Native/src/OSX/clipboard.mm index 116a08670e..303f727317 100644 --- a/native/Avalonia.Native/src/OSX/clipboard.mm +++ b/native/Avalonia.Native/src/OSX/clipboard.mm @@ -67,7 +67,7 @@ public: } } - virtual HRESULT SetText (char* type, void* utf8String) override + virtual HRESULT SetText (char* type, char* utf8String) override { Clear(); @autoreleasepool diff --git a/native/Avalonia.Native/src/OSX/main.mm b/native/Avalonia.Native/src/OSX/main.mm index e6c4a861fd..cd6ef73826 100644 --- a/native/Avalonia.Native/src/OSX/main.mm +++ b/native/Avalonia.Native/src/OSX/main.mm @@ -104,9 +104,9 @@ class MacOptions : public ComSingleObject public: FORWARD_IUNKNOWN() - virtual HRESULT SetApplicationTitle(void* utf8String) override + virtual HRESULT SetApplicationTitle(char* utf8String) override { - auto appTitle = [NSString stringWithUTF8String:(const char*)utf8String]; + auto appTitle = [NSString stringWithUTF8String: utf8String]; [[NSProcessInfo processInfo] setProcessName:appTitle]; diff --git a/native/Avalonia.Native/src/OSX/menu.h b/native/Avalonia.Native/src/OSX/menu.h index bfbc6801f8..0e43b22846 100644 --- a/native/Avalonia.Native/src/OSX/menu.h +++ b/native/Avalonia.Native/src/OSX/menu.h @@ -43,9 +43,9 @@ public: virtual HRESULT SetSubMenu (IAvnMenu* menu) override; - virtual HRESULT SetTitle (void* utf8String) override; + virtual HRESULT SetTitle (char* utf8String) override; - virtual HRESULT SetGesture (void* key, AvnInputModifiers modifiers) override; + virtual HRESULT SetGesture (char* key, AvnInputModifiers modifiers) override; virtual HRESULT SetAction (IAvnPredicateCallback* predicate, IAvnActionCallback* callback) override; @@ -80,7 +80,7 @@ public: virtual HRESULT RemoveItem (IAvnMenuItem* item) override; - virtual HRESULT SetTitle (void* utf8String) override; + virtual HRESULT SetTitle (char* utf8String) override; virtual HRESULT Clear () override; }; diff --git a/native/Avalonia.Native/src/OSX/menu.mm b/native/Avalonia.Native/src/OSX/menu.mm index dc1245cd23..1356388b85 100644 --- a/native/Avalonia.Native/src/OSX/menu.mm +++ b/native/Avalonia.Native/src/OSX/menu.mm @@ -109,7 +109,7 @@ HRESULT AvnAppMenuItem::SetSubMenu (IAvnMenu* menu) } } -HRESULT AvnAppMenuItem::SetTitle (void* utf8String) +HRESULT AvnAppMenuItem::SetTitle (char* utf8String) { @autoreleasepool { @@ -122,7 +122,7 @@ HRESULT AvnAppMenuItem::SetTitle (void* utf8String) } } -HRESULT AvnAppMenuItem::SetGesture (void* key, AvnInputModifiers modifiers) +HRESULT AvnAppMenuItem::SetGesture (char* key, AvnInputModifiers modifiers) { @autoreleasepool { @@ -296,7 +296,7 @@ HRESULT AvnAppMenu::RemoveItem (IAvnMenuItem* item) } } -HRESULT AvnAppMenu::SetTitle (void* utf8String) +HRESULT AvnAppMenu::SetTitle (char* utf8String) { @autoreleasepool { diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index 67b1ea50a6..e3996a1fae 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -768,7 +768,7 @@ private: } } - virtual HRESULT SetTitle (void* utf8title) override + virtual HRESULT SetTitle (char* utf8title) override { @autoreleasepool { diff --git a/nukebuild/MicroComGen.cs b/nukebuild/MicroComGen.cs new file mode 100644 index 0000000000..06c8acbf23 --- /dev/null +++ b/nukebuild/MicroComGen.cs @@ -0,0 +1,14 @@ +using System.IO; +using MicroComGenerator; +using Nuke.Common; + +partial class Build : NukeBuild +{ + Target GenerateCppHeaders => _ => _.Executes(() => + { + var text = File.ReadAllText(RootDirectory / "src" / "Avalonia.Native" / "avn.idl"); + var ast = AstParser.Parse(text); + File.WriteAllText(RootDirectory / "native" / "Avalonia.Native" / "inc" / "avalonia-native.h", + CppGen.GenerateCpp(ast)); + }); +} \ No newline at end of file diff --git a/nukebuild/_build.csproj b/nukebuild/_build.csproj index 77cfb83427..745c727be2 100644 --- a/nukebuild/_build.csproj +++ b/nukebuild/_build.csproj @@ -39,4 +39,8 @@ + + + + diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index dc139cf8e3..1d36cce20d 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -254,13 +254,13 @@ interface IAvnWindowBase : IUnknown HRESULT SetBlurEnabled(bool enable); } -[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91)] +[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91), cpp-virtual-inherits] interface IAvnPopup : IAvnWindowBase { } -[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d)] +[uuid(cab661de-49d6-4ead-b59c-eac9b2b6c28d), cpp-virtual-inherits] interface IAvnWindow : IAvnWindowBase { HRESULT SetEnabled(bool enable); @@ -285,7 +285,7 @@ interface IAvnWindowBaseEvents : IUnknown void Closed(); void Activated(); void Deactivated(); - void Resized([const] AvnSize* size); + void Resized([const] AvnSize& size); void PositionChanged(AvnPoint position); void RawMouseEvent(AvnRawMouseEventType type, uint timeStamp, diff --git a/src/tools/MicroComGenerator/Ast.cs b/src/tools/MicroComGenerator/Ast.cs index 2c366b143d..e9a55308be 100644 --- a/src/tools/MicroComGenerator/Ast.cs +++ b/src/tools/MicroComGenerator/Ast.cs @@ -83,10 +83,16 @@ namespace MicroComGenerator.Ast { public string Name { get; set; } public int PointerLevel { get; set; } + public bool IsLink { get; set; } - public string Format() => Name + new string('*', PointerLevel); + public string Format() => Name + new string('*', PointerLevel) + + (IsLink ? "&" : ""); public override string ToString() => Format(); - public AstTypeNode Clone() => new AstTypeNode() { Name = Name, PointerLevel = PointerLevel }; + public AstTypeNode Clone() => new AstTypeNode() { + Name = Name, + PointerLevel = PointerLevel, + IsLink = IsLink + }; } public class AstStructMemberNode : IAstNodeWithAttributes diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs index a003fb3096..732c0496b3 100644 --- a/src/tools/MicroComGenerator/AstParser.cs +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -146,6 +146,8 @@ namespace MicroComGenerator var t = new AstTypeNode { Name = ident }; while (parser.TryConsume('*')) t.PointerLevel++; + if (parser.TryConsume("&")) + t.IsLink = true; return t; } diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 8806531b19..688036ffc2 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -53,6 +53,17 @@ namespace MicroComGenerator base.VisitStructMember(member); } + protected override void VisitType(AstTypeNode type) + { + if (type.IsLink) + { + type.PointerLevel++; + type.IsLink = false; + } + + base.VisitType(type); + } + protected override void VisitArgument(AstInterfaceMemberArgumentNode argument) { if (argument.HasAttribute("intptr")) diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs index f2b748787f..68192ebffe 100644 --- a/src/tools/MicroComGenerator/CppGen.cs +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -35,7 +35,6 @@ namespace MicroComGenerator sb.Append("enum "); if (en.Attributes.Any(a => a.Name == "class-enum")) sb.Append("class "); - sb.Append(en.Name).Append(" "); sb.AppendLine(en.Name).AppendLine("{"); foreach (var m in en) @@ -73,30 +72,42 @@ namespace MicroComGenerator sb.Append(", ").Append(guid.Substring(16 + c * 2, 2)); } - sb.Append(") : ") - .AppendLine(i.Inherits ?? "IUnknown") + sb.Append(") : "); + if (i.HasAttribute("cpp-virtual-inherits")) + sb.Append("virtual "); + sb.AppendLine(i.Inherits ?? "IUnknown") .AppendLine("{"); foreach (var m in i) { - sb.Append(" ").Append(ConvertType(m.ReturnType)).Append(" ").Append(m.Name).AppendLine(" ("); - for (var c = 0; c < m.Count; c++) + sb.Append(" ") + .Append("virtual ") + .Append(ConvertType(m.ReturnType)) + .Append(" ").Append(m.Name).Append(" ("); + if (m.Count == 0) + sb.AppendLine(") = 0;"); + else { - var arg = m[c]; - sb.Append(" "); - if (arg.Attributes.Any(a => a.Name == "const")) - sb.Append("const "); - sb.Append(ConvertType(arg.Type)) - .Append(" ") - .Append(arg.Name); - if (c != m.Count - 1) - sb.Append(", "); sb.AppendLine(); - sb.AppendLine(" );"); + for (var c = 0; c < m.Count; c++) + { + var arg = m[c]; + sb.Append(" "); + if (arg.Attributes.Any(a => a.Name == "const")) + sb.Append("const "); + sb.Append(ConvertType(arg.Type)) + .Append(" ") + .Append(arg.Name); + if (c != m.Count - 1) + sb.Append(", "); + sb.AppendLine(); + } + + sb.AppendLine(" ) = 0;"); } } - sb.AppendLine("}"); + sb.AppendLine("};"); } return sb.ToString(); From a28dc2b9e411714ca8aebbe2e1fc70c94f03471e Mon Sep 17 00:00:00 2001 From: Luis von der Eltz Date: Thu, 29 Oct 2020 17:40:27 +0100 Subject: [PATCH 059/314] Throw NotSupportedException inside ContextMenu.Open(null) --- src/Avalonia.Controls/ContextMenu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index ec9649bc64..31071768c9 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -236,7 +236,7 @@ namespace Avalonia.Controls /// /// Opens the menu. /// - public override void Open() => Open(null); + public override void Open() => throw new NotSupportedException(); /// /// Opens a context menu on the specified control. From 72be5e3f016e0580f721e98f718319365cfa885e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 29 Oct 2020 20:52:43 +0300 Subject: [PATCH 060/314] Build --- azure-pipelines.yml | 7 ------- src/Avalonia.MicroCom/Avalonia.MicroCom.csproj | 7 +++++++ src/Avalonia.Native/Avalonia.Native.csproj | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d6c561bc6..ac1944b171 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,13 +3,6 @@ jobs: pool: vmImage: 'ubuntu-16.04' steps: - - task: CmdLine@2 - displayName: 'Install CastXML' - inputs: - script: | - sudo apt-get update - sudo apt-get install castxml - - task: CmdLine@2 displayName: 'Install Nuke' inputs: diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj index 7994a74f76..6af3b4347a 100644 --- a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -6,5 +6,12 @@ <_AvaloniaPatchComInterop>true + + + false + all + true + + diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index f0c747504b..a08dc0f28f 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -5,10 +5,7 @@ $(PackAvaloniaNative) true netstandard2.0 - /usr/bin/castxml - /usr/local/bin/castxml true - false From 98c2b0f9e0418877fdb28f64684b8831ad6d1f3c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 20:27:36 +0000 Subject: [PATCH 061/314] Initial implementation of IsKeyboardFocusWithin --- src/Avalonia.Input/ApiCompatBaseline.txt | 4 ++ src/Avalonia.Input/IInputElement.cs | 5 ++ src/Avalonia.Input/InputElement.cs | 24 +++++++- src/Avalonia.Input/KeyboardDevice.cs | 71 ++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/Avalonia.Input/ApiCompatBaseline.txt diff --git a/src/Avalonia.Input/ApiCompatBaseline.txt b/src/Avalonia.Input/ApiCompatBaseline.txt new file mode 100644 index 0000000000..d960664c1b --- /dev/null +++ b/src/Avalonia.Input/ApiCompatBaseline.txt @@ -0,0 +1,4 @@ +Compat issues with assembly Avalonia.Input: +InterfacesShouldHaveSameMembers : Interface member 'public System.Boolean Avalonia.Input.IInputElement.IsKeyboardFocusWithin' is present in the implementation but not in the contract. +InterfacesShouldHaveSameMembers : Interface member 'public System.Boolean Avalonia.Input.IInputElement.IsKeyboardFocusWithin.get()' is present in the implementation but not in the contract. +Total Issues: 2 diff --git a/src/Avalonia.Input/IInputElement.cs b/src/Avalonia.Input/IInputElement.cs index 12fec82368..7aa9c32bca 100644 --- a/src/Avalonia.Input/IInputElement.cs +++ b/src/Avalonia.Input/IInputElement.cs @@ -89,6 +89,11 @@ namespace Avalonia.Input /// value of this control and its parent controls. /// bool IsEffectivelyEnabled { get; } + + /// + /// Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. + /// + bool IsKeyboardFocusWithin { get; } /// /// Gets a value indicating whether the control is focused. diff --git a/src/Avalonia.Input/InputElement.cs b/src/Avalonia.Input/InputElement.cs index 9ace7fd92d..1db7db6ba2 100644 --- a/src/Avalonia.Input/InputElement.cs +++ b/src/Avalonia.Input/InputElement.cs @@ -42,6 +42,14 @@ namespace Avalonia.Input public static readonly StyledProperty CursorProperty = AvaloniaProperty.Register(nameof(Cursor), null, true); + /// + /// Defines the property. + /// + public static readonly DirectProperty IsKeyboardFocusWithinProperty = + AvaloniaProperty.RegisterDirect( + nameof(IsKeyboardFocusWithin), + o => o.IsKeyboardFocusWithin); + /// /// Defines the property. /// @@ -160,6 +168,7 @@ namespace Avalonia.Input private bool _isEffectivelyEnabled = true; private bool _isFocused; + private bool _isKeyboardFocusWithin; private bool _isFocusVisible; private bool _isPointerOver; private GestureRecognizerCollection? _gestureRecognizers; @@ -343,6 +352,15 @@ namespace Avalonia.Input get { return GetValue(CursorProperty); } set { SetValue(CursorProperty, value); } } + + /// + /// Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. + /// + public bool IsKeyboardFocusWithin + { + get => _isKeyboardFocusWithin; + internal set => SetAndRaise(IsKeyboardFocusWithinProperty, ref _isKeyboardFocusWithin, value); + } /// /// Gets a value indicating whether the control is focused. @@ -423,7 +441,7 @@ namespace Avalonia.Input base.OnAttachedToVisualTreeCore(e); UpdateIsEffectivelyEnabled(); } - + /// /// Called before the event occurs. /// @@ -544,6 +562,10 @@ namespace Avalonia.Input { UpdatePseudoClasses(null, change.NewValue.GetValueOrDefault()); } + else if (change.Property == IsKeyboardFocusWithinProperty) + { + PseudoClasses.Set(":focus-within", _isKeyboardFocusWithin); + } } /// diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 187670a26b..758a398f3a 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -31,6 +31,74 @@ namespace Avalonia.Input RaisePropertyChanged(); } } + + private void ClearFocusWithin(IInputElement element, bool clearRoot) + { + foreach (IInputElement el in element.VisualChildren) + { + if (el.IsKeyboardFocusWithin) + { + ClearFocusWithin(el, true); + break; + } + } + + if(clearRoot) + { + if (element is InputElement ie) + { + ie.IsKeyboardFocusWithin = false; + } + } + } + + private void SetIsFocusWithin(InputElement oldElement, InputElement newElement) + { + InputElement? branch = null; + + InputElement el = newElement; + + while (el != null) + { + if (el.IsKeyboardFocusWithin) + { + branch = el; + break; + } + + if ((el as IInputElement).VisualParent is InputElement ie) + { + el = ie; + } + else + { + break; + } + } + + el = oldElement; + + if (el != null && branch != null) + { + ClearFocusWithin(branch, false); + } + + el = newElement; + + while (el != null && el != branch) + { + el.IsKeyboardFocusWithin = true; + + if ((el as IInputElement).VisualParent is InputElement ie) + { + el = ie; + } + else + { + break; + } + } + } public void SetFocusedElement( IInputElement? element, @@ -40,6 +108,9 @@ namespace Avalonia.Input if (element != FocusedElement) { var interactive = FocusedElement as IInteractive; + + SetIsFocusWithin(FocusedElement as InputElement, element as InputElement); + FocusedElement = element; interactive?.RaiseEvent(new RoutedEventArgs From 7cae6af637aff6ab3ee180049911d2a1df01ba44 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 21:24:43 +0000 Subject: [PATCH 062/314] less casting. --- src/Avalonia.Input/KeyboardDevice.cs | 31 +++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 758a398f3a..9653b78e2d 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -52,11 +52,11 @@ namespace Avalonia.Input } } - private void SetIsFocusWithin(InputElement oldElement, InputElement newElement) + private void SetIsFocusWithin(IInputElement oldElement, IInputElement newElement) { - InputElement? branch = null; + IInputElement? branch = null; - InputElement el = newElement; + IInputElement el = newElement; while (el != null) { @@ -66,14 +66,7 @@ namespace Avalonia.Input break; } - if ((el as IInputElement).VisualParent is InputElement ie) - { - el = ie; - } - else - { - break; - } + el = (IInputElement)el.VisualParent; } el = oldElement; @@ -87,16 +80,12 @@ namespace Avalonia.Input while (el != null && el != branch) { - el.IsKeyboardFocusWithin = true; - - if ((el as IInputElement).VisualParent is InputElement ie) + if (el is InputElement ie) { - el = ie; - } - else - { - break; + ie.IsKeyboardFocusWithin = true; } + + el = (IInputElement)el.VisualParent; } } @@ -108,8 +97,8 @@ namespace Avalonia.Input if (element != FocusedElement) { var interactive = FocusedElement as IInteractive; - - SetIsFocusWithin(FocusedElement as InputElement, element as InputElement); + + SetIsFocusWithin(FocusedElement, element); FocusedElement = element; From 6b324eb05839731dddd527a1e219951474e5fe68 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 29 Oct 2020 21:31:12 +0000 Subject: [PATCH 063/314] update reactiveui --- build/ReactiveUI.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ReactiveUI.props b/build/ReactiveUI.props index d8e86e917e..f74ab07e31 100644 --- a/build/ReactiveUI.props +++ b/build/ReactiveUI.props @@ -1,5 +1,5 @@ - + From 50b2b3320c8625fb1a14e3bdc272fb833f4c9d3b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 30 Oct 2020 15:17:19 +0100 Subject: [PATCH 064/314] Move test to existing test case. --- .../Selection/InternalSelectionModelTests.cs | 33 ------------------- .../Selection/SelectionModelTests_Multiple.cs | 7 ++++ .../Selection/SelectionModelTests_Single.cs | 7 ++++ 3 files changed, 14 insertions(+), 33 deletions(-) diff --git a/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs b/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs index 8701fc2479..ce3e698cf3 100644 --- a/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Selection/InternalSelectionModelTests.cs @@ -232,39 +232,6 @@ namespace Avalonia.Controls.UnitTests.Selection Assert.Contains(nameof(target.SelectedItem), changed); } - [Fact] - public void Raises_Selection_Changed_On_Item_Move() - { - var items = new AvaloniaList(new[] { "foo", "bar", "baz" }); - var target = CreateTarget(source: items); - - target.SelectedIndex = 1; - - var changed = new List(); - - target.PropertyChanged += (s, e) => changed.Add(e.PropertyName); - - var oldSelectedIndex = target.SelectedIndex; - var oldSelectedItem = target.SelectedItem; - - - var sel = items[1]; - var other = items[2]; - - items[2] = sel; - items[1] = other; - - Assert.NotEqual(oldSelectedIndex, target.SelectedIndex); - Assert.NotEqual(oldSelectedItem, target.SelectedItem); - - Assert.Equal(-1, target.SelectedIndex); - Assert.Equal(null, target.SelectedItem); - - Assert.Contains(nameof(target.SelectedIndex), changed); - Assert.Contains(nameof(target.SelectedItem), changed); - } - - [Fact] public void Preserves_SelectedItem_On_Items_Reset() { diff --git a/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Multiple.cs b/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Multiple.cs index 5d0c6d31e1..68bdbe51e8 100644 --- a/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Multiple.cs +++ b/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Multiple.cs @@ -1216,6 +1216,7 @@ namespace Avalonia.Controls.UnitTests.Selection var data = (AvaloniaList)target.Source!; var selectionChangedRaised = 0; var selectedIndexRaised = 0; + var selectedItemRaised = 0; var indexesChangedRaised = 0; target.Source = data; @@ -1227,6 +1228,11 @@ namespace Avalonia.Controls.UnitTests.Selection { ++selectedIndexRaised; } + + if (e.PropertyName == nameof(target.SelectedItem)) + { + ++selectedItemRaised; + } }; target.IndexesChanged += (s, e) => ++indexesChangedRaised; @@ -1249,6 +1255,7 @@ namespace Avalonia.Controls.UnitTests.Selection Assert.Equal(2, target.AnchorIndex); Assert.Equal(1, selectionChangedRaised); Assert.Equal(1, selectedIndexRaised); + Assert.Equal(1, selectedItemRaised); Assert.Equal(0, indexesChangedRaised); } diff --git a/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs b/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs index 66a2cef921..668af3b5d7 100644 --- a/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs +++ b/tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs @@ -1040,6 +1040,7 @@ namespace Avalonia.Controls.UnitTests.Selection var data = (AvaloniaList)target.Source!; var selectionChangedRaised = 0; var selectedIndexRaised = 0; + var selectedItemRaised = 0; target.Source = data; target.Select(1); @@ -1050,6 +1051,11 @@ namespace Avalonia.Controls.UnitTests.Selection { ++selectedIndexRaised; } + + if (e.PropertyName == nameof(target.SelectedItem)) + { + ++selectedItemRaised; + } }; target.SelectionChanged += (s, e) => @@ -1070,6 +1076,7 @@ namespace Avalonia.Controls.UnitTests.Selection Assert.Equal(-1, target.AnchorIndex); Assert.Equal(1, selectionChangedRaised); Assert.Equal(1, selectedIndexRaised); + Assert.Equal(1, selectedItemRaised); } [Fact] From 2afd29e9c879ce0693f96d85dcd373ceda21d043 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 31 Oct 2020 16:07:23 +0100 Subject: [PATCH 065/314] Use existing OnDataContextChanged method. --- src/Avalonia.ReactiveUI/ReactiveUserControl.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 40d9666c3e..f4824ade0a 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -28,7 +28,6 @@ namespace Avalonia.ReactiveUI // This WhenActivated block calls ViewModel's WhenActivated // block if the ViewModel implements IActivatableViewModel. this.WhenActivated(disposables => { }); - this.GetObservable(DataContextProperty).Subscribe(OnDataContextChanged); this.GetObservable(ViewModelProperty).Subscribe(OnViewModelChanged); } @@ -47,16 +46,9 @@ namespace Avalonia.ReactiveUI set => ViewModel = (TViewModel)value; } - private void OnDataContextChanged(object value) + protected override void OnDataContextChanged(EventArgs e) { - if (value is TViewModel viewModel) - { - ViewModel = viewModel; - } - else - { - ViewModel = null; - } + ViewModel = DataContext as TViewModel; } private void OnViewModelChanged(object value) From 7f904f6c892e91138b531791452fd8c189f1924c Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 18:03:56 +0300 Subject: [PATCH 066/314] Emit IgnoresAccessChecksToAttribute for runtime-generated XAML --- build.sh | 2 +- .../AvaloniaXamlIlRuntimeCompiler.cs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a40e00f815..bd162fab9b 100755 --- a/build.sh +++ b/build.sh @@ -47,7 +47,7 @@ if [ -f "$DOTNET_GLOBAL_FILE" ]; then fi # If dotnet is installed locally, and expected version is not set or installation matches the expected version -if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") ]]; then +if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") || "$SKIP_DOTNET_DOWNLOAD" == "1" ]]; then export DOTNET_EXE="$(command -v dotnet)" else DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index d9b4cd70da..c69a651af2 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -26,6 +26,7 @@ namespace Avalonia.Markup.Xaml.XamlIl { #if !RUNTIME_XAML_CECIL private static SreTypeSystem _sreTypeSystem; + private static Type _ignoresAccessChecksFromAttribute; private static ModuleBuilder _sreBuilder; private static IXamlType _sreContextType; private static XamlLanguageTypeMappings _sreMappings; @@ -94,8 +95,58 @@ namespace Avalonia.Markup.Xaml.XamlIl _sreTypeSystem.CreateTypeBuilder( _sreBuilder.DefineType("XamlIlContext")), _sreTypeSystem, _sreMappings, _sreEmitMappings); + if (_ignoresAccessChecksFromAttribute == null) + _ignoresAccessChecksFromAttribute = EmitIgnoresAccessCheckAttributeDefinition(_sreBuilder); } + static Type EmitIgnoresAccessCheckAttributeDefinition(ModuleBuilder builder) + { + var tb = builder.DefineType("System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute", + TypeAttributes.Class | TypeAttributes.Public, typeof(Attribute)); + var field = tb.DefineField("_name", typeof(string), FieldAttributes.Private); + var propGet = tb.DefineMethod("get_AssemblyName", MethodAttributes.Public, typeof(string), + Array.Empty()); + var propGetIl = propGet.GetILGenerator(); + propGetIl.Emit(OpCodes.Ldarg_0); + propGetIl.Emit(OpCodes.Ldfld, field); + propGetIl.Emit(OpCodes.Ret); + var prop = tb.DefineProperty("AssemblyName", PropertyAttributes.None, typeof(string), Array.Empty()); + prop.SetGetMethod(propGet); + + + var ctor = tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, + new[] { typeof(string) }); + var ctorIl = ctor.GetILGenerator(); + ctorIl.Emit(OpCodes.Ldarg_0); + ctorIl.Emit(OpCodes.Ldarg_1); + ctorIl.Emit(OpCodes.Stfld, field); + ctorIl.Emit(OpCodes.Ldarg_0); + ctorIl.Emit(OpCodes.Call, typeof(Attribute) + .GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) + .First(x => x.GetParameters().Length == 0)); + + ctorIl.Emit(OpCodes.Ret); + + tb.SetCustomAttribute(new CustomAttributeBuilder( + typeof(AttributeUsageAttribute).GetConstructor(new[] { typeof(AttributeTargets) }), + new object[] { AttributeTargets.Assembly }, + new[] { typeof(AttributeUsageAttribute).GetProperty("AllowMultiple") }, + new object[] { true })); + + return tb.CreateTypeInfo(); + } + + static void EmitIgnoresAccessCheckToAttribute(AssemblyName assemblyName) + { + var name = assemblyName.Name; + var key = assemblyName.GetPublicKey(); + if (key != null) + name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); + _sreAsm.SetCustomAttribute(new CustomAttributeBuilder( + _ignoresAccessChecksFromAttribute.GetConstructors()[0], + new object[] { name })); + } + static object LoadSre(string xaml, Assembly localAssembly, object rootInstance, Uri uri, bool isDesignMode) { @@ -118,6 +169,8 @@ namespace Avalonia.Markup.Xaml.XamlIl { InitializeSre(); + if (localAssembly?.FullName != null) + EmitIgnoresAccessCheckToAttribute(localAssembly.GetName()); var asm = localAssembly == null ? null : _sreTypeSystem.GetAssembly(localAssembly); var tb = _sreBuilder.DefineType("Builder_" + Guid.NewGuid().ToString("N") + "_" + uri); var clrPropertyBuilder = tb.DefineNestedType("ClrProperties_" + Guid.NewGuid().ToString("N")); From 8f6107969cdbe487c58b28d4f6ba6620a9fbd542 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 19:16:56 +0300 Subject: [PATCH 067/314] Extra checks --- .../AvaloniaXamlIlRuntimeCompiler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index c69a651af2..75de1f55ce 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -139,6 +139,8 @@ namespace Avalonia.Markup.Xaml.XamlIl static void EmitIgnoresAccessCheckToAttribute(AssemblyName assemblyName) { var name = assemblyName.Name; + if(string.IsNullOrWhiteSpace(name)) + return; var key = assemblyName.GetPublicKey(); if (key != null) name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); @@ -169,7 +171,7 @@ namespace Avalonia.Markup.Xaml.XamlIl { InitializeSre(); - if (localAssembly?.FullName != null) + if (localAssembly?.GetName() != null) EmitIgnoresAccessCheckToAttribute(localAssembly.GetName()); var asm = localAssembly == null ? null : _sreTypeSystem.GetAssembly(localAssembly); var tb = _sreBuilder.DefineType("Builder_" + Guid.NewGuid().ToString("N") + "_" + uri); From 6b662026ef1aa4d303c83d087b74733d2d951e79 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 1 Nov 2020 20:35:56 +0300 Subject: [PATCH 068/314] Fix support for packages without strong name --- .../AvaloniaXamlIlRuntimeCompiler.cs | 2 +- .../DesignerSupportTests.cs | 61 ++++++++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs index 75de1f55ce..ece90762cb 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs @@ -142,7 +142,7 @@ namespace Avalonia.Markup.Xaml.XamlIl if(string.IsNullOrWhiteSpace(name)) return; var key = assemblyName.GetPublicKey(); - if (key != null) + if (key != null && key.Length != 0) name += ", PublicKey=" + BitConverter.ToString(key).Replace("-", "").ToUpperInvariant(); _sreAsm.SetCustomAttribute(new CustomAttributeBuilder( _ignoresAccessChecksFromAttribute.GetConstructors()[0], diff --git a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs index dd704bc775..d76ed9042f 100644 --- a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs +++ b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Designer; +using Avalonia.Remote.Protocol.Viewport; using Xunit; using Xunit.Extensions; @@ -31,19 +32,38 @@ namespace Avalonia.DesignerSupport.Tests @"..\..\..\..\..\tests/Avalonia.DesignerSupport.TestApp/bin/$BUILD/netcoreapp3.1/", "Avalonia.DesignerSupport.TestApp", "Avalonia.DesignerSupport.TestApp.dll", - @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml"), + @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml", + "win32"), InlineData( @"..\..\..\..\..\samples\ControlCatalog.NetCore\bin\$BUILD\netcoreapp3.1\", "ControlCatalog.NetCore", "ControlCatalog.dll", - @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml")] + @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml", + "win32"), + InlineData( + @"..\..\..\..\..\tests/Avalonia.DesignerSupport.TestApp/bin/$BUILD/netcoreapp3.1/", + "Avalonia.DesignerSupport.TestApp", + "Avalonia.DesignerSupport.TestApp.dll", + @"..\..\..\..\..\tests\Avalonia.DesignerSupport.TestApp\MainWindow.xaml", + "avalonia-remote"), + InlineData( + @"..\..\..\..\..\samples\ControlCatalog.NetCore\bin\$BUILD\netcoreapp3.1\", + "ControlCatalog.NetCore", + "ControlCatalog.dll", + @"..\..\..\..\..\samples\ControlCatalog\MainWindow.xaml", + "avalonia-remote")] public async Task Designer_In_Win32_Mode_Should_Provide_Valid_Hwnd( string outputDir, string executableName, string assemblyName, - string xamlFile) + string xamlFile, + string method) { - Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + outputDir = Path.GetFullPath(outputDir.Replace('\\', Path.DirectorySeparatorChar)); + xamlFile = Path.GetFullPath(xamlFile.Replace('\\', Path.DirectorySeparatorChar)); + + if (method == "win32") + Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); var xaml = File.ReadAllText(xamlFile); string buildType; @@ -56,6 +76,8 @@ namespace Avalonia.DesignerSupport.Tests var sessionId = Guid.NewGuid(); long handle = 0; + bool success = false; + string error = null; var resultMessageReceivedToken = new CancellationTokenSource(); @@ -71,6 +93,18 @@ namespace Avalonia.DesignerSupport.Tests if (msg is StartDesignerSessionMessage start) { Assert.Equal(sessionId, Guid.Parse(start.SessionId)); + if (method == "avalonia-remote") + { + await conn.Send(new ClientSupportedPixelFormatsMessage + { + Formats = new[] { PixelFormat.Rgba8888 } + }); + await conn.Send(new ClientViewportAllocatedMessage + { + DpiX = 96, DpiY = 96, Width = 1024, Height = 768 + }); + } + await conn.Send(new UpdateXamlMessage { AssemblyPath = Path.Combine(outputDir, assemblyName), @@ -80,8 +114,14 @@ namespace Avalonia.DesignerSupport.Tests else if (msg is UpdateXamlResultMessage result) { if (result.Error != null) + { + error = result.Error; outputHelper.WriteLine(result.Error); - handle = result.Handle != null ? long.Parse(result.Handle) : 0; + } + else + success = true; + if (method == "win32") + handle = result.Handle != null ? long.Parse(result.Handle) : 0; resultMessageReceivedToken.Cancel(); conn.Dispose(); } @@ -91,7 +131,7 @@ namespace Avalonia.DesignerSupport.Tests var cmdline = $"exec --runtimeconfig \"{outputDir}{executableName}.runtimeconfig.json\" --depsfile \"{outputDir}{executableName}.deps.json\" " + $" \"{DesignerAppPath.Replace("$BUILD", buildType)}\" " - + $"--transport tcp-bson://127.0.0.1:{port}/ --session-id {sessionId} --method win32 \"{outputDir}{executableName}.dll\""; + + $"--transport tcp-bson://127.0.0.1:{port}/ --session-id {sessionId} --method {method} \"{outputDir}{executableName}.dll\""; using (var proc = new Process { @@ -128,10 +168,15 @@ namespace Avalonia.DesignerSupport.Tests } proc.WaitForExit(); + var stdout = proc.StandardOutput.ReadToEnd(); + var stderr = proc.StandardError.ReadToEnd(); Assert.True(cancelled, $"Message Not Received.\n" + proc.StandardOutput.ReadToEnd() + "\n" + - proc.StandardError.ReadToEnd()); - Assert.NotEqual(0, handle); + stderr + "\n" + stdout); + Assert.True(success, error); + if (method == "win32") + Assert.NotEqual(0, handle); + } } From 7a33cd4e825f70dbc1fb4cef7dabb63d98b1f009 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 10:22:55 +0000 Subject: [PATCH 069/314] change syntax. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index f020280496..09742412d9 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -382,7 +382,7 @@ namespace Avalonia.Controls ItemContainerGenerator.Index.ContainerFromItem(_selectedItem) : ItemContainerGenerator.ContainerFromIndex(0); - return (result is {}, result); // SelectedItem may not be in the treeview. + return (result != null, result); // SelectedItem may not be in the treeview. } return (true, null); From 1cc569472ef90b7940ec8530e15a2eb7e1700341 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 2 Nov 2020 11:45:11 +0100 Subject: [PATCH 070/314] Fix ncrunch. --- .ncrunch/Avalonia.Build.Tasks.v3.ncrunchproject | 4 +--- .ncrunch/Avalonia.MicroCom.v3.ncrunchproject | 5 +++++ Avalonia.v3.ncrunchsolution | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .ncrunch/Avalonia.MicroCom.v3.ncrunchproject diff --git a/.ncrunch/Avalonia.Build.Tasks.v3.ncrunchproject b/.ncrunch/Avalonia.Build.Tasks.v3.ncrunchproject index 319cd523ce..95a483b433 100644 --- a/.ncrunch/Avalonia.Build.Tasks.v3.ncrunchproject +++ b/.ncrunch/Avalonia.Build.Tasks.v3.ncrunchproject @@ -1,5 +1,3 @@  - - True - + \ No newline at end of file diff --git a/.ncrunch/Avalonia.MicroCom.v3.ncrunchproject b/.ncrunch/Avalonia.MicroCom.v3.ncrunchproject new file mode 100644 index 0000000000..319cd523ce --- /dev/null +++ b/.ncrunch/Avalonia.MicroCom.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/Avalonia.v3.ncrunchsolution b/Avalonia.v3.ncrunchsolution index afce1018ec..b97a8e54f5 100644 --- a/Avalonia.v3.ncrunchsolution +++ b/Avalonia.v3.ncrunchsolution @@ -4,6 +4,8 @@ tests\TestFiles\**.* src\Avalonia.Build.Tasks\bin\Debug\netstandard2.0\Avalonia.Build.Tasks.dll src\Avalonia.Build.Tasks\bin\Debug\netstandard2.0\Mono.Cecil.dll + src\Avalonia.Build.Tasks\bin\Debug\netstandard2.0\Mono.Cecil.Rocks.dll + src\Avalonia.Build.Tasks\bin\Debug\netstandard2.0\Mono.Cecil.Pdb.dll True From deb0a58eb48e7f8eb4e0f401809fdefe8a78f327 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 11:07:01 +0000 Subject: [PATCH 071/314] Add some unit tests for FocusWithin --- .../InputElement_Focus.cs | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs index 09fae7207f..7e1f7f1dc3 100644 --- a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs +++ b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs @@ -121,5 +121,93 @@ namespace Avalonia.Input.UnitTests Assert.False(target2.Classes.Contains(":focus-visible")); } } + + [Fact] + public void Control_FocusWithin_PseudoClass_Should_Be_Applied() + { + using (UnitTestApplication.Start(TestServices.RealFocus)) + { + var target1 = new Decorator(); + var target2 = new Decorator(); + var root = new TestRoot + { + Child = new StackPanel + { + Children = + { + target1, + target2 + } + } + }; + + target1.ApplyTemplate(); + target2.ApplyTemplate(); + + FocusManager.Instance?.Focus(target1); + Assert.True(target1.IsFocused); + Assert.True(target1.Classes.Contains(":focus-within")); + Assert.True(target1.IsKeyboardFocusWithin); + Assert.True(root.Child.Classes.Contains(":focus-within")); + Assert.True(root.Child.IsKeyboardFocusWithin); + Assert.True(root.Classes.Contains(":focus-within")); + Assert.True(root.IsKeyboardFocusWithin); + } + } + + [Fact] + public void Control_FocusWithin_PseudoClass_Should_Be_Applied_and_Removed() + { + using (UnitTestApplication.Start(TestServices.RealFocus)) + { + var target1 = new Decorator(); + var target2 = new Decorator(); + var panel1 = new Panel { Children = { target1 } }; + var panel2 = new Panel { Children = { target2 } }; + var root = new TestRoot + { + Child = new StackPanel + { + Children = + { + panel1, + panel2 + } + } + }; + + target1.ApplyTemplate(); + target2.ApplyTemplate(); + + FocusManager.Instance?.Focus(target1); + Assert.True(target1.IsFocused); + Assert.True(target1.Classes.Contains(":focus-within")); + Assert.True(target1.IsKeyboardFocusWithin); + Assert.True(panel1.Classes.Contains(":focus-within")); + Assert.True(panel1.IsKeyboardFocusWithin); + Assert.True(root.Child.Classes.Contains(":focus-within")); + Assert.True(root.Child.IsKeyboardFocusWithin); + Assert.True(root.Classes.Contains(":focus-within")); + Assert.True(root.IsKeyboardFocusWithin); + + FocusManager.Instance?.Focus(target2); + + Assert.False(target1.IsFocused); + Assert.False(target1.Classes.Contains(":focus-within")); + Assert.False(target1.IsKeyboardFocusWithin); + Assert.False(panel1.Classes.Contains(":focus-within")); + Assert.False(panel1.IsKeyboardFocusWithin); + Assert.True(root.Child.Classes.Contains(":focus-within")); + Assert.True(root.Child.IsKeyboardFocusWithin); + Assert.True(root.Classes.Contains(":focus-within")); + Assert.True(root.IsKeyboardFocusWithin); + + Assert.True(target2.IsFocused); + Assert.True(target2.Classes.Contains(":focus-within")); + Assert.True(target2.IsKeyboardFocusWithin); + Assert.True(panel2.Classes.Contains(":focus-within")); + Assert.True(panel2.IsKeyboardFocusWithin); + } + } } } From f9f4e73bd3f5691e3fa5b99baff125ecb7934aab Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 11:09:07 +0000 Subject: [PATCH 072/314] whitespace. --- src/Avalonia.Input/InputElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Input/InputElement.cs b/src/Avalonia.Input/InputElement.cs index 1db7db6ba2..66fb9cfb1c 100644 --- a/src/Avalonia.Input/InputElement.cs +++ b/src/Avalonia.Input/InputElement.cs @@ -441,7 +441,7 @@ namespace Avalonia.Input base.OnAttachedToVisualTreeCore(e); UpdateIsEffectivelyEnabled(); } - + /// /// Called before the event occurs. /// From 8e2d55523922a5b03a388244496f6dc5587663d0 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 11:48:27 +0000 Subject: [PATCH 073/314] focus within copes with detach from tree. --- src/Avalonia.Input/KeyboardDevice.cs | 57 ++++++++++++++++++- .../InputElement_Focus.cs | 45 +++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 9653b78e2d..43a44331a7 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -9,6 +9,7 @@ namespace Avalonia.Input public class KeyboardDevice : IKeyboardDevice, INotifyPropertyChanged { private IInputElement? _focusedElement; + private IInputRoot? _focusedRoot; public event PropertyChangedEventHandler? PropertyChanged; @@ -28,9 +29,34 @@ namespace Avalonia.Input private set { _focusedElement = value; + + if (_focusedElement != null && _focusedElement.IsAttachedToVisualTree) + { + _focusedRoot = _focusedElement.VisualRoot as IInputRoot; + } + else + { + _focusedRoot = null; + } + RaisePropertyChanged(); } } + + private void ClearFocusWithinAncestors(IInputElement element) + { + IInputElement el = element; + + while (el != null) + { + if (el is InputElement ie) + { + ie.IsKeyboardFocusWithin = false; + } + + el = (IInputElement)el.VisualParent; + } + } private void ClearFocusWithin(IInputElement element, bool clearRoot) { @@ -54,9 +80,15 @@ namespace Avalonia.Input private void SetIsFocusWithin(IInputElement oldElement, IInputElement newElement) { + if (newElement == null && oldElement != null) + { + ClearFocusWithinAncestors(oldElement); + return; + } + IInputElement? branch = null; - IInputElement el = newElement; + IInputElement? el = newElement; while (el != null) { @@ -69,7 +101,7 @@ namespace Avalonia.Input el = (IInputElement)el.VisualParent; } - el = oldElement; + el = oldElement!; if (el != null && branch != null) { @@ -88,6 +120,22 @@ namespace Avalonia.Input el = (IInputElement)el.VisualParent; } } + + private void ClearChildrenFocusWithin(IInputElement element,bool clearRoot) + { + foreach (IInputElement el in element.VisualChildren) + { + if (el.IsKeyboardFocusWithin) + { + ClearChildrenFocusWithin(el, true); + break; + } + } + if(clearRoot && element is InputElement ie) + { + ie.IsKeyboardFocusWithin = false; + } + } public void SetFocusedElement( IInputElement? element, @@ -98,6 +146,11 @@ namespace Avalonia.Input { var interactive = FocusedElement as IInteractive; + if (FocusedElement != null && !FocusedElement.IsAttachedToVisualTree && _focusedRoot != null) + { + ClearChildrenFocusWithin(_focusedRoot, true); + } + SetIsFocusWithin(FocusedElement, element); FocusedElement = element; diff --git a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs index 7e1f7f1dc3..b79ae92ef3 100644 --- a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs +++ b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs @@ -209,5 +209,50 @@ namespace Avalonia.Input.UnitTests Assert.True(panel2.IsKeyboardFocusWithin); } } + + [Fact] + public void Control_FocusVsisible_Pseudoclass_Should_Be_Removed_When_Removed_From_Tree() + { + using (UnitTestApplication.Start(TestServices.RealFocus)) + { + var target1 = new Decorator(); + var target2 = new Decorator(); + var root = new TestRoot + { + Child = new StackPanel + { + Children = + { + target1, + target2 + } + } + }; + + target1.ApplyTemplate(); + target2.ApplyTemplate(); + + FocusManager.Instance?.Focus(target1); + Assert.True(target1.IsFocused); + Assert.True(target1.Classes.Contains(":focus-within")); + Assert.True(target1.IsKeyboardFocusWithin); + Assert.True(root.Child.Classes.Contains(":focus-within")); + Assert.True(root.Child.IsKeyboardFocusWithin); + Assert.True(root.Classes.Contains(":focus-within")); + Assert.True(root.IsKeyboardFocusWithin); + + Assert.Equal(KeyboardDevice.Instance.FocusedElement, target1); + + root.Child = null; + + Assert.Null(KeyboardDevice.Instance.FocusedElement); + + Assert.False(target1.IsFocused); + Assert.False(target1.Classes.Contains(":focus-within")); + Assert.False(target1.IsKeyboardFocusWithin); + Assert.False(root.Classes.Contains(":focus-within")); + Assert.False(root.IsKeyboardFocusWithin); + } + } } } From 2baae49a12e55fa4fe20d993d00e95f42bcc7501 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 17:28:51 +0000 Subject: [PATCH 074/314] fix nullable reference type warnings. --- src/Avalonia.Input/KeyboardDevice.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 43a44331a7..099fc74766 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -43,9 +43,9 @@ namespace Avalonia.Input } } - private void ClearFocusWithinAncestors(IInputElement element) + private void ClearFocusWithinAncestors(IInputElement? element) { - IInputElement el = element; + var el = element; while (el != null) { @@ -60,16 +60,16 @@ namespace Avalonia.Input private void ClearFocusWithin(IInputElement element, bool clearRoot) { - foreach (IInputElement el in element.VisualChildren) + foreach (var visual in element.VisualChildren) { - if (el.IsKeyboardFocusWithin) + if (visual is IInputElement el && el.IsKeyboardFocusWithin) { ClearFocusWithin(el, true); break; } } - if(clearRoot) + if (clearRoot) { if (element is InputElement ie) { @@ -78,7 +78,7 @@ namespace Avalonia.Input } } - private void SetIsFocusWithin(IInputElement oldElement, IInputElement newElement) + private void SetIsFocusWithin(IInputElement? oldElement, IInputElement? newElement) { if (newElement == null && oldElement != null) { @@ -88,7 +88,7 @@ namespace Avalonia.Input IInputElement? branch = null; - IInputElement? el = newElement; + var el = newElement; while (el != null) { @@ -101,7 +101,7 @@ namespace Avalonia.Input el = (IInputElement)el.VisualParent; } - el = oldElement!; + el = oldElement; if (el != null && branch != null) { @@ -121,17 +121,18 @@ namespace Avalonia.Input } } - private void ClearChildrenFocusWithin(IInputElement element,bool clearRoot) + private void ClearChildrenFocusWithin(IInputElement element, bool clearRoot) { - foreach (IInputElement el in element.VisualChildren) + foreach (var visual in element.VisualChildren) { - if (el.IsKeyboardFocusWithin) + if (visual is IInputElement el && el.IsKeyboardFocusWithin) { ClearChildrenFocusWithin(el, true); break; } } - if(clearRoot && element is InputElement ie) + + if (clearRoot && element is InputElement ie) { ie.IsKeyboardFocusWithin = false; } From eeba3f0e2e7ee123783617b41bd7f64a772c5c0d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 2 Nov 2020 20:39:34 +0300 Subject: [PATCH 075/314] AddSyntheticProjectReferencesForSolutionDependencies = false --- Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index b41f8c488e..c6610695c4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,5 +2,7 @@ $(MSBuildThisFileDirectory)build-intermediate/nuget $(MSBuildThisFileDirectory)\src\tools\Avalonia.Designer.HostApp\bin\$(Configuration)\netcoreapp2.0\Avalonia.Designer.HostApp.dll + + false From 7354ba337a3b7883878735f4eb21995b7e53760a Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 2 Nov 2020 18:50:27 +0100 Subject: [PATCH 076/314] Use as instead of cast. In case someone's doing something funky, fail gracefully. --- src/Avalonia.Input/KeyboardDevice.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 099fc74766..1a161ae56a 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -98,7 +98,7 @@ namespace Avalonia.Input break; } - el = (IInputElement)el.VisualParent; + el = el.VisualParent as IInputElement; } el = oldElement; @@ -117,8 +117,8 @@ namespace Avalonia.Input ie.IsKeyboardFocusWithin = true; } - el = (IInputElement)el.VisualParent; - } + el = el.VisualParent as IInputElement; + } } private void ClearChildrenFocusWithin(IInputElement element, bool clearRoot) From 72c3f6443dc3cd70d4f7687afbfea0dc2450401b Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 2 Nov 2020 20:54:30 +0300 Subject: [PATCH 077/314] microcom? --- src/Avalonia.MicroCom/Avalonia.MicroCom.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj index 6af3b4347a..b796e173c4 100644 --- a/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj +++ b/src/Avalonia.MicroCom/Avalonia.MicroCom.csproj @@ -10,7 +10,6 @@ false all - true From 8a863a1c1114099b5ea88aadd2b62f15759aca7e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 2 Nov 2020 21:34:45 +0300 Subject: [PATCH 078/314] Update build.md --- Documentation/build.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/build.md b/Documentation/build.md index 8c2ef57b54..2f59146a48 100644 --- a/Documentation/build.md +++ b/Documentation/build.md @@ -30,7 +30,7 @@ The build process needs [Xcode](https://developer.apple.com/xcode/) to build the Linux operating systems ship with their own respective package managers however we will use [Homebrew](https://brew.sh/) to manage packages on macOS. To install follow the instructions [here](https://docs.brew.sh/Installation). -### Install CastXML +### Install CastXML (pre Nov 2020) Avalonia requires [CastXML](https://github.com/CastXML/CastXML) for XML processing during the build process. The easiest way to install this is via the operating system's package managers, such as below. @@ -61,6 +61,7 @@ git submodule update --init --recursive ### Build native libraries (macOS only) On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). The steps to get this working correctly are: +- (for revisions after 2 Nov 2020) Run `./build.sh GenerateCppHeaders` to generate `avalonia-native.h` from `avn.idl` - Navigate to the Avalonia/native/Avalonia.Native/src/OSX folder and open the `Avalonia.Native.OSX.xcodeproj` project - Build the library via the Product->Build menu. This will generate binaries in your local path under ~/Library/Developer/Xcode/DerivedData/Avalonia.Native.OSX-*guid* where "guid" is uniquely generated every time you build. - Manually install the native library by copying it from the build artifacts folder into the shared dynamic library path: From 81e6df9188d47a2debadadfec216b9434c49c2ab Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 2 Nov 2020 21:36:10 +0300 Subject: [PATCH 079/314] CompileNative should depend on GenerateCppHeaders --- nukebuild/Build.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index ecc01b4aab..97647a1c59 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -141,6 +141,7 @@ partial class Build : NukeBuild Target CompileNative => _ => _ .DependsOn(Clean) + .DependsOn(GenerateCppHeaders) .OnlyWhenStatic(() => EnvironmentInfo.IsOsx) .Executes(() => { From 9dee53c7d954a39fa5b3adcfdee00f1ddf0c3d18 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 18:58:15 +0000 Subject: [PATCH 080/314] add failing unit test for focus within tranfer of focus between roots. --- .../InputElement_Focus.cs | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs index b79ae92ef3..8b8f2fa775 100644 --- a/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs +++ b/tests/Avalonia.Input.UnitTests/InputElement_Focus.cs @@ -211,7 +211,7 @@ namespace Avalonia.Input.UnitTests } [Fact] - public void Control_FocusVsisible_Pseudoclass_Should_Be_Removed_When_Removed_From_Tree() + public void Control_FocusWithin_Pseudoclass_Should_Be_Removed_When_Removed_From_Tree() { using (UnitTestApplication.Start(TestServices.RealFocus)) { @@ -254,5 +254,69 @@ namespace Avalonia.Input.UnitTests Assert.False(root.IsKeyboardFocusWithin); } } + + [Fact] + public void Control_FocusWithin_Pseudoclass_Should_Be_Removed_Focus_Moves_To_Different_Root() + { + using (UnitTestApplication.Start(TestServices.RealFocus)) + { + var target1 = new Decorator(); + var target2 = new Decorator(); + + var root1 = new TestRoot + { + Child = new StackPanel + { + Children = + { + target1, + } + } + }; + + var root2 = new TestRoot + { + Child = new StackPanel + { + Children = + { + target2, + } + } + }; + + target1.ApplyTemplate(); + target2.ApplyTemplate(); + + FocusManager.Instance?.Focus(target1); + Assert.True(target1.IsFocused); + Assert.True(target1.Classes.Contains(":focus-within")); + Assert.True(target1.IsKeyboardFocusWithin); + Assert.True(root1.Child.Classes.Contains(":focus-within")); + Assert.True(root1.Child.IsKeyboardFocusWithin); + Assert.True(root1.Classes.Contains(":focus-within")); + Assert.True(root1.IsKeyboardFocusWithin); + + Assert.Equal(KeyboardDevice.Instance.FocusedElement, target1); + + FocusManager.Instance?.Focus(target2); + + Assert.False(target1.IsFocused); + Assert.False(target1.Classes.Contains(":focus-within")); + Assert.False(target1.IsKeyboardFocusWithin); + Assert.False(root1.Child.Classes.Contains(":focus-within")); + Assert.False(root1.Child.IsKeyboardFocusWithin); + Assert.False(root1.Classes.Contains(":focus-within")); + Assert.False(root1.IsKeyboardFocusWithin); + + Assert.True(target2.IsFocused); + Assert.True(target2.Classes.Contains(":focus-within")); + Assert.True(target2.IsKeyboardFocusWithin); + Assert.True(root2.Child.Classes.Contains(":focus-within")); + Assert.True(root2.Child.IsKeyboardFocusWithin); + Assert.True(root2.Classes.Contains(":focus-within")); + Assert.True(root2.IsKeyboardFocusWithin); + } + } } } From d36b7a40df223b7a3805dfb57dae9e01392fcfd1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 2 Nov 2020 19:02:54 +0000 Subject: [PATCH 081/314] ensure focus-within is removed when focus moves to a different root. --- src/Avalonia.Input/KeyboardDevice.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 1a161ae56a..6f4cb7a35c 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -147,7 +147,10 @@ namespace Avalonia.Input { var interactive = FocusedElement as IInteractive; - if (FocusedElement != null && !FocusedElement.IsAttachedToVisualTree && _focusedRoot != null) + if (FocusedElement != null && + (!FocusedElement.IsAttachedToVisualTree || + _focusedRoot != element?.VisualRoot as IInputRoot) && + _focusedRoot != null) { ClearChildrenFocusWithin(_focusedRoot, true); } From 5be046e5efa1a8c9b33a25cec8a4c6530a852123 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Tue, 3 Nov 2020 07:37:52 +0100 Subject: [PATCH 082/314] Fix TextDecoration location calculation --- src/Avalonia.Visuals/Media/TextDecoration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Visuals/Media/TextDecoration.cs b/src/Avalonia.Visuals/Media/TextDecoration.cs index d9b3f664ce..57936426f3 100644 --- a/src/Avalonia.Visuals/Media/TextDecoration.cs +++ b/src/Avalonia.Visuals/Media/TextDecoration.cs @@ -189,11 +189,11 @@ namespace Avalonia.Media break; case TextDecorationLocation.Strikethrough: origin += new Point(shapedTextCharacters.GlyphRun.BaselineOrigin.X, - shapedTextCharacters.GlyphRun.BaselineOrigin.Y - fontMetrics.StrikethroughPosition); + shapedTextCharacters.GlyphRun.BaselineOrigin.Y + fontMetrics.StrikethroughPosition); break; case TextDecorationLocation.Underline: origin += new Point(shapedTextCharacters.GlyphRun.BaselineOrigin.X, - shapedTextCharacters.GlyphRun.BaselineOrigin.Y - fontMetrics.UnderlinePosition); + shapedTextCharacters.GlyphRun.BaselineOrigin.Y + fontMetrics.UnderlinePosition); break; } From 760f13f0934f3192b147645606e5a72894ee3caf Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Wed, 4 Nov 2020 14:54:18 +0100 Subject: [PATCH 083/314] fixed null reference exception when using MultiBinding without StringFormat and Converter --- src/Markup/Avalonia.Markup/Data/MultiBinding.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs index 7aa1eed890..8b31f7b560 100644 --- a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs +++ b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs @@ -116,7 +116,8 @@ namespace Avalonia.Data } var culture = CultureInfo.CurrentCulture; - var converted = converter.Convert(values, targetType, ConverterParameter, culture); + var converted = converter?.Convert(values, targetType, ConverterParameter, culture) + ?? values.ToArray(); if (converted == null) { From 411b2278340dffa337715996ed9cc4f9a891ec96 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Wed, 4 Nov 2020 15:29:22 +0100 Subject: [PATCH 084/314] Adding test --- .../Data/MultiBindingTests.cs | 23 +++++++++++++++++++ .../Extensions/IEnummerableExtension.cs | 21 +++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs diff --git a/tests/Avalonia.Markup.UnitTests/Data/MultiBindingTests.cs b/tests/Avalonia.Markup.UnitTests/Data/MultiBindingTests.cs index 64f5eb2a0e..b87922aa1e 100644 --- a/tests/Avalonia.Markup.UnitTests/Data/MultiBindingTests.cs +++ b/tests/Avalonia.Markup.UnitTests/Data/MultiBindingTests.cs @@ -157,6 +157,29 @@ namespace Avalonia.Markup.UnitTests.Data Assert.Equal("1,2,Fallback", target.Text); } + [Fact] + public void MultiBinding_Without_StringFormat_And_Converter() + { + var source = new { A = 1, B = 2, C = 3 }; + var target = new ItemsControl { }; + + var binding = new MultiBinding + { + Bindings = new[] + { + new Binding { Path = "A", Source = source }, + new Binding { Path = "B", Source = source }, + new Binding { Path = "C", Source = source }, + }, + }; + + target.Bind(ItemsControl.ItemsProperty, binding); + Assert.Equal(target.ItemCount, 3); + Assert.Equal(target.Items.ElementAt(0), source.A); + Assert.Equal(target.Items.ElementAt(1), source.B); + Assert.Equal(target.Items.ElementAt(2), source.C); + } + private class ConcatConverter : IMultiValueConverter { public object Convert(IList values, Type targetType, object parameter, CultureInfo culture) diff --git a/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs b/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs new file mode 100644 index 0000000000..33be06baed --- /dev/null +++ b/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections; + +namespace Avalonia.Markup.UnitTests +{ + static class IEnummerableExtension + { + public static object ElementAt(this IEnumerable source, int index) + { + var i = -1; + var enumerator = source.GetEnumerator(); + + while (enumerator.MoveNext() && ++i < index); + if (i == index) + { + return enumerator.Current; + } + throw new ArgumentOutOfRangeException(nameof(index)); + } + } +} From 8ed53d47beb7194bfa8bb6a1df30f8b1bb2c0530 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Wed, 4 Nov 2020 16:14:29 +0100 Subject: [PATCH 085/314] fixes Should_Return_TargetNullValue_When_Value_Is_Null fails --- src/Markup/Avalonia.Markup/Data/MultiBinding.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs index 8b31f7b560..5bdb424f68 100644 --- a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs +++ b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs @@ -48,7 +48,7 @@ namespace Avalonia.Data /// Gets or sets the binding priority. /// public BindingPriority Priority { get; set; } - + /// /// Gets or sets the relative source for the binding. /// @@ -77,12 +77,12 @@ namespace Avalonia.Data // We only respect `StringFormat` if the type of the property we're assigning to will // accept a string. Note that this is slightly different to WPF in that WPF only applies // `StringFormat` for target type `string` (not `object`). - if (!string.IsNullOrWhiteSpace(StringFormat) && + if (!string.IsNullOrWhiteSpace(StringFormat) && (targetType == typeof(string) || targetType == typeof(object))) { converter = new StringFormatMultiValueConverter(StringFormat, converter); } - + var children = Bindings.Select(x => x.Initiate(target, null)); var input = children.Select(x => x.Observable) @@ -116,8 +116,13 @@ namespace Avalonia.Data } var culture = CultureInfo.CurrentCulture; - var converted = converter?.Convert(values, targetType, ConverterParameter, culture) - ?? values.ToArray(); + object converted; + if (converter != null) + { + converted = converter.Convert(values, targetType, ConverterParameter, culture); + } + else + converted = values.ToArray(); if (converted == null) { From dbd0e3648e024719fe080d43a1c66e40b08eb320 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 5 Nov 2020 10:06:20 +0100 Subject: [PATCH 086/314] fix code smell --- src/Markup/Avalonia.Markup/Data/MultiBinding.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs index 5bdb424f68..a48ac74f29 100644 --- a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs +++ b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs @@ -122,7 +122,9 @@ namespace Avalonia.Data converted = converter.Convert(values, targetType, ConverterParameter, culture); } else + { converted = values.ToArray(); + } if (converted == null) { From dd1941e6ec7d7bbf8af6fa429ebf5c72195765cf Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Thu, 5 Nov 2020 10:20:48 +0100 Subject: [PATCH 087/314] used ReadOnlyCollection instead of ToArray () --- src/Markup/Avalonia.Markup/Data/MultiBinding.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs index a48ac74f29..cbc5f414f2 100644 --- a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs +++ b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs @@ -116,6 +116,7 @@ namespace Avalonia.Data } var culture = CultureInfo.CurrentCulture; + values = new System.Collections.ObjectModel.ReadOnlyCollection(values); object converted; if (converter != null) { @@ -123,7 +124,7 @@ namespace Avalonia.Data } else { - converted = values.ToArray(); + converted = values; } if (converted == null) From 08d3b9154d83051e1decbee347a03cac5b508883 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 5 Nov 2020 14:40:59 +0300 Subject: [PATCH 088/314] Extract microcom generator stuff into a separate .targets file --- build/MicroCom.targets | 33 ++++++++++++++++++++++ src/Avalonia.Native/Avalonia.Native.csproj | 33 ++-------------------- 2 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 build/MicroCom.targets diff --git a/build/MicroCom.targets b/build/MicroCom.targets new file mode 100644 index 0000000000..3a07950616 --- /dev/null +++ b/build/MicroCom.targets @@ -0,0 +1,33 @@ + + + + + + false + all + true + + + + + + + + + + + + + + + + + + <_AvaloniaPatchComInterop>true + + + diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index a08dc0f28f..3913484431 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -20,36 +20,7 @@ + - - - - - false - all - true - - - - - - - - - - - - - - - - - - <_AvaloniaPatchComInterop>true - - + From 47d6ba61dd7014087d6195e628420fa922d25694 Mon Sep 17 00:00:00 2001 From: workgroupengineering Date: Thu, 5 Nov 2020 19:45:52 +0100 Subject: [PATCH 089/314] Update tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes code smell Co-authored-by: Dariusz Komosiński --- .../Extensions/IEnummerableExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs b/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs index 33be06baed..0d9e2969e1 100644 --- a/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs +++ b/tests/Avalonia.Markup.UnitTests/Extensions/IEnummerableExtension.cs @@ -3,7 +3,7 @@ using System.Collections; namespace Avalonia.Markup.UnitTests { - static class IEnummerableExtension + internal static class IEnumerableExtensions { public static object ElementAt(this IEnumerable source, int index) { From e32e092e4ee5be67e5327d697e3f9b3b8e8a372c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 5 Nov 2020 22:04:02 +0000 Subject: [PATCH 090/314] WinUI Comp tweak backdrop blur. --- .../Avalonia.Win32/Composition/CompositionConnector.cs | 6 +----- src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs b/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs index 5bdc0cd410..e0dfdf282c 100644 --- a/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs +++ b/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs @@ -127,17 +127,13 @@ namespace Avalonia.Win32 private SpriteVisual CreateBlur() { var blurEffect = new GaussianBlurEffect(new CompositionEffectSourceParameter("backdrop")); - var blurEffectFactory = _compositor.CreateEffectFactory(blurEffect); - var blurBrush = blurEffectFactory.CreateBrush(); var backDropBrush = _compositor.CreateBackdropBrush(); - blurBrush.SetSourceParameter("backdrop", backDropBrush); - var saturateEffect = new SaturationEffect(blurEffect); var satEffectFactory = _compositor.CreateEffectFactory(saturateEffect); - var satBrush = satEffectFactory.CreateBrush(); + satBrush.SetSourceParameter("backdrop", backDropBrush); var visual = _compositor.CreateSpriteVisual(); diff --git a/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs b/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs index 90eca22d8e..3495829f3a 100644 --- a/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs +++ b/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs @@ -6,7 +6,7 @@ namespace Avalonia.Win32 { class SaturationEffect : EffectBase { - public SaturationEffect(IGraphicsEffect source) : base(source) + public SaturationEffect(IGraphicsEffectSource source) : base(source) { } From b51ea7702f51b522dbf273ba9aaae3060f3857c5 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 01:42:02 +0300 Subject: [PATCH 091/314] Use MicroCom for WinRT interop --- build/MicroCom.targets | 4 +- samples/Sandbox/MainWindow.axaml.cs | 1 + src/Avalonia.MicroCom/MicroComProxyBase.cs | 2 +- src/Avalonia.MicroCom/MicroComRuntime.cs | 28 +- src/Avalonia.OpenGL/Egl/EglContext.cs | 8 + .../Avalonia.Win32/Avalonia.Win32.csproj | 4 +- .../Composition/CompositionBlurHost.cs | 18 - .../Composition/CompositionConnector.cs | 175 - .../CompositionEglGlPlatformSurface.cs | 96 - .../Avalonia.Win32/Composition/D2DEffects.cs | 91 - .../Avalonia.Win32/Composition/EffectBase.cs | 45 - .../GRAPHICS_EFFECT_PROPERTY_MAPPING.cs | 18 - .../Composition/GaussianBlurEffect.cs | 57 - .../Avalonia.Win32/Composition/IBlurHost.cs | 8 - .../ICompositionDrawingSurfaceInterop.cs | 152 - .../Composition/ICompositorDesktopInterop.cs | 14 - .../Composition/ICompositorDesktopInterop1.cs | 69 - .../Composition/ICompositorInterop.cs | 139 - .../Composition/IGraphicsEffectD2D1Interop.cs | 24 - .../IGraphicsEffectD2D1Interop1.cs | 217 - .../Composition/SaturationEffect.cs | 35 - .../Interop/UnmanagedMethods.cs | 9 + src/Windows/Avalonia.Win32/Win32GlManager.cs | 3 +- .../WinRT/Composition/D2DEffects.cs | 130 + .../Composition/WinUICompositedWindow.cs | 84 + .../Composition/WinUICompositorConnection.cs | 152 + .../WinRT/Composition/WinUIEffectBase.cs | 135 + .../WinUiCompositedWindowSurface.cs | 114 + src/Windows/Avalonia.Win32/WinRT/IBlurHost.cs | 7 + .../WinRT/NativeWinRTMethods.cs | 140 + .../Avalonia.Win32/WinRT/WinRT.Generated.cs | 8713 +++++++++++++++++ .../Avalonia.Win32/WinRT/WinRTColor.cs | 18 + .../Avalonia.Win32/WinRT/WinRTInspectable.cs | 38 + .../WinRT/WinRTPropertyValue.cs | 89 + src/Windows/Avalonia.Win32/WinRT/winrt.idl | 651 ++ src/Windows/Avalonia.Win32/WindowImpl.cs | 10 +- src/tools/MicroComGenerator/AstParser.cs | 7 +- .../CSharpGen.InterfaceGen.cs | 47 +- .../MicroComGenerator/CSharpGen.Utils.cs | 9 +- src/tools/MicroComGenerator/CSharpGen.cs | 20 +- 40 files changed, 10394 insertions(+), 1187 deletions(-) delete mode 100644 src/Windows/Avalonia.Win32/Composition/CompositionBlurHost.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/CompositionEglGlPlatformSurface.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/D2DEffects.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/EffectBase.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/IBlurHost.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs delete mode 100644 src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/Composition/D2DEffects.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/Composition/WinUIEffectBase.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/IBlurHost.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/NativeWinRTMethods.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/WinRTInspectable.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/WinRTPropertyValue.cs create mode 100644 src/Windows/Avalonia.Win32/WinRT/winrt.idl diff --git a/build/MicroCom.targets b/build/MicroCom.targets index 3a07950616..3577261738 100644 --- a/build/MicroCom.targets +++ b/build/MicroCom.targets @@ -15,7 +15,7 @@ Inputs="@(AvnComIdl);$(MSBuildThisFileDirectory)/../tools/MicroComGenerator/**/*.cs" Outputs="%(AvnComIdl.OutputFile)"> - + @@ -24,7 +24,7 @@ - + <_AvaloniaPatchComInterop>true diff --git a/samples/Sandbox/MainWindow.axaml.cs b/samples/Sandbox/MainWindow.axaml.cs index b7222e043d..3d54036d29 100644 --- a/samples/Sandbox/MainWindow.axaml.cs +++ b/samples/Sandbox/MainWindow.axaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using Avalonia.Win32.WinRT.Composition; namespace Sandbox { diff --git a/src/Avalonia.MicroCom/MicroComProxyBase.cs b/src/Avalonia.MicroCom/MicroComProxyBase.cs index 681e278104..140af3e4ef 100644 --- a/src/Avalonia.MicroCom/MicroComProxyBase.cs +++ b/src/Avalonia.MicroCom/MicroComProxyBase.cs @@ -56,7 +56,7 @@ namespace Avalonia.MicroCom { var guid = MicroComRuntime.GetGuidFor(typeof(T)); var rv = QueryInterface(guid, out var ppv); - if (rv != 0) + if (rv == 0) return (T)MicroComRuntime.CreateProxyFor(typeof(T), ppv, true); throw new COMException("QueryInterface failed", rv); } diff --git a/src/Avalonia.MicroCom/MicroComRuntime.cs b/src/Avalonia.MicroCom/MicroComRuntime.cs index 9d2c23f40a..85507674d2 100644 --- a/src/Avalonia.MicroCom/MicroComRuntime.cs +++ b/src/Avalonia.MicroCom/MicroComRuntime.cs @@ -38,13 +38,20 @@ namespace Avalonia.MicroCom public static T CreateProxyFor(IntPtr pObject, bool ownsHandle) => (T)CreateProxyFor(typeof(T), pObject, ownsHandle); public static object CreateProxyFor(Type type, IntPtr pObject, bool ownsHandle) => _factories[type](pObject, ownsHandle); - + + public static IntPtr GetNativeIntPtr(this T obj, bool owned = false) where T : IUnknown + => new IntPtr(GetNativePointer(obj, owned)); public static void* GetNativePointer(T obj, bool owned = false) where T : IUnknown { if (obj == null) return null; if (obj is MicroComProxyBase proxy) + { + if(owned) + proxy.AddRef(); return (void*)proxy.NativePointer; + } + if (obj is IMicroComShadowContainer container) { container.Shadow ??= new MicroComShadow(container); @@ -89,10 +96,27 @@ namespace Avalonia.MicroCom } - public static T CloneReference(T iface) where T : IUnknown + public static T CloneReference(this T iface) where T : IUnknown { + var proxy = (MicroComProxyBase)(object)iface; var ownedPointer = GetNativePointer(iface, true); return CreateProxyFor(ownedPointer, true); } + + public static T QueryInterface(this IUnknown unknown) where T : IUnknown + { + var proxy = (MicroComProxyBase)unknown; + return proxy.QueryInterface(); + } + + public static void UnsafeAddRef(this IUnknown unknown) + { + ((MicroComProxyBase)unknown).AddRef(); + } + + public static void UnsafeRelease(this IUnknown unknown) + { + ((MicroComProxyBase)unknown).Release(); + } } } diff --git a/src/Avalonia.OpenGL/Egl/EglContext.cs b/src/Avalonia.OpenGL/Egl/EglContext.cs index 249b4d547f..58137dfff0 100644 --- a/src/Avalonia.OpenGL/Egl/EglContext.cs +++ b/src/Avalonia.OpenGL/Egl/EglContext.cs @@ -93,6 +93,14 @@ namespace Avalonia.OpenGL.Egl return MakeCurrent(); } + public IDisposable EnsureLocked() + { + if (IsCurrent) + return Disposable.Empty; + Monitor.Enter(_lock); + return Disposable.Create(() => Monitor.Exit(_lock)); + } + public bool IsSharedWith(IGlContext context) { var c = (EglContext)context; diff --git a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj index 5889d919df..fe5f806fbe 100644 --- a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj +++ b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj @@ -5,9 +5,11 @@ Avalonia.Win32 + - + + diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionBlurHost.cs b/src/Windows/Avalonia.Win32/Composition/CompositionBlurHost.cs deleted file mode 100644 index 4c090e797c..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/CompositionBlurHost.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Avalonia.Win32 -{ - internal class CompositionBlurHost : IBlurHost - { - Windows.UI.Composition.Visual _blurVisual; - - public CompositionBlurHost(Windows.UI.Composition.Visual blurVisual) - { - _blurVisual = blurVisual; - } - - public void SetBlur(bool enabled) - { - _blurVisual.IsVisible = enabled; - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs b/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs deleted file mode 100644 index 5bdc0cd410..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/CompositionConnector.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Avalonia.Logging; -using Avalonia.OpenGL; -using Avalonia.OpenGL.Angle; -using Avalonia.OpenGL.Egl; -using Windows.UI.Composition; -using Windows.UI.Composition.Interop; -using WinRT; - -namespace Avalonia.Win32 -{ - internal class CompositionConnector - { - private Compositor _compositor; - private Windows.System.DispatcherQueueController _dispatcherQueueController; - private CompositionGraphicsDevice _graphicsDevice; - - internal enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE - { - DQTAT_COM_NONE = 0, - DQTAT_COM_ASTA = 1, - DQTAT_COM_STA = 2 - }; - - internal enum DISPATCHERQUEUE_THREAD_TYPE - { - DQTYPE_THREAD_DEDICATED = 1, - DQTYPE_THREAD_CURRENT = 2, - }; - - [StructLayout(LayoutKind.Sequential)] - internal struct DispatcherQueueOptions - { - public int dwSize; - - [MarshalAs(UnmanagedType.I4)] - public DISPATCHERQUEUE_THREAD_TYPE threadType; - - [MarshalAs(UnmanagedType.I4)] - public DISPATCHERQUEUE_THREAD_APARTMENTTYPE apartmentType; - }; - - [DllImport("coremessaging.dll", EntryPoint = "CreateDispatcherQueueController", CharSet = CharSet.Unicode)] - internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options, out IntPtr dispatcherQueueController); - - public static CompositionConnector TryCreate(EglPlatformOpenGlInterface egl) - { - const int majorRequired = 10; - const int buildRequired = 16299; - - var majorInstalled = Win32Platform.WindowsVersion.Major; - var buildInstalled = Win32Platform.WindowsVersion.Build; - - if (majorInstalled >= majorRequired && - buildInstalled >= buildRequired) - { - try - { - return new CompositionConnector(egl); - } - catch (Exception e) - { - Logger.TryGet(LogEventLevel.Error, "WinUIComposition")?.Log(null, "Unable to initialize WinUI compositor: {0}", e); - - return null; - } - } - - var osVersionNotice = $"Windows {majorRequired} Build {buildRequired} is required. Your machine has Windows {majorInstalled} Build {buildInstalled} installed."; - - Logger.TryGet(LogEventLevel.Warning, "WinUIComposition")?.Log(null, - $"Unable to initialize WinUI compositor: {osVersionNotice}"); - - return null; - } - - public CompositionConnector(EglPlatformOpenGlInterface egl) - { - EnsureDispatcherQueue(); - - if (_dispatcherQueueController != null) - _compositor = new Compositor(); - - var interop = _compositor.As(); - - var display = egl.Display as AngleWin32EglDisplay; - - _graphicsDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); - } - - public ICompositionDrawingSurfaceInterop InitialiseWindowCompositionTree(IntPtr hwnd, out Windows.UI.Composition.Visual surfaceVisual, out IBlurHost blurHost) - { - var target = CreateDesktopWindowTarget(hwnd); - - var surface = _graphicsDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0), - Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, - Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); - - var surfaceInterop = surface.As(); - - var brush = _compositor.CreateSurfaceBrush(surface); - var visual = _compositor.CreateSpriteVisual(); - - visual.Brush = brush; - visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1, 1); - - var container = _compositor.CreateContainerVisual(); - - target.Root = container; - - var blur = CreateBlur(); - - blurHost = new CompositionBlurHost(blur); - - container.Children.InsertAtTop(blur); - - container.Children.InsertAtTop(visual); - - visual.CompositeMode = CompositionCompositeMode.SourceOver; - - surfaceVisual = container; - - return surfaceInterop; - } - - private SpriteVisual CreateBlur() - { - var blurEffect = new GaussianBlurEffect(new CompositionEffectSourceParameter("backdrop")); - var blurEffectFactory = _compositor.CreateEffectFactory(blurEffect); - - var blurBrush = blurEffectFactory.CreateBrush(); - var backDropBrush = _compositor.CreateBackdropBrush(); - - blurBrush.SetSourceParameter("backdrop", backDropBrush); - - var saturateEffect = new SaturationEffect(blurEffect); - var satEffectFactory = _compositor.CreateEffectFactory(saturateEffect); - - var satBrush = satEffectFactory.CreateBrush(); - satBrush.SetSourceParameter("backdrop", backDropBrush); - - var visual = _compositor.CreateSpriteVisual(); - visual.IsVisible = false; - - visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); - visual.Brush = satBrush; - - return visual; - } - - private CompositionTarget CreateDesktopWindowTarget(IntPtr window) - { - var interop = _compositor.As(); - - interop.CreateDesktopWindowTarget(window, false, out var windowTarget); - return Windows.UI.Composition.Desktop.DesktopWindowTarget.FromAbi(windowTarget); - } - - private void EnsureDispatcherQueue() - { - if (_dispatcherQueueController == null) - { - DispatcherQueueOptions options = new DispatcherQueueOptions(); - options.apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE; - options.threadType = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT; - options.dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions)); - - CreateDispatcherQueueController(options, out var queue); - _dispatcherQueueController = Windows.System.DispatcherQueueController.FromAbi(queue); - } - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/CompositionEglGlPlatformSurface.cs b/src/Windows/Avalonia.Win32/Composition/CompositionEglGlPlatformSurface.cs deleted file mode 100644 index 441da93787..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/CompositionEglGlPlatformSurface.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Avalonia.OpenGL; -using Avalonia.OpenGL.Angle; -using Avalonia.OpenGL.Egl; -using Avalonia.OpenGL.Surfaces; -using Windows.UI.Composition.Interop; - -namespace Avalonia.Win32 -{ - internal class CompositionEglGlPlatformSurface : EglGlPlatformSurfaceBase - { - private EglPlatformOpenGlInterface _egl; - private readonly IEglWindowGlPlatformSurfaceInfo _info; - private ICompositionDrawingSurfaceInterop _surfaceInterop; - private Windows.UI.Composition.Visual _surface; - - public CompositionEglGlPlatformSurface(EglPlatformOpenGlInterface egl, IEglWindowGlPlatformSurfaceInfo info) : base() - { - _egl = egl; - _info = info; - } - - public IBlurHost AttachToCompositionTree(CompositionConnector connector, IntPtr hwnd) - { - using (_egl.PrimaryContext.MakeCurrent()) - { - _surfaceInterop = connector.InitialiseWindowCompositionTree(hwnd, out _surface, out var blurHost); - return blurHost; - } - } - - public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() - { - return new CompositionRenderTarget(_egl, _surface, _surfaceInterop, _info); - } - - class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase - { - private readonly EglPlatformOpenGlInterface _egl; - private readonly IEglWindowGlPlatformSurfaceInfo _info; - private PixelSize _currentSize; - private readonly ICompositionDrawingSurfaceInterop _surfaceInterop; - private static Guid s_Iid = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); - private Windows.UI.Composition.Visual _compositionVisual; - - public CompositionRenderTarget(EglPlatformOpenGlInterface egl, - Windows.UI.Composition.Visual compositionVisual, - ICompositionDrawingSurfaceInterop interopSurface, - IEglWindowGlPlatformSurfaceInfo info) - : base(egl) - { - _egl = egl; - _surfaceInterop = interopSurface; - _info = info; - _currentSize = info.Size; - _compositionVisual = compositionVisual; - - using (_egl.PrimaryContext.MakeCurrent()) - { - _surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); - } - - _compositionVisual.Size = new System.Numerics.Vector2(_info.Size.Width, _info.Size.Height); - } - - public override IGlPlatformSurfaceRenderingSession BeginDraw() - { - IntPtr texture; - EglSurface surface; - - using (_egl.PrimaryEglContext.EnsureCurrent()) - { - if (_info.Size != _currentSize) - { - _surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); - _compositionVisual.Size = new System.Numerics.Vector2(_info.Size.Width, _info.Size.Height); - _currentSize = _info.Size; - } - - var offset = new POINT(); - - _surfaceInterop.BeginDraw( - IntPtr.Zero, - ref s_Iid, - out texture, ref offset); - - surface = (_egl.Display as AngleWin32EglDisplay).WrapDirect3D11Texture(_egl, texture, offset.X, offset.Y, _info.Size.Width, _info.Size.Height); - } - - return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); Marshal.Release(texture); surface.Dispose(); }, true); - } - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs b/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs deleted file mode 100644 index 1c761ee082..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/D2DEffects.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; - - -namespace Avalonia.Win32 -{ - class D2DEffects - { - public static readonly Guid CLSID_D2D12DAffineTransform = new Guid(0x6AA97485, 0x6354, 0x4CFC, 0x90, 0x8C, 0xE4, 0xA7, 0x4F, 0x62, 0xC9, 0x6C); - - public static readonly Guid CLSID_D2D13DPerspectiveTransform = new Guid(0xC2844D0B, 0x3D86, 0x46E7, 0x85, 0xBA, 0x52, 0x6C, 0x92, 0x40, 0xF3, 0xFB); - - public static readonly Guid CLSID_D2D13DTransform = new Guid(0xE8467B04, 0xEC61, 0x4B8A, 0xB5, 0xDE, 0xD4, 0xD7, 0x3D, 0xEB, 0xEA, 0x5A); - - public static readonly Guid CLSID_D2D1ArithmeticComposite = new Guid(0xFC151437, 0x049A, 0x4784, 0xA2, 0x4A, 0xF1, 0xC4, 0xDA, 0xF2, 0x09, 0x87); - - public static readonly Guid CLSID_D2D1Atlas = new Guid(0x913E2BE4, 0xFDCF, 0x4FE2, 0xA5, 0xF0, 0x24, 0x54, 0xF1, 0x4F, 0xF4, 0x08); - - public static readonly Guid CLSID_D2D1BitmapSource = new Guid(0x5FB6C24D, 0xC6DD, 0x4231, 0x94, 0x4, 0x50, 0xF4, 0xD5, 0xC3, 0x25, 0x2D); - - public static readonly Guid CLSID_D2D1Blend = new Guid(0x81C5B77B, 0x13F8, 0x4CDD, 0xAD, 0x20, 0xC8, 0x90, 0x54, 0x7A, 0xC6, 0x5D); - - public static readonly Guid CLSID_D2D1Border = new Guid(0x2A2D49C0, 0x4ACF, 0x43C7, 0x8C, 0x6A, 0x7C, 0x4A, 0x27, 0x87, 0x4D, 0x27); - - public static readonly Guid CLSID_D2D1Brightness = new Guid(0x8CEA8D1E, 0x77B0, 0x4986, 0xB3, 0xB9, 0x2F, 0x0C, 0x0E, 0xAE, 0x78, 0x87); - - public static readonly Guid CLSID_D2D1ColorManagement = new Guid(0x1A28524C, 0xFDD6, 0x4AA4, 0xAE, 0x8F, 0x83, 0x7E, 0xB8, 0x26, 0x7B, 0x37); - - public static readonly Guid CLSID_D2D1ColorMatrix = new Guid(0x921F03D6, 0x641C, 0x47DF, 0x85, 0x2D, 0xB4, 0xBB, 0x61, 0x53, 0xAE, 0x11); - - public static readonly Guid CLSID_D2D1Composite = new Guid(0x48FC9F51, 0xF6AC, 0x48F1, 0x8B, 0x58, 0x3B, 0x28, 0xAC, 0x46, 0xF7, 0x6D); - - public static readonly Guid CLSID_D2D1ConvolveMatrix = new Guid(0x407F8C08, 0x5533, 0x4331, 0xA3, 0x41, 0x23, 0xCC, 0x38, 0x77, 0x84, 0x3E); - - public static readonly Guid CLSID_D2D1Crop = new Guid(0xE23F7110, 0x0E9A, 0x4324, 0xAF, 0x47, 0x6A, 0x2C, 0x0C, 0x46, 0xF3, 0x5B); - - public static readonly Guid CLSID_D2D1DirectionalBlur = new Guid(0x174319A6, 0x58E9, 0x49B2, 0xBB, 0x63, 0xCA, 0xF2, 0xC8, 0x11, 0xA3, 0xDB); - - public static readonly Guid CLSID_D2D1DiscreteTransfer = new Guid(0x90866FCD, 0x488E, 0x454B, 0xAF, 0x06, 0xE5, 0x04, 0x1B, 0x66, 0xC3, 0x6C); - - public static readonly Guid CLSID_D2D1DisplacementMap = new Guid(0xEDC48364, 0x417, 0x4111, 0x94, 0x50, 0x43, 0x84, 0x5F, 0xA9, 0xF8, 0x90); - - public static readonly Guid CLSID_D2D1DistantDiffuse = new Guid(0x3E7EFD62, 0xA32D, 0x46D4, 0xA8, 0x3C, 0x52, 0x78, 0x88, 0x9A, 0xC9, 0x54); - - public static readonly Guid CLSID_D2D1DistantSpecular = new Guid(0x428C1EE5, 0x77B8, 0x4450, 0x8A, 0xB5, 0x72, 0x21, 0x9C, 0x21, 0xAB, 0xDA); - - public static readonly Guid CLSID_D2D1DpiCompensation = new Guid(0x6C26C5C7, 0x34E0, 0x46FC, 0x9C, 0xFD, 0xE5, 0x82, 0x37, 0x6, 0xE2, 0x28); - - public static readonly Guid CLSID_D2D1Flood = new Guid(0x61C23C20, 0xAE69, 0x4D8E, 0x94, 0xCF, 0x50, 0x07, 0x8D, 0xF6, 0x38, 0xF2); - - public static readonly Guid CLSID_D2D1GammaTransfer = new Guid(0x409444C4, 0xC419, 0x41A0, 0xB0, 0xC1, 0x8C, 0xD0, 0xC0, 0xA1, 0x8E, 0x42); - - public static readonly Guid CLSID_D2D1GaussianBlur = new Guid(0x1FEB6D69, 0x2FE6, 0x4AC9, 0x8C, 0x58, 0x1D, 0x7F, 0x93, 0xE7, 0xA6, 0xA5); - - public static readonly Guid CLSID_D2D1Scale = new Guid(0x9DAF9369, 0x3846, 0x4D0E, 0xA4, 0x4E, 0xC, 0x60, 0x79, 0x34, 0xA5, 0xD7); - - public static readonly Guid CLSID_D2D1Histogram = new Guid(0x881DB7D0, 0xF7EE, 0x4D4D, 0xA6, 0xD2, 0x46, 0x97, 0xAC, 0xC6, 0x6E, 0xE8); - - public static readonly Guid CLSID_D2D1HueRotation = new Guid(0x0F4458EC, 0x4B32, 0x491B, 0x9E, 0x85, 0xBD, 0x73, 0xF4, 0x4D, 0x3E, 0xB6); - - public static readonly Guid CLSID_D2D1LinearTransfer = new Guid(0xAD47C8FD, 0x63EF, 0x4ACC, 0x9B, 0x51, 0x67, 0x97, 0x9C, 0x03, 0x6C, 0x06); - - public static readonly Guid CLSID_D2D1LuminanceToAlpha = new Guid(0x41251AB7, 0x0BEB, 0x46F8, 0x9D, 0xA7, 0x59, 0xE9, 0x3F, 0xCC, 0xE5, 0xDE); - - public static readonly Guid CLSID_D2D1Morphology = new Guid(0xEAE6C40D, 0x626A, 0x4C2D, 0xBF, 0xCB, 0x39, 0x10, 0x01, 0xAB, 0xE2, 0x02); - - public static readonly Guid CLSID_D2D1OpacityMetadata = new Guid(0x6C53006A, 0x4450, 0x4199, 0xAA, 0x5B, 0xAD, 0x16, 0x56, 0xFE, 0xCE, 0x5E); - - public static readonly Guid CLSID_D2D1PointDiffuse = new Guid(0xB9E303C3, 0xC08C, 0x4F91, 0x8B, 0x7B, 0x38, 0x65, 0x6B, 0xC4, 0x8C, 0x20); - - public static readonly Guid CLSID_D2D1PointSpecular = new Guid(0x09C3CA26, 0x3AE2, 0x4F09, 0x9E, 0xBC, 0xED, 0x38, 0x65, 0xD5, 0x3F, 0x22); - - public static readonly Guid CLSID_D2D1Premultiply = new Guid(0x06EAB419, 0xDEED, 0x4018, 0x80, 0xD2, 0x3E, 0x1D, 0x47, 0x1A, 0xDE, 0xB2); - - public static readonly Guid CLSID_D2D1Saturation = new Guid(0x5CB2D9CF, 0x327D, 0x459F, 0xA0, 0xCE, 0x40, 0xC0, 0xB2, 0x08, 0x6B, 0xF7); - - public static readonly Guid CLSID_D2D1Shadow = new Guid(0xC67EA361, 0x1863, 0x4E69, 0x89, 0xDB, 0x69, 0x5D, 0x3E, 0x9A, 0x5B, 0x6B); - - public static readonly Guid CLSID_D2D1SpotDiffuse = new Guid(0x818A1105, 0x7932, 0x44F4, 0xAA, 0x86, 0x08, 0xAE, 0x7B, 0x2F, 0x2C, 0x93); - - public static readonly Guid CLSID_D2D1SpotSpecular = new Guid(0xEDAE421E, 0x7654, 0x4A37, 0x9D, 0xB8, 0x71, 0xAC, 0xC1, 0xBE, 0xB3, 0xC1); - - public static readonly Guid CLSID_D2D1TableTransfer = new Guid(0x5BF818C3, 0x5E43, 0x48CB, 0xB6, 0x31, 0x86, 0x83, 0x96, 0xD6, 0xA1, 0xD4); - - public static readonly Guid CLSID_D2D1Tile = new Guid(0xB0784138, 0x3B76, 0x4BC5, 0xB1, 0x3B, 0x0F, 0xA2, 0xAD, 0x02, 0x65, 0x9F); - - public static readonly Guid CLSID_D2D1Turbulence = new Guid(0xCF2BB6AE, 0x889A, 0x4AD7, 0xBA, 0x29, 0xA2, 0xFD, 0x73, 0x2C, 0x9F, 0xC9); - - public static readonly Guid CLSID_D2D1UnPremultiply = new Guid(0xFB9AC489, 0xAD8D, 0x41ED, 0x99, 0x99, 0xBB, 0x63, 0x47, 0xD1, 0x10, 0xF7); - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/EffectBase.cs b/src/Windows/Avalonia.Win32/Composition/EffectBase.cs deleted file mode 100644 index ca5b15971e..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/EffectBase.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using Windows.Graphics.Effects; -using Windows.Graphics.Effects.Interop; - - -namespace Avalonia.Win32 -{ - abstract class EffectBase : IGraphicsEffect, IGraphicsEffectSource, global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop - { - private IGraphicsEffectSource[] _sources; - - public EffectBase(params IGraphicsEffectSource[] sources) - { - _sources = sources; - } - - private IGraphicsEffectSource _source; - - public virtual string Name { get; set; } - - public abstract Guid EffectId { get; } - - public abstract uint PropertyCount { get; } - - public uint SourceCount => (uint)_sources.Length; - - public IGraphicsEffectSource GetSource(uint index) - { - if(index < _sources.Length) - { - return _sources[index]; - } - - return null; - } - - public uint GetNamedPropertyMapping(string name, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) - { - throw new NotImplementedException(); - } - - public abstract object GetProperty(uint index); - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs b/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs deleted file mode 100644 index f5d5fc4ad3..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/GRAPHICS_EFFECT_PROPERTY_MAPPING.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Windows.Graphics.Effects.Interop -{ - public enum GRAPHICS_EFFECT_PROPERTY_MAPPING - { - GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, - GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, - GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, - GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 - }; -} - diff --git a/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs b/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs deleted file mode 100644 index 342e68eeb4..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/GaussianBlurEffect.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Windows.Graphics.Effects; - -namespace Avalonia.Win32 -{ - class GaussianBlurEffect : EffectBase - { - public GaussianBlurEffect(IGraphicsEffectSource source) : base(source) - { - } - - enum D2D1_GAUSSIANBLUR_OPTIMIZATION - { - D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED, - D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED, - D2D1_GAUSSIANBLUR_OPTIMIZATION_QUALITY, - D2D1_GAUSSIANBLUR_OPTIMIZATION_FORCE_DWORD - }; - - enum D2D1_BORDER_MODE - { - D2D1_BORDER_MODE_SOFT, - D2D1_BORDER_MODE_HARD, - D2D1_BORDER_MODE_FORCE_DWORD - }; - - enum D2D1GaussianBlurProp - { - D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, - D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION, - D2D1_GAUSSIANBLUR_PROP_BORDER_MODE, - D2D1_GAUSSIANBLUR_PROP_FORCE_DWORD - }; - - public override Guid EffectId => D2DEffects.CLSID_D2D1GaussianBlur; - - public override uint PropertyCount => 3; - - public override object GetProperty(uint index) - { - switch ((D2D1GaussianBlurProp)index) - { - case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION: - return 30.0f; - - case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION: - return (uint)D2D1_GAUSSIANBLUR_OPTIMIZATION.D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED; - - case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_BORDER_MODE: - return (uint)D2D1_BORDER_MODE.D2D1_BORDER_MODE_HARD; - } - - return null; - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/IBlurHost.cs b/src/Windows/Avalonia.Win32/Composition/IBlurHost.cs deleted file mode 100644 index 6ab470d81c..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/IBlurHost.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Avalonia.Win32 -{ - internal interface IBlurHost - { - void SetBlur(bool enabled); - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs deleted file mode 100644 index 2eac796376..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/ICompositionDrawingSurfaceInterop.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using WinRT; - -namespace Windows.UI.Composition.Interop -{ - public struct POINT - { - public int X; - public int Y; - } - - public struct RECT - { - public int left; - public int top; - public int right; - public int bottom; - - public int Width => right - left; - public int Height => bottom - top; - } - - [WindowsRuntimeType] - [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] - public interface ICompositionDrawingSurfaceInterop - { - void BeginDraw(IntPtr updateRect, ref Guid iid, out IntPtr updateObject, ref POINT point); - - void EndDraw(); - - void Resize(POINT sizePixels); - - void ResumeDraw(); - - void Scroll(RECT scrollRect, RECT clipRect, int offsetX, int offsetY); - - void SuspendDraw(); - } -} - -namespace ABI.Windows.UI.Composition.Interop -{ - using global::System; - using global::System.Runtime.InteropServices; - using global::Windows.UI.Composition; - using global::Windows.UI.Composition.Interop; - - [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] - internal class ICompositionDrawingSurfaceInterop : global::Windows.UI.Composition.Interop.ICompositionDrawingSurfaceInterop - - { - [Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE")] - public unsafe struct Vftbl - { - public delegate int _BeginDraw(IntPtr ThisPtr, IntPtr updateRect, ref Guid iid, out IntPtr updateObject, ref POINT updateOffset); - public delegate int _EndDraw(IntPtr ThisPtr); - public delegate int _Resize(IntPtr ThisPtr, POINT sizePixels); - public delegate int _ResumeDraw(IntPtr ThisPtr); - public delegate int _Scroll(IntPtr ThisPtr, RECT scrollRect, RECT clipRect, int offsetX, int offsetY); - public delegate int _SuspendDraw(IntPtr ThisPtr); - - internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; - public _BeginDraw BeginDraw; - public _EndDraw EndDraw; - public _Resize Resize; - public _ResumeDraw ResumeDraw; - public _Scroll Scroll; - public _SuspendDraw SuspendDraw; - - public static readonly Vftbl AbiToProjectionVftable; - public static readonly IntPtr AbiToProjectionVftablePtr; - - static Vftbl() - { - AbiToProjectionVftable = new Vftbl - { - IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, - - BeginDraw = Do_Abi_BeginDraw, - EndDraw = Do_Abi_EndDraw, - Resize = Do_Abi_Resize - - - }; - AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); - Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); - } - - private static int Do_Abi_BeginDraw(IntPtr ThisPtr, IntPtr updateRect, ref Guid iid, out IntPtr updateObject, ref POINT updateOffset) - { - updateObject = IntPtr.Zero; - return 0; - } - - private static int Do_Abi_EndDraw(IntPtr ThisPtr) - { - return 0; - } - - private static int Do_Abi_Resize(IntPtr ThisPtr, POINT sizePixels) - { - return 0; - } - } - internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); - - public static implicit operator ICompositionDrawingSurfaceInterop(IObjectReference obj) => (obj != null) ? new ICompositionDrawingSurfaceInterop(obj) : null; - protected readonly ObjectReference _obj; - public IObjectReference ObjRef { get => _obj; } - public IntPtr ThisPtr => _obj.ThisPtr; - public ObjectReference AsInterface() => _obj.As(); - public A As() => _obj.AsType(); - - public ICompositionDrawingSurfaceInterop(IObjectReference obj) : this(obj.As()) { } - internal ICompositionDrawingSurfaceInterop(ObjectReference obj) - { - _obj = obj; - } - - public void BeginDraw(IntPtr updateRect, ref Guid iid, out IntPtr updateObject, ref POINT point) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.BeginDraw(ThisPtr, updateRect, ref iid, out updateObject, ref point)); - } - - public void EndDraw() - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.EndDraw(ThisPtr)); - } - - public void Resize(POINT sizePixels) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.Resize(ThisPtr, sizePixels)); - } - - public void ResumeDraw() - { - throw new NotImplementedException(); - } - - public void Scroll(RECT scrollRect, RECT clipRect, int offsetX, int offsetY) - { - throw new NotImplementedException(); - } - - public void SuspendDraw() - { - throw new NotImplementedException(); - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs deleted file mode 100644 index 1d4cd3450f..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using WinRT; - -namespace Windows.UI.Composition.Desktop -{ - [WindowsRuntimeType] - [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] - public interface ICompositorDesktopInterop - { - void CreateDesktopWindowTarget(IntPtr hwndTarget, bool isTopmost, out IntPtr test); - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs deleted file mode 100644 index 1c3f06d679..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/ICompositorDesktopInterop1.cs +++ /dev/null @@ -1,69 +0,0 @@ -using WinRT; - -namespace ABI.Windows.UI.Composition.Desktop -{ - using global::System; - using global::System.Runtime.InteropServices; - - [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] - internal class ICompositorDesktopInterop : global::Windows.UI.Composition.Desktop.ICompositorDesktopInterop - - { - [Guid("29E691FA-4567-4DCA-B319-D0F207EB6807")] - public struct Vftbl - { - public delegate int _CreateDesktopWindowTarget(IntPtr thisPtr, IntPtr hwndTarget, byte isTopMost, out IntPtr desktopWindowTarget); - - internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; - public _CreateDesktopWindowTarget CreateDesktopWindowTarget; - - - public static readonly Vftbl AbiToProjectionVftable; - public static readonly IntPtr AbiToProjectionVftablePtr; - - static Vftbl() - { - AbiToProjectionVftable = new Vftbl - { - IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, - CreateDesktopWindowTarget = Do_Abi_Create_Desktop_Window_Target - }; - AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); - Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); - } - - private static int Do_Abi_Create_Desktop_Window_Target(IntPtr thisPtr, IntPtr hwndTarget, byte isTopMost, out IntPtr desktopWindowTarget) - { - try - { - ComWrappersSupport.FindObject(thisPtr).CreateDesktopWindowTarget(hwndTarget, isTopMost != 0, out desktopWindowTarget); - return 0; - } - catch (Exception ex) - { - desktopWindowTarget = IntPtr.Zero; - return Marshal.GetHRForException(ex); - } - } - } - internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); - - public static implicit operator ICompositorDesktopInterop(IObjectReference obj) => (obj != null) ? new ICompositorDesktopInterop(obj) : null; - protected readonly ObjectReference _obj; - public IObjectReference ObjRef { get => _obj; } - public IntPtr ThisPtr => _obj.ThisPtr; - public ObjectReference AsInterface() => _obj.As(); - public A As() => _obj.AsType(); - public ICompositorDesktopInterop(IObjectReference obj) : this(obj.As()) { } - internal ICompositorDesktopInterop(ObjectReference obj) - { - _obj = obj; - } - - public void CreateDesktopWindowTarget(IntPtr hwndTarget, bool isTopmost, out IntPtr test) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateDesktopWindowTarget(ThisPtr, hwndTarget, isTopmost ? (byte)1 : (byte)0, out test)); - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs b/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs deleted file mode 100644 index d9b25e497e..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/ICompositorInterop.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using WinRT; - -namespace Windows.UI.Composition.Interop -{ - [WindowsRuntimeType] - [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] - public interface ICompositorInterop - { - ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain); - - ICompositionSurface CreateCompositionSurfaceForSwapChain(IntPtr swapChain); - - CompositionGraphicsDevice CreateGraphicsDevice(IntPtr renderingDevice); - } -} - -namespace ABI.Windows.UI.Composition.Interop -{ - using global::System; - using global::System.Runtime.InteropServices; - using global::Windows.UI.Composition; - - [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] - internal class ICompositorInterop : global::Windows.UI.Composition.Interop.ICompositorInterop - - { - [Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330")] - public struct Vftbl - { - public delegate int _CreateCompositionSurfaceForHandle(IntPtr ThisPtr, IntPtr swapChain, out IntPtr result); - public delegate int _CreateCompositionSurfaceForSwapChain(IntPtr ThisPtr, IntPtr swapChain, out IntPtr result); - public delegate int _CreateGraphicsDevice(IntPtr ThisPtr, IntPtr renderingDevice, out IntPtr result); - - internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; - public _CreateCompositionSurfaceForHandle CreateCompositionSurfaceForHandle; - public _CreateCompositionSurfaceForSwapChain CreateCompositionSurfaceForSwapChain; - public _CreateGraphicsDevice CreateGraphicsDevice; - - - public static readonly Vftbl AbiToProjectionVftable; - public static readonly IntPtr AbiToProjectionVftablePtr; - - static Vftbl() - { - AbiToProjectionVftable = new Vftbl - { - IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, - - CreateCompositionSurfaceForHandle = Do_Abi_Create_Composition_Surface_For_Handle, - CreateCompositionSurfaceForSwapChain = Do_Abi_Create_Composition_Surface_For_SwapChain, - CreateGraphicsDevice= Do_Abi_Create_Graphics_Device - }; - AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); - Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); - } - - private static int Do_Abi_Create_Composition_Surface_For_Handle(IntPtr thisPtr, IntPtr swapChain, out IntPtr surface) - { - try - { - surface = IntPtr.Zero; - //surface = ComWrappersSupport.FindObject(thisPtr).CreateCompositionSurfaceForHandle(swapChain); - return 0; - } - catch (Exception ex) - { - surface = IntPtr.Zero; - return Marshal.GetHRForException(ex); - } - } - - private static int Do_Abi_Create_Composition_Surface_For_SwapChain(IntPtr thisPtr, IntPtr swapChain, out IntPtr surface) - { - try - { - surface = IntPtr.Zero; - //surface = ComWrappersSupport.FindObject(thisPtr).CreateCompositionSurfaceForSwapChain(swapChain); - return 0; - } - catch (Exception ex) - { - surface = IntPtr.Zero; - return Marshal.GetHRForException(ex); - } - } - - private static int Do_Abi_Create_Graphics_Device(IntPtr thisPtr, IntPtr renderingDevice, out IntPtr graphicsDevice) - { - try - { - graphicsDevice = ComWrappersSupport.FindObject(thisPtr).CreateGraphicsDevice(renderingDevice).ThisPtr; - return 0; - } - catch (Exception ex) - { - graphicsDevice = IntPtr.Zero; - return Marshal.GetHRForException(ex); - } - } - } - internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); - - public static implicit operator ICompositorInterop(IObjectReference obj) => (obj != null) ? new ICompositorInterop(obj) : null; - protected readonly ObjectReference _obj; - public IObjectReference ObjRef { get => _obj; } - public IntPtr ThisPtr => _obj.ThisPtr; - public ObjectReference AsInterface() => _obj.As(); - public A As() => _obj.AsType(); - public ICompositorInterop(IObjectReference obj) : this(obj.As()) { } - internal ICompositorInterop(ObjectReference obj) - { - _obj = obj; - } - - public ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateCompositionSurfaceForHandle(ThisPtr, swapChain, out var compositionSurface)); - - return null; - } - - public ICompositionSurface CreateCompositionSurfaceForSwapChain(IntPtr swapChain) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateCompositionSurfaceForSwapChain(ThisPtr, swapChain, out var compositionSurface)); - - return null; - } - - public CompositionGraphicsDevice CreateGraphicsDevice(IntPtr renderingDevice) - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.CreateGraphicsDevice(ThisPtr, renderingDevice, out var graphicsDevice)); - - return CompositionGraphicsDevice.FromAbi(graphicsDevice); - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs deleted file mode 100644 index 74d3939a98..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using WinRT; - -namespace Windows.Graphics.Effects.Interop -{ - [WindowsRuntimeType] - [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] - public interface IGraphicsEffectD2D1Interop - { - Guid EffectId { get; } - - uint GetNamedPropertyMapping(string name, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping); - - object GetProperty(uint index); - - uint PropertyCount { get; } - - IGraphicsEffectSource GetSource(uint index); - - uint SourceCount { get; } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs b/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs deleted file mode 100644 index 8466b05fb5..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/IGraphicsEffectD2D1Interop1.cs +++ /dev/null @@ -1,217 +0,0 @@ -using WinRT; - -namespace ABI.Windows.Graphics.Effects.Interop -{ - using global::System; - using global::System.Runtime.InteropServices; - - [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] - internal class IGraphicsEffectD2D1Interop : global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop - - { - [Guid("2FC57384-A068-44D7-A331-30982FCF7177")] - public struct Vftbl - { - public delegate int _GetEffectId(IntPtr thisPtr, out Guid guid); - public delegate int _GetNamedPropertyMapping(IntPtr thisPtr, IntPtr name, IntPtr index, IntPtr mapping); - public delegate int _GetProperty(IntPtr thisPtr, uint index, out IntPtr value); - public unsafe delegate int _GetPropertyCount(IntPtr thisPtr, uint* count); - public delegate int _GetSource(IntPtr thisPtr, uint index, out IntPtr source); - public delegate int _GetSourceCount(IntPtr thisPtr, out uint count); - - internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; - public _GetEffectId GetEffectId; - public _GetNamedPropertyMapping GetNamedPropertyMapping; - public _GetPropertyCount GetPropertyCount; - public _GetProperty GetProperty; - public _GetSource GetSource; - public _GetSourceCount GetSourceCount; - - public static readonly Vftbl AbiToProjectionVftable; - public static readonly IntPtr AbiToProjectionVftablePtr; - - unsafe static Vftbl() - { - AbiToProjectionVftable = new Vftbl - { - IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, - GetEffectId = Do_Abi_Get_Effect_Id, - GetNamedPropertyMapping = Do_Abi_Get_Property_Mapping, - GetPropertyCount = Do_Abi_Get_Property_Count, - GetProperty = Do_Abi_Get_Property, - GetSource = Do_Abi_Get_Source, - GetSourceCount = Do_Abi_Get_Source_Count - - }; - AbiToProjectionVftablePtr = Marshal.AllocHGlobal(Marshal.SizeOf()); - Marshal.StructureToPtr(AbiToProjectionVftable, AbiToProjectionVftablePtr, false); - } - - private static int Do_Abi_Get_Effect_Id(IntPtr thisPtr, out Guid guid) - { - guid = default; - - try - { - guid = ComWrappersSupport.FindObject(thisPtr).EffectId; - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - - private static int Do_Abi_Get_Property_Mapping(IntPtr thisPtr, IntPtr name, IntPtr index, IntPtr mapping) - { - try - { - ComWrappersSupport.FindObject(thisPtr).GetNamedPropertyMapping(MarshalString.FromAbi(name), out var mappingResult); - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - - private static int Do_Abi_Get_Property(IntPtr thisPtr, uint index, out IntPtr value) - { - value = default; - - try - { - value = MarshalInspectable.CreateMarshaler( - ComWrappersSupport.FindObject(thisPtr).GetProperty(index)) - .As(Guid.Parse("4BD682DD-7554-40E9-9A9B-82654EDE7E62")) - .GetRef(); - - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - - unsafe private static int Do_Abi_Get_Property_Count(IntPtr thisPtr, uint* count) - { - - try - { - var res = ComWrappersSupport.FindObject(thisPtr).PropertyCount; - - if (count != null) - { - *count = res; - } - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - - private static int Do_Abi_Get_Source(IntPtr thisPtr, uint index, out IntPtr value) - { - value = default; - - try - { - var source = ComWrappersSupport.FindObject(thisPtr).GetSource(index); - - value = MarshalInterface.FromManaged(source); - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - - private static int Do_Abi_Get_Source_Count(IntPtr thisPtr, out uint count) - { - count = default; - - try - { - count = ComWrappersSupport.FindObject(thisPtr).SourceCount; - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return 0; - } - } - internal static ObjectReference FromAbi(IntPtr thisPtr) => ObjectReference.FromAbi(thisPtr); - - public static implicit operator IGraphicsEffectD2D1Interop(IObjectReference obj) => (obj != null) ? new IGraphicsEffectD2D1Interop(obj) : null; - protected readonly ObjectReference _obj; - public IObjectReference ObjRef { get => _obj; } - public IntPtr ThisPtr => _obj.ThisPtr; - - public ObjectReference AsInterface() => _obj.As(); - public A As() => _obj.AsType(); - public IGraphicsEffectD2D1Interop(IObjectReference obj) : this(obj.As()) { } - internal IGraphicsEffectD2D1Interop(ObjectReference obj) - { - _obj = obj; - } - - public Guid EffectId - { - get - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.GetEffectId(ThisPtr, out Guid guid)); - return guid; - } - } - - public uint PropertyCount - { - get - { - unsafe - { - uint count = default; - Marshal.ThrowExceptionForHR(_obj.Vftbl.GetPropertyCount(ThisPtr, &count)); - return count; - } - } - } - - public uint SourceCount - { - get - { - Marshal.ThrowExceptionForHR(_obj.Vftbl.GetSourceCount(ThisPtr, out uint count)); - return count; - } - } - - public uint GetNamedPropertyMapping(string name, out global::Windows.Graphics.Effects.Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) - { - throw new NotImplementedException(); - } - - public object GetProperty(uint index) - { - // Marshal.ThrowExceptionForHR(_obj.Vftbl.GetProperty(ThisPtr, index, out IntPtr value)); - throw new NotImplementedException(); - } - - public global::Windows.Graphics.Effects.IGraphicsEffectSource GetSource(uint index) - { - throw new NotImplementedException(); - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs b/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs deleted file mode 100644 index 90eca22d8e..0000000000 --- a/src/Windows/Avalonia.Win32/Composition/SaturationEffect.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using Windows.Graphics.Effects; - - -namespace Avalonia.Win32 -{ - class SaturationEffect : EffectBase - { - public SaturationEffect(IGraphicsEffect source) : base(source) - { - } - - enum D2D1_SATURATION_PROP - { - D2D1_SATURATION_PROP_SATURATION, - D2D1_SATURATION_PROP_FORCE_DWORD - }; - - public override Guid EffectId => D2DEffects.CLSID_D2D1Saturation; - - public override uint PropertyCount => 1; - - public override object GetProperty(uint index) - { - switch ((D2D1_SATURATION_PROP)index) - { - case D2D1_SATURATION_PROP.D2D1_SATURATION_PROP_SATURATION: - return 2.0f; - } - - return null; - } - } -} - diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index f88c57cf59..af1692302a 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -1225,6 +1225,9 @@ namespace Avalonia.Win32.Interop [DllImport("kernel32.dll", SetLastError = true)] public static extern IntPtr LoadLibrary(string fileName); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, int flags); [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)] public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); @@ -1613,6 +1616,12 @@ namespace Avalonia.Win32.Interop public int X; public int Y; } + + public struct SIZE + { + public int X; + public int Y; + } public struct RECT { diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs index 4363b5fd29..e79d9bbde7 100644 --- a/src/Windows/Avalonia.Win32/Win32GlManager.cs +++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs @@ -3,6 +3,7 @@ using Avalonia.OpenGL; using Avalonia.OpenGL.Angle; using Avalonia.OpenGL.Egl; using Avalonia.Win32.OpenGl; +using Avalonia.Win32.WinRT.Composition; namespace Avalonia.Win32 { @@ -26,7 +27,7 @@ namespace Avalonia.Win32 if (egl is { } && opts?.UseWindowsUIComposition == true) { - var compositionConnector = CompositionConnector.TryCreate(egl); + var compositionConnector = WinUICompositorConnection.TryCreate(egl); if (compositionConnector != null) AvaloniaLocator.CurrentMutable.BindToSelf(compositionConnector); diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/D2DEffects.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/D2DEffects.cs new file mode 100644 index 0000000000..bef5a55b06 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/D2DEffects.cs @@ -0,0 +1,130 @@ +using System; + +namespace Avalonia.Win32.WinRT.Composition +{ + class D2DEffects + { + public static readonly Guid CLSID_D2D12DAffineTransform = + new Guid(0x6AA97485, 0x6354, 0x4CFC, 0x90, 0x8C, 0xE4, 0xA7, 0x4F, 0x62, 0xC9, 0x6C); + + public static readonly Guid CLSID_D2D13DPerspectiveTransform = + new Guid(0xC2844D0B, 0x3D86, 0x46E7, 0x85, 0xBA, 0x52, 0x6C, 0x92, 0x40, 0xF3, 0xFB); + + public static readonly Guid CLSID_D2D13DTransform = + new Guid(0xE8467B04, 0xEC61, 0x4B8A, 0xB5, 0xDE, 0xD4, 0xD7, 0x3D, 0xEB, 0xEA, 0x5A); + + public static readonly Guid CLSID_D2D1ArithmeticComposite = + new Guid(0xFC151437, 0x049A, 0x4784, 0xA2, 0x4A, 0xF1, 0xC4, 0xDA, 0xF2, 0x09, 0x87); + + public static readonly Guid CLSID_D2D1Atlas = + new Guid(0x913E2BE4, 0xFDCF, 0x4FE2, 0xA5, 0xF0, 0x24, 0x54, 0xF1, 0x4F, 0xF4, 0x08); + + public static readonly Guid CLSID_D2D1BitmapSource = + new Guid(0x5FB6C24D, 0xC6DD, 0x4231, 0x94, 0x4, 0x50, 0xF4, 0xD5, 0xC3, 0x25, 0x2D); + + public static readonly Guid CLSID_D2D1Blend = + new Guid(0x81C5B77B, 0x13F8, 0x4CDD, 0xAD, 0x20, 0xC8, 0x90, 0x54, 0x7A, 0xC6, 0x5D); + + public static readonly Guid CLSID_D2D1Border = + new Guid(0x2A2D49C0, 0x4ACF, 0x43C7, 0x8C, 0x6A, 0x7C, 0x4A, 0x27, 0x87, 0x4D, 0x27); + + public static readonly Guid CLSID_D2D1Brightness = + new Guid(0x8CEA8D1E, 0x77B0, 0x4986, 0xB3, 0xB9, 0x2F, 0x0C, 0x0E, 0xAE, 0x78, 0x87); + + public static readonly Guid CLSID_D2D1ColorManagement = + new Guid(0x1A28524C, 0xFDD6, 0x4AA4, 0xAE, 0x8F, 0x83, 0x7E, 0xB8, 0x26, 0x7B, 0x37); + + public static readonly Guid CLSID_D2D1ColorMatrix = + new Guid(0x921F03D6, 0x641C, 0x47DF, 0x85, 0x2D, 0xB4, 0xBB, 0x61, 0x53, 0xAE, 0x11); + + public static readonly Guid CLSID_D2D1Composite = + new Guid(0x48FC9F51, 0xF6AC, 0x48F1, 0x8B, 0x58, 0x3B, 0x28, 0xAC, 0x46, 0xF7, 0x6D); + + public static readonly Guid CLSID_D2D1ConvolveMatrix = + new Guid(0x407F8C08, 0x5533, 0x4331, 0xA3, 0x41, 0x23, 0xCC, 0x38, 0x77, 0x84, 0x3E); + + public static readonly Guid CLSID_D2D1Crop = + new Guid(0xE23F7110, 0x0E9A, 0x4324, 0xAF, 0x47, 0x6A, 0x2C, 0x0C, 0x46, 0xF3, 0x5B); + + public static readonly Guid CLSID_D2D1DirectionalBlur = + new Guid(0x174319A6, 0x58E9, 0x49B2, 0xBB, 0x63, 0xCA, 0xF2, 0xC8, 0x11, 0xA3, 0xDB); + + public static readonly Guid CLSID_D2D1DiscreteTransfer = + new Guid(0x90866FCD, 0x488E, 0x454B, 0xAF, 0x06, 0xE5, 0x04, 0x1B, 0x66, 0xC3, 0x6C); + + public static readonly Guid CLSID_D2D1DisplacementMap = + new Guid(0xEDC48364, 0x417, 0x4111, 0x94, 0x50, 0x43, 0x84, 0x5F, 0xA9, 0xF8, 0x90); + + public static readonly Guid CLSID_D2D1DistantDiffuse = + new Guid(0x3E7EFD62, 0xA32D, 0x46D4, 0xA8, 0x3C, 0x52, 0x78, 0x88, 0x9A, 0xC9, 0x54); + + public static readonly Guid CLSID_D2D1DistantSpecular = + new Guid(0x428C1EE5, 0x77B8, 0x4450, 0x8A, 0xB5, 0x72, 0x21, 0x9C, 0x21, 0xAB, 0xDA); + + public static readonly Guid CLSID_D2D1DpiCompensation = + new Guid(0x6C26C5C7, 0x34E0, 0x46FC, 0x9C, 0xFD, 0xE5, 0x82, 0x37, 0x6, 0xE2, 0x28); + + public static readonly Guid CLSID_D2D1Flood = + new Guid(0x61C23C20, 0xAE69, 0x4D8E, 0x94, 0xCF, 0x50, 0x07, 0x8D, 0xF6, 0x38, 0xF2); + + public static readonly Guid CLSID_D2D1GammaTransfer = + new Guid(0x409444C4, 0xC419, 0x41A0, 0xB0, 0xC1, 0x8C, 0xD0, 0xC0, 0xA1, 0x8E, 0x42); + + public static readonly Guid CLSID_D2D1GaussianBlur = + new Guid(0x1FEB6D69, 0x2FE6, 0x4AC9, 0x8C, 0x58, 0x1D, 0x7F, 0x93, 0xE7, 0xA6, 0xA5); + + public static readonly Guid CLSID_D2D1Scale = + new Guid(0x9DAF9369, 0x3846, 0x4D0E, 0xA4, 0x4E, 0xC, 0x60, 0x79, 0x34, 0xA5, 0xD7); + + public static readonly Guid CLSID_D2D1Histogram = + new Guid(0x881DB7D0, 0xF7EE, 0x4D4D, 0xA6, 0xD2, 0x46, 0x97, 0xAC, 0xC6, 0x6E, 0xE8); + + public static readonly Guid CLSID_D2D1HueRotation = + new Guid(0x0F4458EC, 0x4B32, 0x491B, 0x9E, 0x85, 0xBD, 0x73, 0xF4, 0x4D, 0x3E, 0xB6); + + public static readonly Guid CLSID_D2D1LinearTransfer = + new Guid(0xAD47C8FD, 0x63EF, 0x4ACC, 0x9B, 0x51, 0x67, 0x97, 0x9C, 0x03, 0x6C, 0x06); + + public static readonly Guid CLSID_D2D1LuminanceToAlpha = + new Guid(0x41251AB7, 0x0BEB, 0x46F8, 0x9D, 0xA7, 0x59, 0xE9, 0x3F, 0xCC, 0xE5, 0xDE); + + public static readonly Guid CLSID_D2D1Morphology = + new Guid(0xEAE6C40D, 0x626A, 0x4C2D, 0xBF, 0xCB, 0x39, 0x10, 0x01, 0xAB, 0xE2, 0x02); + + public static readonly Guid CLSID_D2D1OpacityMetadata = + new Guid(0x6C53006A, 0x4450, 0x4199, 0xAA, 0x5B, 0xAD, 0x16, 0x56, 0xFE, 0xCE, 0x5E); + + public static readonly Guid CLSID_D2D1PointDiffuse = + new Guid(0xB9E303C3, 0xC08C, 0x4F91, 0x8B, 0x7B, 0x38, 0x65, 0x6B, 0xC4, 0x8C, 0x20); + + public static readonly Guid CLSID_D2D1PointSpecular = + new Guid(0x09C3CA26, 0x3AE2, 0x4F09, 0x9E, 0xBC, 0xED, 0x38, 0x65, 0xD5, 0x3F, 0x22); + + public static readonly Guid CLSID_D2D1Premultiply = + new Guid(0x06EAB419, 0xDEED, 0x4018, 0x80, 0xD2, 0x3E, 0x1D, 0x47, 0x1A, 0xDE, 0xB2); + + public static readonly Guid CLSID_D2D1Saturation = + new Guid(0x5CB2D9CF, 0x327D, 0x459F, 0xA0, 0xCE, 0x40, 0xC0, 0xB2, 0x08, 0x6B, 0xF7); + + public static readonly Guid CLSID_D2D1Shadow = + new Guid(0xC67EA361, 0x1863, 0x4E69, 0x89, 0xDB, 0x69, 0x5D, 0x3E, 0x9A, 0x5B, 0x6B); + + public static readonly Guid CLSID_D2D1SpotDiffuse = + new Guid(0x818A1105, 0x7932, 0x44F4, 0xAA, 0x86, 0x08, 0xAE, 0x7B, 0x2F, 0x2C, 0x93); + + public static readonly Guid CLSID_D2D1SpotSpecular = + new Guid(0xEDAE421E, 0x7654, 0x4A37, 0x9D, 0xB8, 0x71, 0xAC, 0xC1, 0xBE, 0xB3, 0xC1); + + public static readonly Guid CLSID_D2D1TableTransfer = + new Guid(0x5BF818C3, 0x5E43, 0x48CB, 0xB6, 0x31, 0x86, 0x83, 0x96, 0xD6, 0xA1, 0xD4); + + public static readonly Guid CLSID_D2D1Tile = + new Guid(0xB0784138, 0x3B76, 0x4BC5, 0xB1, 0x3B, 0x0F, 0xA2, 0xAD, 0x02, 0x65, 0x9F); + + public static readonly Guid CLSID_D2D1Turbulence = + new Guid(0xCF2BB6AE, 0x889A, 0x4AD7, 0xBA, 0x29, 0xA2, 0xFD, 0x73, 0x2C, 0x9F, 0xC9); + + public static readonly Guid CLSID_D2D1UnPremultiply = + new Guid(0xFB9AC489, 0xAD8D, 0x41ED, 0x99, 0x99, 0xBB, 0x63, 0x47, 0xD1, 0x10, 0xF7); + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs new file mode 100644 index 0000000000..da56c98d56 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs @@ -0,0 +1,84 @@ +using System; +using System.Numerics; +using Avalonia.MicroCom; +using Avalonia.OpenGL; +using Avalonia.OpenGL.Egl; +using Avalonia.Win32.Interop; + +namespace Avalonia.Win32.WinRT.Composition +{ + public class WinUICompositedWindow : IDisposable + { + private EglContext _syncContext; + private readonly IVisual _blurVisual; + private ICompositionTarget _compositionTarget; + private IVisual _contentVisual; + private ICompositionDrawingSurfaceInterop _surfaceInterop; + private PixelSize _size; + + private static Guid IID_ID3D11Texture2D = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); + + + internal WinUICompositedWindow(EglContext syncContext, + ICompositionTarget compositionTarget, + ICompositionDrawingSurfaceInterop surfaceInterop, + IVisual contentVisual, IVisual blurVisual) + { + _syncContext = syncContext; + _blurVisual = blurVisual.CloneReference(); + _compositionTarget = compositionTarget.CloneReference(); + _contentVisual = contentVisual.CloneReference(); + _surfaceInterop = surfaceInterop.CloneReference(); + } + + + public void ResizeIfNeeded(PixelSize size) + { + using (_syncContext.EnsureLocked()) + { + if (_size != size) + { + _surfaceInterop.Resize(new UnmanagedMethods.POINT { X = size.Width, Y = size.Height }); + _contentVisual.SetSize(new Vector2(size.Width, size.Height)); + _size = size; + } + } + } + + public unsafe IUnknown BeginDrawToTexture(out PixelPoint offset) + { + if (!_syncContext.IsCurrent) + throw new InvalidOperationException(); + + var iid = IID_ID3D11Texture2D; + void* pTexture; + var off = _surfaceInterop.BeginDraw(null, &iid, &pTexture); + offset = new PixelPoint(off.X, off.Y); + return MicroComRuntime.CreateProxyFor(pTexture, true); + } + + public void EndDraw() + { + if (!_syncContext.IsCurrent) + throw new InvalidOperationException(); + _surfaceInterop.EndDraw(); + } + + public void SetBlur(bool enable) + { + using (_syncContext.EnsureLocked()) + _blurVisual.SetIsVisible(enable ? 1 : 0); + } + + public void Dispose() + { + if (_syncContext == null) + { + _blurVisual.Dispose(); + _contentVisual.Dispose(); + _surfaceInterop.Dispose(); + _compositionTarget.Dispose(); + } + } + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs new file mode 100644 index 0000000000..5056899106 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -0,0 +1,152 @@ +using System; +using System.Numerics; +using System.Runtime.InteropServices; +using Avalonia.Logging; +using Avalonia.MicroCom; +using Avalonia.OpenGL; +using Avalonia.OpenGL.Angle; +using Avalonia.OpenGL.Egl; +using Avalonia.Win32.Interop; + +namespace Avalonia.Win32.WinRT.Composition +{ + public class WinUICompositorConnection + { + private readonly EglContext _syncContext; + private IntPtr _queue; + private ICompositor _compositor; + private ICompositor2 _compositor2; + private ICompositorInterop _compositorInterop; + private AngleWin32EglDisplay _angle; + private ICompositionGraphicsDevice _device; + private EglPlatformOpenGlInterface _gl; + private ICompositorDesktopInterop _compositorDesktopInterop; + + public WinUICompositorConnection(EglPlatformOpenGlInterface gl) + { + _gl = gl; + _syncContext = _gl.PrimaryEglContext; + _angle = (AngleWin32EglDisplay)_gl.Display; + _queue = NativeWinRTMethods.CreateDispatcherQueueController(new NativeWinRTMethods.DispatcherQueueOptions + { + apartmentType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE, + dwSize = Marshal.SizeOf(), + threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT + }); + _compositor = NativeWinRTMethods.CreateInstance("Windows.UI.Composition.Compositor"); + _compositor2 = _compositor.QueryInterface(); + _compositorInterop = _compositor.QueryInterface(); + _compositorDesktopInterop = _compositor.QueryInterface(); + using var device = MicroComRuntime.CreateProxyFor(_angle.GetDirect3DDevice(), true); + + _device = _compositorInterop.CreateGraphicsDevice(device); + } + + public EglPlatformOpenGlInterface Egl => _gl; + + public static WinUICompositorConnection TryCreate(EglPlatformOpenGlInterface angle) + { + const int majorRequired = 10; + const int buildRequired = 16299; + + var majorInstalled = Win32Platform.WindowsVersion.Major; + var buildInstalled = Win32Platform.WindowsVersion.Build; + + if (majorInstalled >= majorRequired && + buildInstalled >= buildRequired) + { + try + { + return new WinUICompositorConnection(angle); + } + catch (Exception e) + { + Logger.TryGet(LogEventLevel.Error, "WinUIComposition") + ?.Log(null, "Unable to initialize WinUI compositor: {0}", e); + + return null; + } + } + + var osVersionNotice = + $"Windows {majorRequired} Build {buildRequired} is required. Your machine has Windows {majorInstalled} Build {buildInstalled} installed."; + + Logger.TryGet(LogEventLevel.Warning, "WinUIComposition")?.Log(null, + $"Unable to initialize WinUI compositor: {osVersionNotice}"); + + return null; + } + + + public WinUICompositedWindow CreateWindow(IntPtr hWnd) + { + using var sc = _syncContext.EnsureLocked(); + using var desktopTarget = _compositorDesktopInterop.CreateDesktopWindowTarget(hWnd, 0); + using var target = desktopTarget.QueryInterface(); + + using var drawingSurface = _device.CreateDrawingSurface(new UnmanagedMethods.SIZE(), DirectXPixelFormat.B8G8R8A8UIntNormalized, + DirectXAlphaMode.Premultiplied); + using var surface = drawingSurface.QueryInterface(); + using var surfaceInterop = drawingSurface.QueryInterface(); + + using var surfaceBrush = _compositor.CreateSurfaceBrushWithSurface(surface); + using var brush = surfaceBrush.QueryInterface(); + + using var spriteVisual = _compositor.CreateSpriteVisual(); + spriteVisual.SetBrush(brush); + using var visual = spriteVisual.QueryInterface(); + using var visual2 = spriteVisual.QueryInterface(); + //visual2.SetRelativeSizeAdjustment(new Vector2(1, 1)); + using var container = _compositor.CreateContainerVisual(); + using var containerVisual = container.QueryInterface(); + using var containerVisual2 = container.QueryInterface(); + containerVisual2.SetRelativeSizeAdjustment(new Vector2(1, 1)); + using var containerChildren = container.Children; + + target.SetRoot(containerVisual); + + using var blur = CreateBlur(); + + containerChildren.InsertAtTop(blur); + containerChildren.InsertAtTop(visual); + //visual.SetCompositeMode(CompositionCompositeMode.SourceOver); + + return new WinUICompositedWindow(_syncContext, target, surfaceInterop, visual, blur); + } + + private unsafe IVisual CreateBlur() + { + using var backDropParameterFactory = NativeWinRTMethods.CreateActivationFactory( + "Windows.UI.Composition.CompositionEffectSourceParameter"); + using var backdropString = new HStringInterop("backdrop"); + using var backDropParameter = + backDropParameterFactory.Create(backdropString.Handle); + using var backDropParameterAsSource = backDropParameter.QueryInterface(); + var blurEffect = new WinUIGaussianBlurEffect(backDropParameterAsSource); + using var blurEffectFactory = _compositor.CreateEffectFactory(blurEffect); + using var backdrop = _compositor2.CreateBackdropBrush(); + using var backdropBrush = backdrop.QueryInterface(); + + + var saturateEffect = new SaturationEffect(blurEffect); + using var satEffectFactory = _compositor.CreateEffectFactory(saturateEffect); + using var sat = satEffectFactory.CreateBrush(); + using var satBrush = sat.QueryInterface(); + sat.SetSourceParameter(backdropString.Handle, backdropBrush); + + using var spriteVisual = _compositor.CreateSpriteVisual(); + using var visual = spriteVisual.QueryInterface(); + using var visual2 = spriteVisual.QueryInterface(); + + + + spriteVisual.SetBrush(satBrush); + //visual.SetIsVisible(0); + visual2.SetRelativeSizeAdjustment(new Vector2(1.0f, 1.0f)); + + return visual.CloneReference(); + } + + + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUIEffectBase.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUIEffectBase.cs new file mode 100644 index 0000000000..ea75a2f311 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUIEffectBase.cs @@ -0,0 +1,135 @@ +using System; +using System.Linq; +using System.Runtime.InteropServices; +using Avalonia.MicroCom; + +namespace Avalonia.Win32.WinRT.Composition +{ + abstract class WinUIEffectBase : WinRTInspectable, IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop + { + private IGraphicsEffectSource[] _sources; + + public WinUIEffectBase(params IGraphicsEffectSource[] _sources) + { + this._sources = _sources.Select(e => + { + if (e is WinUIEffectBase) + return e; + return e.CloneReference(); + }).ToArray(); + } + + public IntPtr Name => IntPtr.Zero; + + public void SetName(IntPtr name) + { + + } + + public abstract Guid EffectId { get; } + public unsafe void GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping) => + throw new COMException("Not supported", unchecked((int)0x80004001)); + + public abstract uint PropertyCount { get; } + public abstract IPropertyValue GetProperty(uint index); + + public IGraphicsEffectSource GetSource(uint index) + { + if (_sources == null || index> _sources.Length) + throw new COMException("Invalid index", unchecked((int)0x80070057)); + return _sources[index]; + } + + public uint SourceCount => (uint)(_sources?.Length ?? 0); + + public override void OnUnreferencedFromNative() + { + if (_sources == null) + return; + + /*foreach(var s in _sources) + s.Dispose();*/ + _sources = null; + } + } + + class WinUIGaussianBlurEffect : WinUIEffectBase + { + public WinUIGaussianBlurEffect(IGraphicsEffectSource source) : base(source) + { + } + + enum D2D1_GAUSSIANBLUR_OPTIMIZATION + { + D2D1_GAUSSIANBLUR_OPTIMIZATION_SPEED, + D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED, + D2D1_GAUSSIANBLUR_OPTIMIZATION_QUALITY, + D2D1_GAUSSIANBLUR_OPTIMIZATION_FORCE_DWORD + }; + + enum D2D1_BORDER_MODE + { + D2D1_BORDER_MODE_SOFT, + D2D1_BORDER_MODE_HARD, + D2D1_BORDER_MODE_FORCE_DWORD + }; + + enum D2D1GaussianBlurProp + { + D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, + D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION, + D2D1_GAUSSIANBLUR_PROP_BORDER_MODE, + D2D1_GAUSSIANBLUR_PROP_FORCE_DWORD + }; + + public override Guid EffectId => D2DEffects.CLSID_D2D1GaussianBlur; + + public override uint PropertyCount => 3; + + public override IPropertyValue GetProperty(uint index) + { + switch ((D2D1GaussianBlurProp)index) + { + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION: + return new WinRTPropertyValue(30.0f); + + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION: + return new WinRTPropertyValue((uint)D2D1_GAUSSIANBLUR_OPTIMIZATION + .D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED); + + case D2D1GaussianBlurProp.D2D1_GAUSSIANBLUR_PROP_BORDER_MODE: + return new WinRTPropertyValue((uint)D2D1_BORDER_MODE.D2D1_BORDER_MODE_HARD); + } + + return null; + } + } + + class SaturationEffect : WinUIEffectBase + { + public SaturationEffect(IGraphicsEffectSource source) : base(source) + { + } + + enum D2D1_SATURATION_PROP + { + D2D1_SATURATION_PROP_SATURATION, + D2D1_SATURATION_PROP_FORCE_DWORD + }; + + public override Guid EffectId => D2DEffects.CLSID_D2D1Saturation; + + public override uint PropertyCount => 1; + + public override IPropertyValue GetProperty(uint index) + { + switch ((D2D1_SATURATION_PROP)index) + { + case D2D1_SATURATION_PROP.D2D1_SATURATION_PROP_SATURATION: + return new WinRTPropertyValue(2.0f); + } + + return null; + } + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs new file mode 100644 index 0000000000..9d80803b91 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs @@ -0,0 +1,114 @@ +using System; +using System.Runtime.InteropServices; +using Avalonia.MicroCom; +using Avalonia.OpenGL.Angle; +using Avalonia.OpenGL.Egl; +using Avalonia.OpenGL.Surfaces; +using Avalonia.Utilities; +using Avalonia.Win32.Interop; + +namespace Avalonia.Win32.WinRT.Composition +{ + internal class WinUiCompositedWindowSurface : EglGlPlatformSurfaceBase, IBlurHost, IDisposable + { + private readonly WinUICompositorConnection _connection; + private EglPlatformOpenGlInterface _egl; + private readonly EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo _info; + private IRef _window; + private bool _enableBlur; + + public WinUiCompositedWindowSurface(WinUICompositorConnection connection, IEglWindowGlPlatformSurfaceInfo info) : base() + { + _connection = connection; + _egl = connection.Egl; + _info = info; + } + + public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() + { + using (_egl.PrimaryContext.EnsureCurrent()) + { + if (_window?.Item == null) + { + _window = RefCountable.Create(_connection.CreateWindow(_info.Handle)); + _window.Item.SetBlur(_enableBlur); + } + + return new CompositionRenderTarget(_egl, _window, _info); + } + } + + class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase + { + private readonly EglPlatformOpenGlInterface _egl; + private readonly IRef _window; + private readonly IEglWindowGlPlatformSurfaceInfo _info; + + public CompositionRenderTarget(EglPlatformOpenGlInterface egl, + IRef window, + IEglWindowGlPlatformSurfaceInfo info) + : base(egl) + { + _egl = egl; + _window = window.Clone(); + _info = info; + _window.Item.ResizeIfNeeded(_info.Size); + } + + public override IGlPlatformSurfaceRenderingSession BeginDraw() + { + var contextLock = _egl.PrimaryEglContext.EnsureCurrent(); + IUnknown texture = null; + EglSurface surface = null; + var success = false; + try + { + if (_window?.Item == null) + throw new ObjectDisposedException(GetType().FullName); + + var size = _info.Size; + _window.Item.ResizeIfNeeded(size); + texture = _window.Item.BeginDrawToTexture(out var offset); + + surface = ((AngleWin32EglDisplay) _egl.Display).WrapDirect3D11Texture(_egl, + texture.GetNativeIntPtr(), + offset.X, offset.Y, size.Width, size.Height); + + var res = base.BeginDraw(surface, _info, () => + { + _window.Item.EndDraw(); + texture?.Dispose(); + surface?.Dispose(); + contextLock?.Dispose(); + }, true); + success = true; + return res; + } + finally + { + if (!success) + { + surface?.Dispose(); + texture?.Dispose(); + contextLock.Dispose(); + } + } + } + } + + public void SetBlur(bool enable) + { + _enableBlur = enable; + _window?.Item?.SetBlur(enable); + } + + public void Dispose() + { + using (_egl.PrimaryEglContext.EnsureLocked()) + { + _window?.Dispose(); + _window = null; + } + } + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/IBlurHost.cs b/src/Windows/Avalonia.Win32/WinRT/IBlurHost.cs new file mode 100644 index 0000000000..81c0e3e185 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/IBlurHost.cs @@ -0,0 +1,7 @@ +namespace Avalonia.Win32.WinRT +{ + public interface IBlurHost + { + void SetBlur(bool enable); + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/NativeWinRTMethods.cs b/src/Windows/Avalonia.Win32/WinRT/NativeWinRTMethods.cs new file mode 100644 index 0000000000..087bd2fd43 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/NativeWinRTMethods.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Threading; +using Avalonia.MicroCom; +using Avalonia.Win32.Interop; + +namespace Avalonia.Win32.WinRT +{ + internal static class NativeWinRTMethods + { + [DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", CallingConvention = CallingConvention.StdCall, + PreserveSig = false)] + internal static extern unsafe IntPtr WindowsCreateString( + [MarshalAs(UnmanagedType.LPWStr)] string sourceString, + int length); + + internal static IntPtr WindowsCreateString(string sourceString) + => WindowsCreateString(sourceString, sourceString.Length); + + [DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", + CallingConvention = CallingConvention.StdCall, PreserveSig = false)] + internal static extern unsafe IntPtr WindowsDeleteString(IntPtr hString); + + [DllImport("Windows.UI.Composition", EntryPoint = "DllGetActivationFactory", + CallingConvention = CallingConvention.StdCall, PreserveSig = false)] + private extern static IntPtr GetWindowsUICompositionActivationFactory( + IntPtr activatableClassId); + + internal static IActivationFactory GetWindowsUICompositionActivationFactory(string className) + {//"Windows.UI.Composition.Compositor" + var s = WindowsCreateString(className); + var factory = GetWindowsUICompositionActivationFactory(s); + return MicroComRuntime.CreateProxyFor(factory, true); + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate int GetActivationFactoryDelegate(IntPtr classId, out IntPtr ppv); + + internal static T CreateInstance(string fullName) where T : IUnknown + { + var s = WindowsCreateString(fullName); + EnsureRoInitialized(); + var pUnk = RoActivateInstance(s); + using var unk = MicroComRuntime.CreateProxyFor(pUnk, true); + WindowsDeleteString(s); + return MicroComRuntime.QueryInterface(unk); + } + + internal static TFactory CreateActivationFactory(string fullName) where TFactory : IUnknown + { + var s = WindowsCreateString(fullName); + EnsureRoInitialized(); + var guid = MicroComRuntime.GetGuidFor(typeof(TFactory)); + var pUnk = RoGetActivationFactory(s, ref guid); + using var unk = MicroComRuntime.CreateProxyFor(pUnk, true); + WindowsDeleteString(s); + return MicroComRuntime.QueryInterface(unk); + } + + internal enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE + { + DQTAT_COM_NONE = 0, + DQTAT_COM_ASTA = 1, + DQTAT_COM_STA = 2 + }; + + internal enum DISPATCHERQUEUE_THREAD_TYPE + { + DQTYPE_THREAD_DEDICATED = 1, + DQTYPE_THREAD_CURRENT = 2, + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct DispatcherQueueOptions + { + public int dwSize; + + [MarshalAs(UnmanagedType.I4)] + public DISPATCHERQUEUE_THREAD_TYPE threadType; + + [MarshalAs(UnmanagedType.I4)] + public DISPATCHERQUEUE_THREAD_APARTMENTTYPE apartmentType; + }; + + [DllImport("coremessaging.dll", PreserveSig = false)] + internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options); + + internal enum RO_INIT_TYPE + { + RO_INIT_SINGLETHREADED = 0, // Single-threaded application + RO_INIT_MULTITHREADED = 1, // COM calls objects on any thread. + } + + [DllImport("combase.dll", PreserveSig = false)] + private static extern void RoInitialize(RO_INIT_TYPE initType); + + [DllImport("combase.dll", PreserveSig = false)] + private static extern IntPtr RoActivateInstance(IntPtr activatableClassId); + + [DllImport("combase.dll", PreserveSig = false)] + private static extern IntPtr RoGetActivationFactory(IntPtr activatableClassId, ref Guid iid); + + private static bool _initialized; + private static void EnsureRoInitialized() + { + if (_initialized) + return; + RoInitialize(Thread.CurrentThread.GetApartmentState() == ApartmentState.STA ? + RO_INIT_TYPE.RO_INIT_SINGLETHREADED : + RO_INIT_TYPE.RO_INIT_MULTITHREADED); + _initialized = true; + } + } + + class HStringInterop : IDisposable + { + private IntPtr _s; + + public HStringInterop(string s) + { + _s = s == null ? IntPtr.Zero : NativeWinRTMethods.WindowsCreateString(s); + } + + public IntPtr Handle => _s; + + public void Dispose() + { + if (_s != IntPtr.Zero) + { + NativeWinRTMethods.WindowsDeleteString(_s); + _s = IntPtr.Zero; + } + } + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs b/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs new file mode 100644 index 0000000000..0968212fe0 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs @@ -0,0 +1,8713 @@ +#pragma warning disable 108 +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using Avalonia.MicroCom; + +namespace Avalonia.Win32.WinRT +{ + internal enum TrustLevel + { + BaseTrust, + PartialTrust, + FullTrust + } + + internal enum DirectXAlphaMode + { + Unspecified, + Premultiplied, + Straight, + Ignore + } + + internal enum DirectXPixelFormat + { + Unknown = 0, + R32G32B32A32Typeless = 1, + R32G32B32A32Float = 2, + R32G32B32A32UInt = 3, + R32G32B32A32Int = 4, + R32G32B32Typeless = 5, + R32G32B32Float = 6, + R32G32B32UInt = 7, + R32G32B32Int = 8, + R16G16B16A16Typeless = 9, + R16G16B16A16Float = 10, + R16G16B16A16UIntNormalized = 11, + R16G16B16A16UInt = 12, + R16G16B16A16IntNormalized = 13, + R16G16B16A16Int = 14, + R32G32Typeless = 15, + R32G32Float = 16, + R32G32UInt = 17, + R32G32Int = 18, + R32G8X24Typeless = 19, + D32FloatS8X24UInt = 20, + R32FloatX8X24Typeless = 21, + X32TypelessG8X24UInt = 22, + R10G10B10A2Typeless = 23, + R10G10B10A2UIntNormalized = 24, + R10G10B10A2UInt = 25, + R11G11B10Float = 26, + R8G8B8A8Typeless = 27, + R8G8B8A8UIntNormalized = 28, + R8G8B8A8UIntNormalizedSrgb = 29, + R8G8B8A8UInt = 30, + R8G8B8A8IntNormalized = 31, + R8G8B8A8Int = 32, + R16G16Typeless = 33, + R16G16Float = 34, + R16G16UIntNormalized = 35, + R16G16UInt = 36, + R16G16IntNormalized = 37, + R16G16Int = 38, + R32Typeless = 39, + D32Float = 40, + R32Float = 41, + R32UInt = 42, + R32Int = 43, + R24G8Typeless = 44, + D24UIntNormalizedS8UInt = 45, + R24UIntNormalizedX8Typeless = 46, + X24TypelessG8UInt = 47, + R8G8Typeless = 48, + R8G8UIntNormalized = 49, + R8G8UInt = 50, + R8G8IntNormalized = 51, + R8G8Int = 52, + R16Typeless = 53, + R16Float = 54, + D16UIntNormalized = 55, + R16UIntNormalized = 56, + R16UInt = 57, + R16IntNormalized = 58, + R16Int = 59, + R8Typeless = 60, + R8UIntNormalized = 61, + R8UInt = 62, + R8IntNormalized = 63, + R8Int = 64, + A8UIntNormalized = 65, + R1UIntNormalized = 66, + R9G9B9E5SharedExponent = 67, + R8G8B8G8UIntNormalized = 68, + G8R8G8B8UIntNormalized = 69, + BC1Typeless = 70, + BC1UIntNormalized = 71, + BC1UIntNormalizedSrgb = 72, + BC2Typeless = 73, + BC2UIntNormalized = 74, + BC2UIntNormalizedSrgb = 75, + BC3Typeless = 76, + BC3UIntNormalized = 77, + BC3UIntNormalizedSrgb = 78, + BC4Typeless = 79, + BC4UIntNormalized = 80, + BC4IntNormalized = 81, + BC5Typeless = 82, + BC5UIntNormalized = 83, + BC5IntNormalized = 84, + B5G6R5UIntNormalized = 85, + B5G5R5A1UIntNormalized = 86, + B8G8R8A8UIntNormalized = 87, + B8G8R8X8UIntNormalized = 88, + R10G10B10XRBiasA2UIntNormalized = 89, + B8G8R8A8Typeless = 90, + B8G8R8A8UIntNormalizedSrgb = 91, + B8G8R8X8Typeless = 92, + B8G8R8X8UIntNormalizedSrgb = 93, + BC6HTypeless = 94, + BC6H16UnsignedFloat = 95, + BC6H16Float = 96, + BC7Typeless = 97, + BC7UIntNormalized = 98, + BC7UIntNormalizedSrgb = 99, + Ayuv = 100, + Y410 = 101, + Y416 = 102, + NV12 = 103, + P010 = 104, + P016 = 105, + Opaque420 = 106, + Yuy2 = 107, + Y210 = 108, + Y216 = 109, + NV11 = 110, + AI44 = 111, + IA44 = 112, + P8 = 113, + A8P8 = 114, + B4G4R4A4UIntNormalized = 115, + P208 = 130, + V208 = 131, + V408 = 132 + } + + internal enum PropertyType + { + Empty = 0, + UInt8 = 1, + Int16 = 2, + UInt16 = 3, + Int32 = 4, + UInt32 = 5, + Int64 = 6, + UInt64 = 7, + Single = 8, + Double = 9, + Char16 = 10, + Boolean = 11, + String = 12, + Inspectable = 13, + DateTime = 14, + TimeSpan = 15, + Guid = 16, + Point = 17, + Size = 18, + Rect = 19, + OtherType = 20, + UInt8Array = 1025, + Int16Array = 1026, + UInt16Array = 1027, + Int32Array = 1028, + UInt32Array = 1029, + Int64Array = 1030, + UInt64Array = 1031, + SingleArray = 1032, + DoubleArray = 1033, + Char16Array = 1034, + BooleanArray = 1035, + StringArray = 1036, + InspectableArray = 1037, + DateTimeArray = 1038, + TimeSpanArray = 1039, + GuidArray = 1040, + PointArray = 1041, + SizeArray = 1042, + RectArray = 1043, + OtherTypeArray = 1044 + } + + internal enum AsyncStatus + { + Started = 0, + Completed, + Canceled, + Error + } + + internal enum CompositionBatchTypes + { + None = 0x0, + Animation = 0x1, + Effect = 0x2, + InfiniteAnimation = 0x4, + AllAnimations = 0x5 + } + + internal enum CompositionBackfaceVisibility + { + Inherit, + Visible, + Hidden + } + + internal enum CompositionBorderMode + { + Inherit, + Soft, + Hard + } + + internal enum CompositionCompositeMode + { + Inherit, + SourceOver, + DestinationInvert, + MinBlend + } + + internal enum GRAPHICS_EFFECT_PROPERTY_MAPPING + { + GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, + GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 + } + + internal enum CompositionEffectFactoryLoadStatus + { + Success = 0, + EffectTooComplex = 1, + Pending = 2, + Other = -1 + } + + internal unsafe partial interface IInspectable : Avalonia.MicroCom.IUnknown + { + void GetIids(ulong* iidCount, Guid** iids); + IntPtr RuntimeClassName + { + get; + } + + TrustLevel TrustLevel + { + get; + } + } + + internal unsafe partial interface IPropertyValue : IInspectable + { + PropertyType Type + { + get; + } + + int IsNumericScalar + { + get; + } + + byte UInt8 + { + get; + } + + short Int16 + { + get; + } + + ushort UInt16 + { + get; + } + + int Int32 + { + get; + } + + uint UInt32 + { + get; + } + + long Int64 + { + get; + } + + ulong UInt64 + { + get; + } + + float Single + { + get; + } + + double Double + { + get; + } + + System.Char Char16 + { + get; + } + + int Boolean + { + get; + } + + IntPtr String + { + get; + } + + System.Guid Guid + { + get; + } + + void GetDateTime(void* value); + void GetTimeSpan(void* value); + void GetPoint(void* value); + void GetSize(void* value); + void GetRect(void* value); + byte* GetUInt8Array(uint* __valueSize); + short* GetInt16Array(uint* __valueSize); + ushort* GetUInt16Array(uint* __valueSize); + int* GetInt32Array(uint* __valueSize); + uint* GetUInt32Array(uint* __valueSize); + long* GetInt64Array(uint* __valueSize); + ulong* GetUInt64Array(uint* __valueSize); + float* GetSingleArray(uint* __valueSize); + double* GetDoubleArray(uint* __valueSize); + System.Char* GetChar16Array(uint* __valueSize); + int* GetBooleanArray(uint* __valueSize); + IntPtr* GetStringArray(uint* __valueSize); + void** GetInspectableArray(uint* __valueSize); + System.Guid* GetGuidArray(uint* __valueSize); + void* GetDateTimeArray(uint* __valueSize); + void* GetTimeSpanArray(uint* __valueSize); + void* GetPointArray(uint* __valueSize); + void* GetSizeArray(uint* __valueSize); + void* GetRectArray(uint* __valueSize); + } + + internal unsafe partial interface IAsyncActionCompletedHandler : Avalonia.MicroCom.IUnknown + { + void Invoke(IAsyncAction asyncInfo, AsyncStatus asyncStatus); + } + + internal unsafe partial interface IAsyncAction : IInspectable + { + void SetCompleted(IAsyncActionCompletedHandler handler); + IAsyncActionCompletedHandler Completed + { + get; + } + + void GetResults(); + } + + internal unsafe partial interface IDispatcherQueue : IInspectable + { + } + + internal unsafe partial interface IDispatcherQueueController : IInspectable + { + IDispatcherQueue DispatcherQueue + { + get; + } + + IAsyncAction ShutdownQueueAsync(); + } + + internal unsafe partial interface IActivationFactory : IInspectable + { + IntPtr ActivateInstance(); + } + + internal unsafe partial interface ICompositor : IInspectable + { + void* CreateColorKeyFrameAnimation(); + void* CreateColorBrush(); + ICompositionColorBrush CreateColorBrushWithColor(Avalonia.Win32.WinRT.WinRTColor* color); + IContainerVisual CreateContainerVisual(); + void* CreateCubicBezierEasingFunction(System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2); + ICompositionEffectFactory CreateEffectFactory(IGraphicsEffect graphicsEffect); + void* CreateEffectFactoryWithProperties(void* graphicsEffect, void* animatableProperties); + void* CreateExpressionAnimation(); + void* CreateExpressionAnimationWithExpression(IntPtr expression); + void* CreateInsetClip(); + void* CreateInsetClipWithInsets(float leftInset, float topInset, float rightInset, float bottomInset); + void* CreateLinearEasingFunction(); + void* CreatePropertySet(); + void* CreateQuaternionKeyFrameAnimation(); + void* CreateScalarKeyFrameAnimation(); + void* CreateScopedBatch(CompositionBatchTypes batchType); + ISpriteVisual CreateSpriteVisual(); + ICompositionSurfaceBrush CreateSurfaceBrush(); + ICompositionSurfaceBrush CreateSurfaceBrushWithSurface(ICompositionSurface surface); + void* CreateTargetForCurrentView(); + void* CreateVector2KeyFrameAnimation(); + void* CreateVector3KeyFrameAnimation(); + void* CreateVector4KeyFrameAnimation(); + void* GetCommitBatch(CompositionBatchTypes batchType); + } + + internal unsafe partial interface ICompositor2 : IInspectable + { + void* CreateAmbientLight(); + void* CreateAnimationGroup(); + ICompositionBackdropBrush CreateBackdropBrush(); + void* CreateDistantLight(); + void* CreateDropShadow(); + void* CreateImplicitAnimationCollection(); + void* CreateLayerVisual(); + void* CreateMaskBrush(); + void* CreateNineGridBrush(); + void* CreatePointLight(); + void* CreateSpotLight(); + void* CreateStepEasingFunction(); + void* CreateStepEasingFunctionWithStepCount(int stepCount); + } + + internal unsafe partial interface ISpriteVisual : IInspectable + { + ICompositionBrush Brush + { + get; + } + + void SetBrush(ICompositionBrush value); + } + + internal unsafe partial interface ICompositionDrawingSurfaceInterop : Avalonia.MicroCom.IUnknown + { + Avalonia.Win32.Interop.UnmanagedMethods.POINT BeginDraw(Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject); + void EndDraw(); + void Resize(Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels); + void Scroll(Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY); + void ResumeDraw(); + void SuspendDraw(); + } + + internal unsafe partial interface ICompositionGraphicsDeviceInterop : Avalonia.MicroCom.IUnknown + { + IUnknown RenderingDevice + { + get; + } + + void SetRenderingDevice(IUnknown value); + } + + internal unsafe partial interface ICompositorInterop : Avalonia.MicroCom.IUnknown + { + ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain); + ICompositionSurface CreateCompositionSurfaceForSwapChain(IUnknown swapChain); + ICompositionGraphicsDevice CreateGraphicsDevice(IUnknown renderingDevice); + } + + internal unsafe partial interface ISwapChainInterop : Avalonia.MicroCom.IUnknown + { + void SetSwapChain(IUnknown swapChain); + } + + internal unsafe partial interface ICompositorDesktopInterop : Avalonia.MicroCom.IUnknown + { + IDesktopWindowTarget CreateDesktopWindowTarget(IntPtr hwndTarget, int isTopmost); + void EnsureOnThread(int threadId); + } + + internal unsafe partial interface IDesktopWindowTargetInterop : Avalonia.MicroCom.IUnknown + { + IntPtr HWnd + { + get; + } + } + + internal unsafe partial interface IDesktopWindowContentBridgeInterop : Avalonia.MicroCom.IUnknown + { + void Initialize(ICompositor compositor, IntPtr parentHwnd); + IntPtr HWnd + { + get; + } + + float AppliedScaleFactor + { + get; + } + } + + internal unsafe partial interface ICompositionGraphicsDevice : IInspectable + { + ICompositionDrawingSurface CreateDrawingSurface(Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode); + void AddRenderingDeviceReplaced(void* handler, void* token); + void RemoveRenderingDeviceReplaced(int token); + } + + internal unsafe partial interface ICompositionSurface : IInspectable + { + } + + internal unsafe partial interface IDesktopWindowTarget : IInspectable + { + int IsTopmost + { + get; + } + } + + internal unsafe partial interface ICompositionDrawingSurface : IInspectable + { + DirectXAlphaMode AlphaMode + { + get; + } + + DirectXPixelFormat PixelFormat + { + get; + } + + Avalonia.Win32.Interop.UnmanagedMethods.POINT Size + { + get; + } + } + + internal unsafe partial interface ICompositionSurfaceBrush : IInspectable + { + } + + internal unsafe partial interface ICompositionBrush : IInspectable + { + } + + internal unsafe partial interface IVisual : IInspectable + { + System.Numerics.Vector2 AnchorPoint + { + get; + } + + void SetAnchorPoint(System.Numerics.Vector2 value); + CompositionBackfaceVisibility BackfaceVisibility + { + get; + } + + void SetBackfaceVisibility(CompositionBackfaceVisibility value); + CompositionBorderMode BorderMode + { + get; + } + + void SetBorderMode(CompositionBorderMode value); + System.Numerics.Vector3 CenterPoint + { + get; + } + + void SetCenterPoint(System.Numerics.Vector3 value); + void* Clip + { + get; + } + + void SetClip(void* value); + CompositionCompositeMode CompositeMode + { + get; + } + + void SetCompositeMode(CompositionCompositeMode value); + int IsVisible + { + get; + } + + void SetIsVisible(int value); + System.Numerics.Vector3 Offset + { + get; + } + + void SetOffset(System.Numerics.Vector3 value); + float Opacity + { + get; + } + + void SetOpacity(float value); + System.Numerics.Quaternion Orientation + { + get; + } + + void SetOrientation(System.Numerics.Quaternion value); + IContainerVisual Parent + { + get; + } + + float RotationAngle + { + get; + } + + void SetRotationAngle(float value); + float RotationAngleInDegrees + { + get; + } + + void SetRotationAngleInDegrees(float value); + System.Numerics.Vector3 RotationAxis + { + get; + } + + void SetRotationAxis(System.Numerics.Vector3 value); + System.Numerics.Vector3 Scale + { + get; + } + + void SetScale(System.Numerics.Vector3 value); + System.Numerics.Vector2 Size + { + get; + } + + void SetSize(System.Numerics.Vector2 value); + System.Numerics.Matrix4x4 TransformMatrix + { + get; + } + + void SetTransformMatrix(System.Numerics.Matrix4x4 value); + } + + internal unsafe partial interface IVisual2 : IInspectable + { + IVisual ParentForTransform + { + get; + } + + void SetParentForTransform(IVisual value); + System.Numerics.Vector3 RelativeOffsetAdjustment + { + get; + } + + void SetRelativeOffsetAdjustment(System.Numerics.Vector3 value); + System.Numerics.Vector2 RelativeSizeAdjustment + { + get; + } + + void SetRelativeSizeAdjustment(System.Numerics.Vector2 value); + } + + internal unsafe partial interface IContainerVisual : IInspectable + { + IVisualCollection Children + { + get; + } + } + + internal unsafe partial interface IVisualCollection : IInspectable + { + int Count + { + get; + } + + void InsertAbove(IVisual newChild, IVisual sibling); + void InsertAtBottom(IVisual newChild); + void InsertAtTop(IVisual newChild); + void InsertBelow(IVisual newChild, IVisual sibling); + void Remove(IVisual child); + void RemoveAll(); + } + + internal unsafe partial interface ICompositionTarget : IInspectable + { + IVisual Root + { + get; + } + + void SetRoot(IVisual value); + } + + internal unsafe partial interface IGraphicsEffect : IInspectable + { + IntPtr Name + { + get; + } + + void SetName(IntPtr name); + } + + internal unsafe partial interface IGraphicsEffectSource : IInspectable + { + } + + internal unsafe partial interface IGraphicsEffectD2D1Interop : Avalonia.MicroCom.IUnknown + { + Guid EffectId + { + get; + } + + void GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping); + uint PropertyCount + { + get; + } + + IPropertyValue GetProperty(uint index); + IGraphicsEffectSource GetSource(uint index); + uint SourceCount + { + get; + } + } + + internal unsafe partial interface ICompositionEffectSourceParameter : IInspectable + { + IntPtr Name + { + get; + } + } + + internal unsafe partial interface ICompositionEffectSourceParameterFactory : IInspectable + { + ICompositionEffectSourceParameter Create(IntPtr name); + } + + internal unsafe partial interface ICompositionEffectFactory : IInspectable + { + ICompositionEffectBrush CreateBrush(); + int ExtendedError + { + get; + } + + CompositionEffectFactoryLoadStatus LoadStatus + { + get; + } + } + + internal unsafe partial interface ICompositionEffectBrush : IInspectable + { + ICompositionBrush GetSourceParameter(IntPtr name); + void SetSourceParameter(IntPtr name, ICompositionBrush source); + } + + internal unsafe partial interface ICompositionBackdropBrush : IInspectable + { + } + + internal unsafe partial interface ICompositionColorBrush : IInspectable + { + Avalonia.Win32.WinRT.WinRTColor Color + { + get; + } + + void SetColor(Avalonia.Win32.WinRT.WinRTColor value); + } +} + +namespace Avalonia.Win32.WinRT.Impl +{ + unsafe internal partial class __MicroComIInspectableProxy : Avalonia.MicroCom.MicroComProxyBase, IInspectable + { + public void GetIids(ulong* iidCount, Guid** iids) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, iidCount, iids, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetIids failed", __result); + } + + public IntPtr RuntimeClassName + { + get + { + int __result; + IntPtr className = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &className, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRuntimeClassName failed", __result); + return className; + } + } + + public TrustLevel TrustLevel + { + get + { + int __result; + TrustLevel trustLevel = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &trustLevel, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetTrustLevel failed", __result); + return trustLevel; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IInspectable), new Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90"), (p, owns) => new __MicroComIInspectableProxy(p, owns)); + } + + public __MicroComIInspectableProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComIInspectableVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetIidsDelegate(IntPtr @this, ulong* iidCount, Guid** iids); + static int GetIids(IntPtr @this, ulong* iidCount, Guid** iids) + { + IInspectable __target = null; + try + { + { + __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetIids(iidCount, iids); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRuntimeClassNameDelegate(IntPtr @this, IntPtr* className); + static int GetRuntimeClassName(IntPtr @this, IntPtr* className) + { + IInspectable __target = null; + try + { + { + __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RuntimeClassName; + *className = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetTrustLevelDelegate(IntPtr @this, TrustLevel* trustLevel); + static int GetTrustLevel(IntPtr @this, TrustLevel* trustLevel) + { + IInspectable __target = null; + try + { + { + __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.TrustLevel; + *trustLevel = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIInspectableVTable() + { + base.AddMethod((GetIidsDelegate)GetIids); + base.AddMethod((GetRuntimeClassNameDelegate)GetRuntimeClassName); + base.AddMethod((GetTrustLevelDelegate)GetTrustLevel); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IInspectable), new __MicroComIInspectableVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIPropertyValueProxy : __MicroComIInspectableProxy, IPropertyValue + { + public PropertyType Type + { + get + { + int __result; + PropertyType value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetType failed", __result); + return value; + } + } + + public int IsNumericScalar + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetIsNumericScalar failed", __result); + return value; + } + } + + public byte UInt8 + { + get + { + int __result; + byte value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt8 failed", __result); + return value; + } + } + + public short Int16 + { + get + { + int __result; + short value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt16 failed", __result); + return value; + } + } + + public ushort UInt16 + { + get + { + int __result; + ushort value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt16 failed", __result); + return value; + } + } + + public int Int32 + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt32 failed", __result); + return value; + } + } + + public uint UInt32 + { + get + { + int __result; + uint value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 6]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt32 failed", __result); + return value; + } + } + + public long Int64 + { + get + { + int __result; + long value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 7]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt64 failed", __result); + return value; + } + } + + public ulong UInt64 + { + get + { + int __result; + ulong value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 8]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt64 failed", __result); + return value; + } + } + + public float Single + { + get + { + int __result; + float value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 9]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSingle failed", __result); + return value; + } + } + + public double Double + { + get + { + int __result; + double value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 10]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetDouble failed", __result); + return value; + } + } + + public System.Char Char16 + { + get + { + int __result; + System.Char value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 11]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetChar16 failed", __result); + return value; + } + } + + public int Boolean + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 12]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetBoolean failed", __result); + return value; + } + } + + public IntPtr String + { + get + { + int __result; + IntPtr value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 13]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetString failed", __result); + return value; + } + } + + public System.Guid Guid + { + get + { + int __result; + System.Guid value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 14]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetGuid failed", __result); + return value; + } + } + + public void GetDateTime(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 15]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetDateTime failed", __result); + } + + public void GetTimeSpan(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 16]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetTimeSpan failed", __result); + } + + public void GetPoint(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 17]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetPoint failed", __result); + } + + public void GetSize(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 18]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); + } + + public void GetRect(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 19]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRect failed", __result); + } + + public byte* GetUInt8Array(uint* __valueSize) + { + int __result; + byte* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 20]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt8Array failed", __result); + return value; + } + + public short* GetInt16Array(uint* __valueSize) + { + int __result; + short* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 21]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt16Array failed", __result); + return value; + } + + public ushort* GetUInt16Array(uint* __valueSize) + { + int __result; + ushort* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 22]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt16Array failed", __result); + return value; + } + + public int* GetInt32Array(uint* __valueSize) + { + int __result; + int* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 23]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt32Array failed", __result); + return value; + } + + public uint* GetUInt32Array(uint* __valueSize) + { + int __result; + uint* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 24]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt32Array failed", __result); + return value; + } + + public long* GetInt64Array(uint* __valueSize) + { + int __result; + long* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 25]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInt64Array failed", __result); + return value; + } + + public ulong* GetUInt64Array(uint* __valueSize) + { + int __result; + ulong* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 26]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetUInt64Array failed", __result); + return value; + } + + public float* GetSingleArray(uint* __valueSize) + { + int __result; + float* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 27]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSingleArray failed", __result); + return value; + } + + public double* GetDoubleArray(uint* __valueSize) + { + int __result; + double* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 28]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetDoubleArray failed", __result); + return value; + } + + public System.Char* GetChar16Array(uint* __valueSize) + { + int __result; + System.Char* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 29]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetChar16Array failed", __result); + return value; + } + + public int* GetBooleanArray(uint* __valueSize) + { + int __result; + int* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 30]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetBooleanArray failed", __result); + return value; + } + + public IntPtr* GetStringArray(uint* __valueSize) + { + int __result; + IntPtr* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 31]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetStringArray failed", __result); + return value; + } + + public void** GetInspectableArray(uint* __valueSize) + { + int __result; + void** value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 32]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetInspectableArray failed", __result); + return value; + } + + public System.Guid* GetGuidArray(uint* __valueSize) + { + int __result; + System.Guid* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 33]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetGuidArray failed", __result); + return value; + } + + public void* GetDateTimeArray(uint* __valueSize) + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 34]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetDateTimeArray failed", __result); + return value; + } + + public void* GetTimeSpanArray(uint* __valueSize) + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 35]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetTimeSpanArray failed", __result); + return value; + } + + public void* GetPointArray(uint* __valueSize) + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 36]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetPointArray failed", __result); + return value; + } + + public void* GetSizeArray(uint* __valueSize) + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 37]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSizeArray failed", __result); + return value; + } + + public void* GetRectArray(uint* __valueSize) + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 38]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRectArray failed", __result); + return value; + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IPropertyValue), new Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62"), (p, owns) => new __MicroComIPropertyValueProxy(p, owns)); + } + + public __MicroComIPropertyValueProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 39; + } + + unsafe class __MicroComIPropertyValueVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetTypeDelegate(IntPtr @this, PropertyType* value); + static int GetType(IntPtr @this, PropertyType* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Type; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetIsNumericScalarDelegate(IntPtr @this, int* value); + static int GetIsNumericScalar(IntPtr @this, int* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.IsNumericScalar; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt8Delegate(IntPtr @this, byte* value); + static int GetUInt8(IntPtr @this, byte* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.UInt8; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt16Delegate(IntPtr @this, short* value); + static int GetInt16(IntPtr @this, short* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Int16; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt16Delegate(IntPtr @this, ushort* value); + static int GetUInt16(IntPtr @this, ushort* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.UInt16; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt32Delegate(IntPtr @this, int* value); + static int GetInt32(IntPtr @this, int* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Int32; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt32Delegate(IntPtr @this, uint* value); + static int GetUInt32(IntPtr @this, uint* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.UInt32; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt64Delegate(IntPtr @this, long* value); + static int GetInt64(IntPtr @this, long* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Int64; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt64Delegate(IntPtr @this, ulong* value); + static int GetUInt64(IntPtr @this, ulong* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.UInt64; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSingleDelegate(IntPtr @this, float* value); + static int GetSingle(IntPtr @this, float* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Single; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetDoubleDelegate(IntPtr @this, double* value); + static int GetDouble(IntPtr @this, double* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Double; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetChar16Delegate(IntPtr @this, System.Char* value); + static int GetChar16(IntPtr @this, System.Char* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Char16; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetBooleanDelegate(IntPtr @this, int* value); + static int GetBoolean(IntPtr @this, int* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Boolean; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetStringDelegate(IntPtr @this, IntPtr* value); + static int GetString(IntPtr @this, IntPtr* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.String; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetGuidDelegate(IntPtr @this, System.Guid* value); + static int GetGuid(IntPtr @this, System.Guid* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Guid; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetDateTimeDelegate(IntPtr @this, void* value); + static int GetDateTime(IntPtr @this, void* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetDateTime(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetTimeSpanDelegate(IntPtr @this, void* value); + static int GetTimeSpan(IntPtr @this, void* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetTimeSpan(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetPointDelegate(IntPtr @this, void* value); + static int GetPoint(IntPtr @this, void* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetPoint(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSizeDelegate(IntPtr @this, void* value); + static int GetSize(IntPtr @this, void* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetSize(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRectDelegate(IntPtr @this, void* value); + static int GetRect(IntPtr @this, void* value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetRect(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt8ArrayDelegate(IntPtr @this, uint* __valueSize, byte** value); + static int GetUInt8Array(IntPtr @this, uint* __valueSize, byte** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetUInt8Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt16ArrayDelegate(IntPtr @this, uint* __valueSize, short** value); + static int GetInt16Array(IntPtr @this, uint* __valueSize, short** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetInt16Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt16ArrayDelegate(IntPtr @this, uint* __valueSize, ushort** value); + static int GetUInt16Array(IntPtr @this, uint* __valueSize, ushort** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetUInt16Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt32ArrayDelegate(IntPtr @this, uint* __valueSize, int** value); + static int GetInt32Array(IntPtr @this, uint* __valueSize, int** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetInt32Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt32ArrayDelegate(IntPtr @this, uint* __valueSize, uint** value); + static int GetUInt32Array(IntPtr @this, uint* __valueSize, uint** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetUInt32Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInt64ArrayDelegate(IntPtr @this, uint* __valueSize, long** value); + static int GetInt64Array(IntPtr @this, uint* __valueSize, long** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetInt64Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetUInt64ArrayDelegate(IntPtr @this, uint* __valueSize, ulong** value); + static int GetUInt64Array(IntPtr @this, uint* __valueSize, ulong** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetUInt64Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSingleArrayDelegate(IntPtr @this, uint* __valueSize, float** value); + static int GetSingleArray(IntPtr @this, uint* __valueSize, float** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetSingleArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetDoubleArrayDelegate(IntPtr @this, uint* __valueSize, double** value); + static int GetDoubleArray(IntPtr @this, uint* __valueSize, double** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetDoubleArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetChar16ArrayDelegate(IntPtr @this, uint* __valueSize, System.Char** value); + static int GetChar16Array(IntPtr @this, uint* __valueSize, System.Char** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetChar16Array(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetBooleanArrayDelegate(IntPtr @this, uint* __valueSize, int** value); + static int GetBooleanArray(IntPtr @this, uint* __valueSize, int** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetBooleanArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetStringArrayDelegate(IntPtr @this, uint* __valueSize, IntPtr** value); + static int GetStringArray(IntPtr @this, uint* __valueSize, IntPtr** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetStringArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetInspectableArrayDelegate(IntPtr @this, uint* __valueSize, void*** value); + static int GetInspectableArray(IntPtr @this, uint* __valueSize, void*** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetInspectableArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetGuidArrayDelegate(IntPtr @this, uint* __valueSize, System.Guid** value); + static int GetGuidArray(IntPtr @this, uint* __valueSize, System.Guid** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetGuidArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetDateTimeArrayDelegate(IntPtr @this, uint* __valueSize, void** value); + static int GetDateTimeArray(IntPtr @this, uint* __valueSize, void** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetDateTimeArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetTimeSpanArrayDelegate(IntPtr @this, uint* __valueSize, void** value); + static int GetTimeSpanArray(IntPtr @this, uint* __valueSize, void** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetTimeSpanArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetPointArrayDelegate(IntPtr @this, uint* __valueSize, void** value); + static int GetPointArray(IntPtr @this, uint* __valueSize, void** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetPointArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSizeArrayDelegate(IntPtr @this, uint* __valueSize, void** value); + static int GetSizeArray(IntPtr @this, uint* __valueSize, void** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetSizeArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRectArrayDelegate(IntPtr @this, uint* __valueSize, void** value); + static int GetRectArray(IntPtr @this, uint* __valueSize, void** value) + { + IPropertyValue __target = null; + try + { + { + __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetRectArray(__valueSize); + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIPropertyValueVTable() + { + base.AddMethod((GetTypeDelegate)GetType); + base.AddMethod((GetIsNumericScalarDelegate)GetIsNumericScalar); + base.AddMethod((GetUInt8Delegate)GetUInt8); + base.AddMethod((GetInt16Delegate)GetInt16); + base.AddMethod((GetUInt16Delegate)GetUInt16); + base.AddMethod((GetInt32Delegate)GetInt32); + base.AddMethod((GetUInt32Delegate)GetUInt32); + base.AddMethod((GetInt64Delegate)GetInt64); + base.AddMethod((GetUInt64Delegate)GetUInt64); + base.AddMethod((GetSingleDelegate)GetSingle); + base.AddMethod((GetDoubleDelegate)GetDouble); + base.AddMethod((GetChar16Delegate)GetChar16); + base.AddMethod((GetBooleanDelegate)GetBoolean); + base.AddMethod((GetStringDelegate)GetString); + base.AddMethod((GetGuidDelegate)GetGuid); + base.AddMethod((GetDateTimeDelegate)GetDateTime); + base.AddMethod((GetTimeSpanDelegate)GetTimeSpan); + base.AddMethod((GetPointDelegate)GetPoint); + base.AddMethod((GetSizeDelegate)GetSize); + base.AddMethod((GetRectDelegate)GetRect); + base.AddMethod((GetUInt8ArrayDelegate)GetUInt8Array); + base.AddMethod((GetInt16ArrayDelegate)GetInt16Array); + base.AddMethod((GetUInt16ArrayDelegate)GetUInt16Array); + base.AddMethod((GetInt32ArrayDelegate)GetInt32Array); + base.AddMethod((GetUInt32ArrayDelegate)GetUInt32Array); + base.AddMethod((GetInt64ArrayDelegate)GetInt64Array); + base.AddMethod((GetUInt64ArrayDelegate)GetUInt64Array); + base.AddMethod((GetSingleArrayDelegate)GetSingleArray); + base.AddMethod((GetDoubleArrayDelegate)GetDoubleArray); + base.AddMethod((GetChar16ArrayDelegate)GetChar16Array); + base.AddMethod((GetBooleanArrayDelegate)GetBooleanArray); + base.AddMethod((GetStringArrayDelegate)GetStringArray); + base.AddMethod((GetInspectableArrayDelegate)GetInspectableArray); + base.AddMethod((GetGuidArrayDelegate)GetGuidArray); + base.AddMethod((GetDateTimeArrayDelegate)GetDateTimeArray); + base.AddMethod((GetTimeSpanArrayDelegate)GetTimeSpanArray); + base.AddMethod((GetPointArrayDelegate)GetPointArray); + base.AddMethod((GetSizeArrayDelegate)GetSizeArray); + base.AddMethod((GetRectArrayDelegate)GetRectArray); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IPropertyValue), new __MicroComIPropertyValueVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIAsyncActionCompletedHandlerProxy : Avalonia.MicroCom.MicroComProxyBase, IAsyncActionCompletedHandler + { + public void Invoke(IAsyncAction asyncInfo, AsyncStatus asyncStatus) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(asyncInfo), asyncStatus, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Invoke failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IAsyncActionCompletedHandler), new Guid("A4ED5C81-76C9-40BD-8BE6-B1D90FB20AE7"), (p, owns) => new __MicroComIAsyncActionCompletedHandlerProxy(p, owns)); + } + + public __MicroComIAsyncActionCompletedHandlerProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComIAsyncActionCompletedHandlerVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InvokeDelegate(IntPtr @this, void* asyncInfo, AsyncStatus asyncStatus); + static int Invoke(IntPtr @this, void* asyncInfo, AsyncStatus asyncStatus) + { + IAsyncActionCompletedHandler __target = null; + try + { + { + __target = (IAsyncActionCompletedHandler)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.Invoke(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(asyncInfo, false), asyncStatus); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIAsyncActionCompletedHandlerVTable() + { + base.AddMethod((InvokeDelegate)Invoke); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IAsyncActionCompletedHandler), new __MicroComIAsyncActionCompletedHandlerVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIAsyncActionProxy : __MicroComIInspectableProxy, IAsyncAction + { + public void SetCompleted(IAsyncActionCompletedHandler handler) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(handler), (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetCompleted failed", __result); + } + + public IAsyncActionCompletedHandler Completed + { + get + { + int __result; + void* __marshal_ppv = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_ppv, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetCompleted failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_ppv, true); + } + } + + public void GetResults() + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetResults failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IAsyncAction), new Guid("5A648006-843A-4DA9-865B-9D26E5DFAD7B"), (p, owns) => new __MicroComIAsyncActionProxy(p, owns)); + } + + public __MicroComIAsyncActionProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComIAsyncActionVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetCompletedDelegate(IntPtr @this, void* handler); + static int SetCompleted(IntPtr @this, void* handler) + { + IAsyncAction __target = null; + try + { + { + __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetCompleted(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(handler, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetCompletedDelegate(IntPtr @this, void** ppv); + static int GetCompleted(IntPtr @this, void** ppv) + { + IAsyncAction __target = null; + try + { + { + __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Completed; + *ppv = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetResultsDelegate(IntPtr @this); + static int GetResults(IntPtr @this) + { + IAsyncAction __target = null; + try + { + { + __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetResults(); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIAsyncActionVTable() + { + base.AddMethod((SetCompletedDelegate)SetCompleted); + base.AddMethod((GetCompletedDelegate)GetCompleted); + base.AddMethod((GetResultsDelegate)GetResults); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IAsyncAction), new __MicroComIAsyncActionVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIDispatcherQueueProxy : __MicroComIInspectableProxy, IDispatcherQueue + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDispatcherQueue), new Guid("603E88E4-A338-4FFE-A457-A5CFB9CEB899"), (p, owns) => new __MicroComIDispatcherQueueProxy(p, owns)); + } + + public __MicroComIDispatcherQueueProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComIDispatcherQueueVTable : __MicroComIInspectableVTable + { + public __MicroComIDispatcherQueueVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDispatcherQueue), new __MicroComIDispatcherQueueVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIDispatcherQueueControllerProxy : __MicroComIInspectableProxy, IDispatcherQueueController + { + public IDispatcherQueue DispatcherQueue + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetDispatcherQueue failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public IAsyncAction ShutdownQueueAsync() + { + int __result; + void* __marshal_operation = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_operation, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("ShutdownQueueAsync failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_operation, true); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDispatcherQueueController), new Guid("22F34E66-50DB-4E36-A98D-61C01B384D20"), (p, owns) => new __MicroComIDispatcherQueueControllerProxy(p, owns)); + } + + public __MicroComIDispatcherQueueControllerProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComIDispatcherQueueControllerVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetDispatcherQueueDelegate(IntPtr @this, void** value); + static int GetDispatcherQueue(IntPtr @this, void** value) + { + IDispatcherQueueController __target = null; + try + { + { + __target = (IDispatcherQueueController)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.DispatcherQueue; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int ShutdownQueueAsyncDelegate(IntPtr @this, void** operation); + static int ShutdownQueueAsync(IntPtr @this, void** operation) + { + IDispatcherQueueController __target = null; + try + { + { + __target = (IDispatcherQueueController)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.ShutdownQueueAsync(); + *operation = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIDispatcherQueueControllerVTable() + { + base.AddMethod((GetDispatcherQueueDelegate)GetDispatcherQueue); + base.AddMethod((ShutdownQueueAsyncDelegate)ShutdownQueueAsync); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDispatcherQueueController), new __MicroComIDispatcherQueueControllerVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIActivationFactoryProxy : __MicroComIInspectableProxy, IActivationFactory + { + public IntPtr ActivateInstance() + { + int __result; + IntPtr instance = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &instance, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("ActivateInstance failed", __result); + return instance; + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IActivationFactory), new Guid("00000035-0000-0000-C000-000000000046"), (p, owns) => new __MicroComIActivationFactoryProxy(p, owns)); + } + + public __MicroComIActivationFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComIActivationFactoryVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int ActivateInstanceDelegate(IntPtr @this, IntPtr* instance); + static int ActivateInstance(IntPtr @this, IntPtr* instance) + { + IActivationFactory __target = null; + try + { + { + __target = (IActivationFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.ActivateInstance(); + *instance = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIActivationFactoryVTable() + { + base.AddMethod((ActivateInstanceDelegate)ActivateInstance); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IActivationFactory), new __MicroComIActivationFactoryVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositorProxy : __MicroComIInspectableProxy, ICompositor + { + public void* CreateColorKeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateColorKeyFrameAnimation failed", __result); + return result; + } + + public void* CreateColorBrush() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateColorBrush failed", __result); + return result; + } + + public ICompositionColorBrush CreateColorBrushWithColor(Avalonia.Win32.WinRT.WinRTColor* color) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, color, &__marshal_result, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateColorBrushWithColor failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public IContainerVisual CreateContainerVisual() + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateContainerVisual failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void* CreateCubicBezierEasingFunction(System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, controlPoint1, controlPoint2, &result, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateCubicBezierEasingFunction failed", __result); + return result; + } + + public ICompositionEffectFactory CreateEffectFactory(IGraphicsEffect graphicsEffect) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(graphicsEffect), &__marshal_result, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateEffectFactory failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void* CreateEffectFactoryWithProperties(void* graphicsEffect, void* animatableProperties) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, graphicsEffect, animatableProperties, &result, (*PPV)[base.VTableSize + 6]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateEffectFactoryWithProperties failed", __result); + return result; + } + + public void* CreateExpressionAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 7]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateExpressionAnimation failed", __result); + return result; + } + + public void* CreateExpressionAnimationWithExpression(IntPtr expression) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, expression, &result, (*PPV)[base.VTableSize + 8]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateExpressionAnimationWithExpression failed", __result); + return result; + } + + public void* CreateInsetClip() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 9]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateInsetClip failed", __result); + return result; + } + + public void* CreateInsetClipWithInsets(float leftInset, float topInset, float rightInset, float bottomInset) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, leftInset, topInset, rightInset, bottomInset, &result, (*PPV)[base.VTableSize + 10]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateInsetClipWithInsets failed", __result); + return result; + } + + public void* CreateLinearEasingFunction() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 11]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateLinearEasingFunction failed", __result); + return result; + } + + public void* CreatePropertySet() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 12]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreatePropertySet failed", __result); + return result; + } + + public void* CreateQuaternionKeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 13]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateQuaternionKeyFrameAnimation failed", __result); + return result; + } + + public void* CreateScalarKeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 14]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateScalarKeyFrameAnimation failed", __result); + return result; + } + + public void* CreateScopedBatch(CompositionBatchTypes batchType) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, batchType, &result, (*PPV)[base.VTableSize + 15]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateScopedBatch failed", __result); + return result; + } + + public ISpriteVisual CreateSpriteVisual() + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 16]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateSpriteVisual failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public ICompositionSurfaceBrush CreateSurfaceBrush() + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 17]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateSurfaceBrush failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public ICompositionSurfaceBrush CreateSurfaceBrushWithSurface(ICompositionSurface surface) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(surface), &__marshal_result, (*PPV)[base.VTableSize + 18]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateSurfaceBrushWithSurface failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void* CreateTargetForCurrentView() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 19]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateTargetForCurrentView failed", __result); + return result; + } + + public void* CreateVector2KeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 20]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateVector2KeyFrameAnimation failed", __result); + return result; + } + + public void* CreateVector3KeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 21]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateVector3KeyFrameAnimation failed", __result); + return result; + } + + public void* CreateVector4KeyFrameAnimation() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 22]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateVector4KeyFrameAnimation failed", __result); + return result; + } + + public void* GetCommitBatch(CompositionBatchTypes batchType) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, batchType, &result, (*PPV)[base.VTableSize + 23]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetCommitBatch failed", __result); + return result; + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositor), new Guid("B403CA50-7F8C-4E83-985F-CC45060036D8"), (p, owns) => new __MicroComICompositorProxy(p, owns)); + } + + public __MicroComICompositorProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 24; + } + + unsafe class __MicroComICompositorVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateColorKeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateColorKeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateColorKeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateColorBrushDelegate(IntPtr @this, void** result); + static int CreateColorBrush(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateColorBrush(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateColorBrushWithColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* color, void** result); + static int CreateColorBrushWithColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* color, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateColorBrushWithColor(color); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateContainerVisualDelegate(IntPtr @this, void** result); + static int CreateContainerVisual(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateContainerVisual(); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateCubicBezierEasingFunctionDelegate(IntPtr @this, System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2, void** result); + static int CreateCubicBezierEasingFunction(IntPtr @this, System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateCubicBezierEasingFunction(controlPoint1, controlPoint2); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateEffectFactoryDelegate(IntPtr @this, void* graphicsEffect, void** result); + static int CreateEffectFactory(IntPtr @this, void* graphicsEffect, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateEffectFactory(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(graphicsEffect, false)); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateEffectFactoryWithPropertiesDelegate(IntPtr @this, void* graphicsEffect, void* animatableProperties, void** result); + static int CreateEffectFactoryWithProperties(IntPtr @this, void* graphicsEffect, void* animatableProperties, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateEffectFactoryWithProperties(graphicsEffect, animatableProperties); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateExpressionAnimationDelegate(IntPtr @this, void** result); + static int CreateExpressionAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateExpressionAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateExpressionAnimationWithExpressionDelegate(IntPtr @this, IntPtr expression, void** result); + static int CreateExpressionAnimationWithExpression(IntPtr @this, IntPtr expression, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateExpressionAnimationWithExpression(expression); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateInsetClipDelegate(IntPtr @this, void** result); + static int CreateInsetClip(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateInsetClip(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateInsetClipWithInsetsDelegate(IntPtr @this, float leftInset, float topInset, float rightInset, float bottomInset, void** result); + static int CreateInsetClipWithInsets(IntPtr @this, float leftInset, float topInset, float rightInset, float bottomInset, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateInsetClipWithInsets(leftInset, topInset, rightInset, bottomInset); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateLinearEasingFunctionDelegate(IntPtr @this, void** result); + static int CreateLinearEasingFunction(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateLinearEasingFunction(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreatePropertySetDelegate(IntPtr @this, void** result); + static int CreatePropertySet(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreatePropertySet(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateQuaternionKeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateQuaternionKeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateQuaternionKeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateScalarKeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateScalarKeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateScalarKeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateScopedBatchDelegate(IntPtr @this, CompositionBatchTypes batchType, void** result); + static int CreateScopedBatch(IntPtr @this, CompositionBatchTypes batchType, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateScopedBatch(batchType); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateSpriteVisualDelegate(IntPtr @this, void** result); + static int CreateSpriteVisual(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateSpriteVisual(); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateSurfaceBrushDelegate(IntPtr @this, void** result); + static int CreateSurfaceBrush(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateSurfaceBrush(); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateSurfaceBrushWithSurfaceDelegate(IntPtr @this, void* surface, void** result); + static int CreateSurfaceBrushWithSurface(IntPtr @this, void* surface, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateSurfaceBrushWithSurface(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(surface, false)); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateTargetForCurrentViewDelegate(IntPtr @this, void** result); + static int CreateTargetForCurrentView(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateTargetForCurrentView(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateVector2KeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateVector2KeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateVector2KeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateVector3KeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateVector3KeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateVector3KeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateVector4KeyFrameAnimationDelegate(IntPtr @this, void** result); + static int CreateVector4KeyFrameAnimation(IntPtr @this, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateVector4KeyFrameAnimation(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetCommitBatchDelegate(IntPtr @this, CompositionBatchTypes batchType, void** result); + static int GetCommitBatch(IntPtr @this, CompositionBatchTypes batchType, void** result) + { + ICompositor __target = null; + try + { + { + __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetCommitBatch(batchType); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositorVTable() + { + base.AddMethod((CreateColorKeyFrameAnimationDelegate)CreateColorKeyFrameAnimation); + base.AddMethod((CreateColorBrushDelegate)CreateColorBrush); + base.AddMethod((CreateColorBrushWithColorDelegate)CreateColorBrushWithColor); + base.AddMethod((CreateContainerVisualDelegate)CreateContainerVisual); + base.AddMethod((CreateCubicBezierEasingFunctionDelegate)CreateCubicBezierEasingFunction); + base.AddMethod((CreateEffectFactoryDelegate)CreateEffectFactory); + base.AddMethod((CreateEffectFactoryWithPropertiesDelegate)CreateEffectFactoryWithProperties); + base.AddMethod((CreateExpressionAnimationDelegate)CreateExpressionAnimation); + base.AddMethod((CreateExpressionAnimationWithExpressionDelegate)CreateExpressionAnimationWithExpression); + base.AddMethod((CreateInsetClipDelegate)CreateInsetClip); + base.AddMethod((CreateInsetClipWithInsetsDelegate)CreateInsetClipWithInsets); + base.AddMethod((CreateLinearEasingFunctionDelegate)CreateLinearEasingFunction); + base.AddMethod((CreatePropertySetDelegate)CreatePropertySet); + base.AddMethod((CreateQuaternionKeyFrameAnimationDelegate)CreateQuaternionKeyFrameAnimation); + base.AddMethod((CreateScalarKeyFrameAnimationDelegate)CreateScalarKeyFrameAnimation); + base.AddMethod((CreateScopedBatchDelegate)CreateScopedBatch); + base.AddMethod((CreateSpriteVisualDelegate)CreateSpriteVisual); + base.AddMethod((CreateSurfaceBrushDelegate)CreateSurfaceBrush); + base.AddMethod((CreateSurfaceBrushWithSurfaceDelegate)CreateSurfaceBrushWithSurface); + base.AddMethod((CreateTargetForCurrentViewDelegate)CreateTargetForCurrentView); + base.AddMethod((CreateVector2KeyFrameAnimationDelegate)CreateVector2KeyFrameAnimation); + base.AddMethod((CreateVector3KeyFrameAnimationDelegate)CreateVector3KeyFrameAnimation); + base.AddMethod((CreateVector4KeyFrameAnimationDelegate)CreateVector4KeyFrameAnimation); + base.AddMethod((GetCommitBatchDelegate)GetCommitBatch); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositor), new __MicroComICompositorVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositor2Proxy : __MicroComIInspectableProxy, ICompositor2 + { + public void* CreateAmbientLight() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateAmbientLight failed", __result); + return result; + } + + public void* CreateAnimationGroup() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateAnimationGroup failed", __result); + return result; + } + + public ICompositionBackdropBrush CreateBackdropBrush() + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateBackdropBrush failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void* CreateDistantLight() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateDistantLight failed", __result); + return result; + } + + public void* CreateDropShadow() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateDropShadow failed", __result); + return result; + } + + public void* CreateImplicitAnimationCollection() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateImplicitAnimationCollection failed", __result); + return result; + } + + public void* CreateLayerVisual() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 6]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateLayerVisual failed", __result); + return result; + } + + public void* CreateMaskBrush() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 7]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateMaskBrush failed", __result); + return result; + } + + public void* CreateNineGridBrush() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 8]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateNineGridBrush failed", __result); + return result; + } + + public void* CreatePointLight() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 9]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreatePointLight failed", __result); + return result; + } + + public void* CreateSpotLight() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 10]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateSpotLight failed", __result); + return result; + } + + public void* CreateStepEasingFunction() + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 11]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateStepEasingFunction failed", __result); + return result; + } + + public void* CreateStepEasingFunctionWithStepCount(int stepCount) + { + int __result; + void* result = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, stepCount, &result, (*PPV)[base.VTableSize + 12]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateStepEasingFunctionWithStepCount failed", __result); + return result; + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositor2), new Guid("735081DC-5E24-45DA-A38F-E32CC349A9A0"), (p, owns) => new __MicroComICompositor2Proxy(p, owns)); + } + + public __MicroComICompositor2Proxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 13; + } + + unsafe class __MicroComICompositor2VTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateAmbientLightDelegate(IntPtr @this, void** result); + static int CreateAmbientLight(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateAmbientLight(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateAnimationGroupDelegate(IntPtr @this, void** result); + static int CreateAnimationGroup(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateAnimationGroup(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateBackdropBrushDelegate(IntPtr @this, void** result); + static int CreateBackdropBrush(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateBackdropBrush(); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateDistantLightDelegate(IntPtr @this, void** result); + static int CreateDistantLight(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateDistantLight(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateDropShadowDelegate(IntPtr @this, void** result); + static int CreateDropShadow(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateDropShadow(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateImplicitAnimationCollectionDelegate(IntPtr @this, void** result); + static int CreateImplicitAnimationCollection(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateImplicitAnimationCollection(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateLayerVisualDelegate(IntPtr @this, void** result); + static int CreateLayerVisual(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateLayerVisual(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateMaskBrushDelegate(IntPtr @this, void** result); + static int CreateMaskBrush(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateMaskBrush(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateNineGridBrushDelegate(IntPtr @this, void** result); + static int CreateNineGridBrush(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateNineGridBrush(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreatePointLightDelegate(IntPtr @this, void** result); + static int CreatePointLight(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreatePointLight(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateSpotLightDelegate(IntPtr @this, void** result); + static int CreateSpotLight(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateSpotLight(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateStepEasingFunctionDelegate(IntPtr @this, void** result); + static int CreateStepEasingFunction(IntPtr @this, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateStepEasingFunction(); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateStepEasingFunctionWithStepCountDelegate(IntPtr @this, int stepCount, void** result); + static int CreateStepEasingFunctionWithStepCount(IntPtr @this, int stepCount, void** result) + { + ICompositor2 __target = null; + try + { + { + __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateStepEasingFunctionWithStepCount(stepCount); + *result = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositor2VTable() + { + base.AddMethod((CreateAmbientLightDelegate)CreateAmbientLight); + base.AddMethod((CreateAnimationGroupDelegate)CreateAnimationGroup); + base.AddMethod((CreateBackdropBrushDelegate)CreateBackdropBrush); + base.AddMethod((CreateDistantLightDelegate)CreateDistantLight); + base.AddMethod((CreateDropShadowDelegate)CreateDropShadow); + base.AddMethod((CreateImplicitAnimationCollectionDelegate)CreateImplicitAnimationCollection); + base.AddMethod((CreateLayerVisualDelegate)CreateLayerVisual); + base.AddMethod((CreateMaskBrushDelegate)CreateMaskBrush); + base.AddMethod((CreateNineGridBrushDelegate)CreateNineGridBrush); + base.AddMethod((CreatePointLightDelegate)CreatePointLight); + base.AddMethod((CreateSpotLightDelegate)CreateSpotLight); + base.AddMethod((CreateStepEasingFunctionDelegate)CreateStepEasingFunction); + base.AddMethod((CreateStepEasingFunctionWithStepCountDelegate)CreateStepEasingFunctionWithStepCount); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositor2), new __MicroComICompositor2VTable().CreateVTable()); + } + + unsafe internal partial class __MicroComISpriteVisualProxy : __MicroComIInspectableProxy, ISpriteVisual + { + public ICompositionBrush Brush + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetBrush failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public void SetBrush(ICompositionBrush value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetBrush failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ISpriteVisual), new Guid("08E05581-1AD1-4F97-9757-402D76E4233B"), (p, owns) => new __MicroComISpriteVisualProxy(p, owns)); + } + + public __MicroComISpriteVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComISpriteVisualVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetBrushDelegate(IntPtr @this, void** value); + static int GetBrush(IntPtr @this, void** value) + { + ISpriteVisual __target = null; + try + { + { + __target = (ISpriteVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Brush; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetBrushDelegate(IntPtr @this, void* value); + static int SetBrush(IntPtr @this, void* value) + { + ISpriteVisual __target = null; + try + { + { + __target = (ISpriteVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetBrush(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComISpriteVisualVTable() + { + base.AddMethod((GetBrushDelegate)GetBrush); + base.AddMethod((SetBrushDelegate)SetBrush); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ISpriteVisual), new __MicroComISpriteVisualVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionDrawingSurfaceInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositionDrawingSurfaceInterop + { + public Avalonia.Win32.Interop.UnmanagedMethods.POINT BeginDraw(Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject) + { + int __result; + Avalonia.Win32.Interop.UnmanagedMethods.POINT updateOffset = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, updateRect, iid, updateObject, &updateOffset, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("BeginDraw failed", __result); + return updateOffset; + } + + public void EndDraw() + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("EndDraw failed", __result); + } + + public void Resize(Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, sizePixels, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Resize failed", __result); + } + + public void Scroll(Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, scrollRect, clipRect, offsetX, offsetY, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Scroll failed", __result); + } + + public void ResumeDraw() + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("ResumeDraw failed", __result); + } + + public void SuspendDraw() + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SuspendDraw failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionDrawingSurfaceInterop), new Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE"), (p, owns) => new __MicroComICompositionDrawingSurfaceInteropProxy(p, owns)); + } + + public __MicroComICompositionDrawingSurfaceInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 6; + } + + unsafe class __MicroComICompositionDrawingSurfaceInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int BeginDrawDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject, Avalonia.Win32.Interop.UnmanagedMethods.POINT* updateOffset); + static int BeginDraw(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject, Avalonia.Win32.Interop.UnmanagedMethods.POINT* updateOffset) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.BeginDraw(updateRect, iid, updateObject); + *updateOffset = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int EndDrawDelegate(IntPtr @this); + static int EndDraw(IntPtr @this) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.EndDraw(); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int ResizeDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels); + static int Resize(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.Resize(sizePixels); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int ScrollDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY); + static int Scroll(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.Scroll(scrollRect, clipRect, offsetX, offsetY); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int ResumeDrawDelegate(IntPtr @this); + static int ResumeDraw(IntPtr @this) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.ResumeDraw(); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SuspendDrawDelegate(IntPtr @this); + static int SuspendDraw(IntPtr @this) + { + ICompositionDrawingSurfaceInterop __target = null; + try + { + { + __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SuspendDraw(); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionDrawingSurfaceInteropVTable() + { + base.AddMethod((BeginDrawDelegate)BeginDraw); + base.AddMethod((EndDrawDelegate)EndDraw); + base.AddMethod((ResizeDelegate)Resize); + base.AddMethod((ScrollDelegate)Scroll); + base.AddMethod((ResumeDrawDelegate)ResumeDraw); + base.AddMethod((SuspendDrawDelegate)SuspendDraw); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionDrawingSurfaceInterop), new __MicroComICompositionDrawingSurfaceInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionGraphicsDeviceInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositionGraphicsDeviceInterop + { + public IUnknown RenderingDevice + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRenderingDevice failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public void SetRenderingDevice(IUnknown value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRenderingDevice failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionGraphicsDeviceInterop), new Guid("A116FF71-F8BF-4C8A-9C98-70779A32A9C8"), (p, owns) => new __MicroComICompositionGraphicsDeviceInteropProxy(p, owns)); + } + + public __MicroComICompositionGraphicsDeviceInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComICompositionGraphicsDeviceInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRenderingDeviceDelegate(IntPtr @this, void** value); + static int GetRenderingDevice(IntPtr @this, void** value) + { + ICompositionGraphicsDeviceInterop __target = null; + try + { + { + __target = (ICompositionGraphicsDeviceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RenderingDevice; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRenderingDeviceDelegate(IntPtr @this, void* value); + static int SetRenderingDevice(IntPtr @this, void* value) + { + ICompositionGraphicsDeviceInterop __target = null; + try + { + { + __target = (ICompositionGraphicsDeviceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRenderingDevice(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionGraphicsDeviceInteropVTable() + { + base.AddMethod((GetRenderingDeviceDelegate)GetRenderingDevice); + base.AddMethod((SetRenderingDeviceDelegate)SetRenderingDevice); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionGraphicsDeviceInterop), new __MicroComICompositionGraphicsDeviceInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositorInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositorInterop + { + public ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain) + { + int __result; + void* __marshal_res = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, swapChain, &__marshal_res, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateCompositionSurfaceForHandle failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_res, true); + } + + public ICompositionSurface CreateCompositionSurfaceForSwapChain(IUnknown swapChain) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(swapChain), &__marshal_result, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateCompositionSurfaceForSwapChain failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public ICompositionGraphicsDevice CreateGraphicsDevice(IUnknown renderingDevice) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(renderingDevice), &__marshal_result, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateGraphicsDevice failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositorInterop), new Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330"), (p, owns) => new __MicroComICompositorInteropProxy(p, owns)); + } + + public __MicroComICompositorInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComICompositorInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateCompositionSurfaceForHandleDelegate(IntPtr @this, IntPtr swapChain, void** res); + static int CreateCompositionSurfaceForHandle(IntPtr @this, IntPtr swapChain, void** res) + { + ICompositorInterop __target = null; + try + { + { + __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateCompositionSurfaceForHandle(swapChain); + *res = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateCompositionSurfaceForSwapChainDelegate(IntPtr @this, void* swapChain, void** result); + static int CreateCompositionSurfaceForSwapChain(IntPtr @this, void* swapChain, void** result) + { + ICompositorInterop __target = null; + try + { + { + __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateCompositionSurfaceForSwapChain(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(swapChain, false)); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateGraphicsDeviceDelegate(IntPtr @this, void* renderingDevice, void** result); + static int CreateGraphicsDevice(IntPtr @this, void* renderingDevice, void** result) + { + ICompositorInterop __target = null; + try + { + { + __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateGraphicsDevice(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(renderingDevice, false)); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositorInteropVTable() + { + base.AddMethod((CreateCompositionSurfaceForHandleDelegate)CreateCompositionSurfaceForHandle); + base.AddMethod((CreateCompositionSurfaceForSwapChainDelegate)CreateCompositionSurfaceForSwapChain); + base.AddMethod((CreateGraphicsDeviceDelegate)CreateGraphicsDevice); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositorInterop), new __MicroComICompositorInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComISwapChainInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ISwapChainInterop + { + public void SetSwapChain(IUnknown swapChain) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(swapChain), (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetSwapChain failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ISwapChainInterop), new Guid("26f496a0-7f38-45fb-88f7-faaabe67dd59"), (p, owns) => new __MicroComISwapChainInteropProxy(p, owns)); + } + + public __MicroComISwapChainInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComISwapChainInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetSwapChainDelegate(IntPtr @this, void* swapChain); + static int SetSwapChain(IntPtr @this, void* swapChain) + { + ISwapChainInterop __target = null; + try + { + { + __target = (ISwapChainInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetSwapChain(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(swapChain, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComISwapChainInteropVTable() + { + base.AddMethod((SetSwapChainDelegate)SetSwapChain); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ISwapChainInterop), new __MicroComISwapChainInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositorDesktopInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositorDesktopInterop + { + public IDesktopWindowTarget CreateDesktopWindowTarget(IntPtr hwndTarget, int isTopmost) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, hwndTarget, isTopmost, &__marshal_result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateDesktopWindowTarget failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void EnsureOnThread(int threadId) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, threadId, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("EnsureOnThread failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositorDesktopInterop), new Guid("29E691FA-4567-4DCA-B319-D0F207EB6807"), (p, owns) => new __MicroComICompositorDesktopInteropProxy(p, owns)); + } + + public __MicroComICompositorDesktopInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComICompositorDesktopInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateDesktopWindowTargetDelegate(IntPtr @this, IntPtr hwndTarget, int isTopmost, void** result); + static int CreateDesktopWindowTarget(IntPtr @this, IntPtr hwndTarget, int isTopmost, void** result) + { + ICompositorDesktopInterop __target = null; + try + { + { + __target = (ICompositorDesktopInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateDesktopWindowTarget(hwndTarget, isTopmost); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int EnsureOnThreadDelegate(IntPtr @this, int threadId); + static int EnsureOnThread(IntPtr @this, int threadId) + { + ICompositorDesktopInterop __target = null; + try + { + { + __target = (ICompositorDesktopInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.EnsureOnThread(threadId); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositorDesktopInteropVTable() + { + base.AddMethod((CreateDesktopWindowTargetDelegate)CreateDesktopWindowTarget); + base.AddMethod((EnsureOnThreadDelegate)EnsureOnThread); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositorDesktopInterop), new __MicroComICompositorDesktopInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIDesktopWindowTargetInteropProxy : Avalonia.MicroCom.MicroComProxyBase, IDesktopWindowTargetInterop + { + public IntPtr HWnd + { + get + { + int __result; + IntPtr value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetHWnd failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowTargetInterop), new Guid("35DBF59E-E3F9-45B0-81E7-FE75F4145DC9"), (p, owns) => new __MicroComIDesktopWindowTargetInteropProxy(p, owns)); + } + + public __MicroComIDesktopWindowTargetInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComIDesktopWindowTargetInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetHWndDelegate(IntPtr @this, IntPtr* value); + static int GetHWnd(IntPtr @this, IntPtr* value) + { + IDesktopWindowTargetInterop __target = null; + try + { + { + __target = (IDesktopWindowTargetInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.HWnd; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIDesktopWindowTargetInteropVTable() + { + base.AddMethod((GetHWndDelegate)GetHWnd); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowTargetInterop), new __MicroComIDesktopWindowTargetInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIDesktopWindowContentBridgeInteropProxy : Avalonia.MicroCom.MicroComProxyBase, IDesktopWindowContentBridgeInterop + { + public void Initialize(ICompositor compositor, IntPtr parentHwnd) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(compositor), parentHwnd, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Initialize failed", __result); + } + + public IntPtr HWnd + { + get + { + int __result; + IntPtr value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetHWnd failed", __result); + return value; + } + } + + public float AppliedScaleFactor + { + get + { + int __result; + float value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetAppliedScaleFactor failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowContentBridgeInterop), new Guid("37642806-F421-4FD0-9F82-23AE7C776182"), (p, owns) => new __MicroComIDesktopWindowContentBridgeInteropProxy(p, owns)); + } + + public __MicroComIDesktopWindowContentBridgeInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComIDesktopWindowContentBridgeInteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InitializeDelegate(IntPtr @this, void* compositor, IntPtr parentHwnd); + static int Initialize(IntPtr @this, void* compositor, IntPtr parentHwnd) + { + IDesktopWindowContentBridgeInterop __target = null; + try + { + { + __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.Initialize(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(compositor, false), parentHwnd); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetHWndDelegate(IntPtr @this, IntPtr* value); + static int GetHWnd(IntPtr @this, IntPtr* value) + { + IDesktopWindowContentBridgeInterop __target = null; + try + { + { + __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.HWnd; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetAppliedScaleFactorDelegate(IntPtr @this, float* value); + static int GetAppliedScaleFactor(IntPtr @this, float* value) + { + IDesktopWindowContentBridgeInterop __target = null; + try + { + { + __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.AppliedScaleFactor; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIDesktopWindowContentBridgeInteropVTable() + { + base.AddMethod((InitializeDelegate)Initialize); + base.AddMethod((GetHWndDelegate)GetHWnd); + base.AddMethod((GetAppliedScaleFactorDelegate)GetAppliedScaleFactor); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowContentBridgeInterop), new __MicroComIDesktopWindowContentBridgeInteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionGraphicsDeviceProxy : __MicroComIInspectableProxy, ICompositionGraphicsDevice + { + public ICompositionDrawingSurface CreateDrawingSurface(Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, sizePixels, pixelFormat, alphaMode, &__marshal_result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateDrawingSurface failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void AddRenderingDeviceReplaced(void* handler, void* token) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, handler, token, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("AddRenderingDeviceReplaced failed", __result); + } + + public void RemoveRenderingDeviceReplaced(int token) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, token, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("RemoveRenderingDeviceReplaced failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionGraphicsDevice), new Guid("FB22C6E1-80A2-4667-9936-DBEAF6EEFE95"), (p, owns) => new __MicroComICompositionGraphicsDeviceProxy(p, owns)); + } + + public __MicroComICompositionGraphicsDeviceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComICompositionGraphicsDeviceVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateDrawingSurfaceDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode, void** result); + static int CreateDrawingSurface(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode, void** result) + { + ICompositionGraphicsDevice __target = null; + try + { + { + __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateDrawingSurface(sizePixels, pixelFormat, alphaMode); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int AddRenderingDeviceReplacedDelegate(IntPtr @this, void* handler, void* token); + static int AddRenderingDeviceReplaced(IntPtr @this, void* handler, void* token) + { + ICompositionGraphicsDevice __target = null; + try + { + { + __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.AddRenderingDeviceReplaced(handler, token); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int RemoveRenderingDeviceReplacedDelegate(IntPtr @this, int token); + static int RemoveRenderingDeviceReplaced(IntPtr @this, int token) + { + ICompositionGraphicsDevice __target = null; + try + { + { + __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.RemoveRenderingDeviceReplaced(token); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionGraphicsDeviceVTable() + { + base.AddMethod((CreateDrawingSurfaceDelegate)CreateDrawingSurface); + base.AddMethod((AddRenderingDeviceReplacedDelegate)AddRenderingDeviceReplaced); + base.AddMethod((RemoveRenderingDeviceReplacedDelegate)RemoveRenderingDeviceReplaced); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionGraphicsDevice), new __MicroComICompositionGraphicsDeviceVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionSurfaceProxy : __MicroComIInspectableProxy, ICompositionSurface + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionSurface), new Guid("1527540D-42C7-47A6-A408-668F79A90DFB"), (p, owns) => new __MicroComICompositionSurfaceProxy(p, owns)); + } + + public __MicroComICompositionSurfaceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComICompositionSurfaceVTable : __MicroComIInspectableVTable + { + public __MicroComICompositionSurfaceVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionSurface), new __MicroComICompositionSurfaceVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIDesktopWindowTargetProxy : __MicroComIInspectableProxy, IDesktopWindowTarget + { + public int IsTopmost + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetIsTopmost failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowTarget), new Guid("6329D6CA-3366-490E-9DB3-25312929AC51"), (p, owns) => new __MicroComIDesktopWindowTargetProxy(p, owns)); + } + + public __MicroComIDesktopWindowTargetProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComIDesktopWindowTargetVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetIsTopmostDelegate(IntPtr @this, int* value); + static int GetIsTopmost(IntPtr @this, int* value) + { + IDesktopWindowTarget __target = null; + try + { + { + __target = (IDesktopWindowTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.IsTopmost; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIDesktopWindowTargetVTable() + { + base.AddMethod((GetIsTopmostDelegate)GetIsTopmost); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowTarget), new __MicroComIDesktopWindowTargetVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionDrawingSurfaceProxy : __MicroComIInspectableProxy, ICompositionDrawingSurface + { + public DirectXAlphaMode AlphaMode + { + get + { + int __result; + DirectXAlphaMode value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetAlphaMode failed", __result); + return value; + } + } + + public DirectXPixelFormat PixelFormat + { + get + { + int __result; + DirectXPixelFormat value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetPixelFormat failed", __result); + return value; + } + } + + public Avalonia.Win32.Interop.UnmanagedMethods.POINT Size + { + get + { + int __result; + Avalonia.Win32.Interop.UnmanagedMethods.POINT value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionDrawingSurface), new Guid("A166C300-FAD0-4D11-9E67-E433162FF49E"), (p, owns) => new __MicroComICompositionDrawingSurfaceProxy(p, owns)); + } + + public __MicroComICompositionDrawingSurfaceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComICompositionDrawingSurfaceVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetAlphaModeDelegate(IntPtr @this, DirectXAlphaMode* value); + static int GetAlphaMode(IntPtr @this, DirectXAlphaMode* value) + { + ICompositionDrawingSurface __target = null; + try + { + { + __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.AlphaMode; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetPixelFormatDelegate(IntPtr @this, DirectXPixelFormat* value); + static int GetPixelFormat(IntPtr @this, DirectXPixelFormat* value) + { + ICompositionDrawingSurface __target = null; + try + { + { + __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.PixelFormat; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSizeDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT* value); + static int GetSize(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT* value) + { + ICompositionDrawingSurface __target = null; + try + { + { + __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Size; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionDrawingSurfaceVTable() + { + base.AddMethod((GetAlphaModeDelegate)GetAlphaMode); + base.AddMethod((GetPixelFormatDelegate)GetPixelFormat); + base.AddMethod((GetSizeDelegate)GetSize); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionDrawingSurface), new __MicroComICompositionDrawingSurfaceVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionSurfaceBrushProxy : __MicroComIInspectableProxy, ICompositionSurfaceBrush + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionSurfaceBrush), new Guid("AD016D79-1E4C-4C0D-9C29-83338C87C162"), (p, owns) => new __MicroComICompositionSurfaceBrushProxy(p, owns)); + } + + public __MicroComICompositionSurfaceBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComICompositionSurfaceBrushVTable : __MicroComIInspectableVTable + { + public __MicroComICompositionSurfaceBrushVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionSurfaceBrush), new __MicroComICompositionSurfaceBrushVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionBrushProxy : __MicroComIInspectableProxy, ICompositionBrush + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionBrush), new Guid("AB0D7608-30C0-40E9-B568-B60A6BD1FB46"), (p, owns) => new __MicroComICompositionBrushProxy(p, owns)); + } + + public __MicroComICompositionBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComICompositionBrushVTable : __MicroComIInspectableVTable + { + public __MicroComICompositionBrushVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionBrush), new __MicroComICompositionBrushVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIVisualProxy : __MicroComIInspectableProxy, IVisual + { + public System.Numerics.Vector2 AnchorPoint + { + get + { + int __result; + System.Numerics.Vector2 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetAnchorPoint failed", __result); + return value; + } + } + + public void SetAnchorPoint(System.Numerics.Vector2 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetAnchorPoint failed", __result); + } + + public CompositionBackfaceVisibility BackfaceVisibility + { + get + { + int __result; + CompositionBackfaceVisibility value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetBackfaceVisibility failed", __result); + return value; + } + } + + public void SetBackfaceVisibility(CompositionBackfaceVisibility value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetBackfaceVisibility failed", __result); + } + + public CompositionBorderMode BorderMode + { + get + { + int __result; + CompositionBorderMode value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetBorderMode failed", __result); + return value; + } + } + + public void SetBorderMode(CompositionBorderMode value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetBorderMode failed", __result); + } + + public System.Numerics.Vector3 CenterPoint + { + get + { + int __result; + System.Numerics.Vector3 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 6]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetCenterPoint failed", __result); + return value; + } + } + + public void SetCenterPoint(System.Numerics.Vector3 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 7]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetCenterPoint failed", __result); + } + + public void* Clip + { + get + { + int __result; + void* value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 8]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetClip failed", __result); + return value; + } + } + + public void SetClip(void* value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 9]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetClip failed", __result); + } + + public CompositionCompositeMode CompositeMode + { + get + { + int __result; + CompositionCompositeMode value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 10]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetCompositeMode failed", __result); + return value; + } + } + + public void SetCompositeMode(CompositionCompositeMode value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 11]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetCompositeMode failed", __result); + } + + public int IsVisible + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 12]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetIsVisible failed", __result); + return value; + } + } + + public void SetIsVisible(int value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 13]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetIsVisible failed", __result); + } + + public System.Numerics.Vector3 Offset + { + get + { + int __result; + System.Numerics.Vector3 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 14]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetOffset failed", __result); + return value; + } + } + + public void SetOffset(System.Numerics.Vector3 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 15]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetOffset failed", __result); + } + + public float Opacity + { + get + { + int __result; + float value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 16]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetOpacity failed", __result); + return value; + } + } + + public void SetOpacity(float value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 17]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetOpacity failed", __result); + } + + public System.Numerics.Quaternion Orientation + { + get + { + int __result; + System.Numerics.Quaternion value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 18]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetOrientation failed", __result); + return value; + } + } + + public void SetOrientation(System.Numerics.Quaternion value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 19]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetOrientation failed", __result); + } + + public IContainerVisual Parent + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 20]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetParent failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public float RotationAngle + { + get + { + int __result; + float value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 21]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRotationAngle failed", __result); + return value; + } + } + + public void SetRotationAngle(float value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 22]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRotationAngle failed", __result); + } + + public float RotationAngleInDegrees + { + get + { + int __result; + float value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 23]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRotationAngleInDegrees failed", __result); + return value; + } + } + + public void SetRotationAngleInDegrees(float value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 24]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRotationAngleInDegrees failed", __result); + } + + public System.Numerics.Vector3 RotationAxis + { + get + { + int __result; + System.Numerics.Vector3 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 25]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRotationAxis failed", __result); + return value; + } + } + + public void SetRotationAxis(System.Numerics.Vector3 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 26]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRotationAxis failed", __result); + } + + public System.Numerics.Vector3 Scale + { + get + { + int __result; + System.Numerics.Vector3 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 27]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetScale failed", __result); + return value; + } + } + + public void SetScale(System.Numerics.Vector3 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 28]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetScale failed", __result); + } + + public System.Numerics.Vector2 Size + { + get + { + int __result; + System.Numerics.Vector2 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 29]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); + return value; + } + } + + public void SetSize(System.Numerics.Vector2 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 30]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetSize failed", __result); + } + + public System.Numerics.Matrix4x4 TransformMatrix + { + get + { + int __result; + System.Numerics.Matrix4x4 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 31]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetTransformMatrix failed", __result); + return value; + } + } + + public void SetTransformMatrix(System.Numerics.Matrix4x4 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 32]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetTransformMatrix failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisual), new Guid("117E202D-A859-4C89-873B-C2AA566788E3"), (p, owns) => new __MicroComIVisualProxy(p, owns)); + } + + public __MicroComIVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 33; + } + + unsafe class __MicroComIVisualVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetAnchorPointDelegate(IntPtr @this, System.Numerics.Vector2* value); + static int GetAnchorPoint(IntPtr @this, System.Numerics.Vector2* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.AnchorPoint; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetAnchorPointDelegate(IntPtr @this, System.Numerics.Vector2 value); + static int SetAnchorPoint(IntPtr @this, System.Numerics.Vector2 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetAnchorPoint(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetBackfaceVisibilityDelegate(IntPtr @this, CompositionBackfaceVisibility* value); + static int GetBackfaceVisibility(IntPtr @this, CompositionBackfaceVisibility* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.BackfaceVisibility; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetBackfaceVisibilityDelegate(IntPtr @this, CompositionBackfaceVisibility value); + static int SetBackfaceVisibility(IntPtr @this, CompositionBackfaceVisibility value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetBackfaceVisibility(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetBorderModeDelegate(IntPtr @this, CompositionBorderMode* value); + static int GetBorderMode(IntPtr @this, CompositionBorderMode* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.BorderMode; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetBorderModeDelegate(IntPtr @this, CompositionBorderMode value); + static int SetBorderMode(IntPtr @this, CompositionBorderMode value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetBorderMode(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetCenterPointDelegate(IntPtr @this, System.Numerics.Vector3* value); + static int GetCenterPoint(IntPtr @this, System.Numerics.Vector3* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CenterPoint; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetCenterPointDelegate(IntPtr @this, System.Numerics.Vector3 value); + static int SetCenterPoint(IntPtr @this, System.Numerics.Vector3 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetCenterPoint(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetClipDelegate(IntPtr @this, void** value); + static int GetClip(IntPtr @this, void** value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Clip; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetClipDelegate(IntPtr @this, void* value); + static int SetClip(IntPtr @this, void* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetClip(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetCompositeModeDelegate(IntPtr @this, CompositionCompositeMode* value); + static int GetCompositeMode(IntPtr @this, CompositionCompositeMode* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CompositeMode; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetCompositeModeDelegate(IntPtr @this, CompositionCompositeMode value); + static int SetCompositeMode(IntPtr @this, CompositionCompositeMode value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetCompositeMode(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetIsVisibleDelegate(IntPtr @this, int* value); + static int GetIsVisible(IntPtr @this, int* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.IsVisible; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetIsVisibleDelegate(IntPtr @this, int value); + static int SetIsVisible(IntPtr @this, int value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetIsVisible(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetOffsetDelegate(IntPtr @this, System.Numerics.Vector3* value); + static int GetOffset(IntPtr @this, System.Numerics.Vector3* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Offset; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetOffsetDelegate(IntPtr @this, System.Numerics.Vector3 value); + static int SetOffset(IntPtr @this, System.Numerics.Vector3 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetOffset(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetOpacityDelegate(IntPtr @this, float* value); + static int GetOpacity(IntPtr @this, float* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Opacity; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetOpacityDelegate(IntPtr @this, float value); + static int SetOpacity(IntPtr @this, float value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetOpacity(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetOrientationDelegate(IntPtr @this, System.Numerics.Quaternion* value); + static int GetOrientation(IntPtr @this, System.Numerics.Quaternion* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Orientation; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetOrientationDelegate(IntPtr @this, System.Numerics.Quaternion value); + static int SetOrientation(IntPtr @this, System.Numerics.Quaternion value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetOrientation(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetParentDelegate(IntPtr @this, void** value); + static int GetParent(IntPtr @this, void** value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Parent; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRotationAngleDelegate(IntPtr @this, float* value); + static int GetRotationAngle(IntPtr @this, float* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RotationAngle; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRotationAngleDelegate(IntPtr @this, float value); + static int SetRotationAngle(IntPtr @this, float value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRotationAngle(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRotationAngleInDegreesDelegate(IntPtr @this, float* value); + static int GetRotationAngleInDegrees(IntPtr @this, float* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RotationAngleInDegrees; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRotationAngleInDegreesDelegate(IntPtr @this, float value); + static int SetRotationAngleInDegrees(IntPtr @this, float value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRotationAngleInDegrees(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRotationAxisDelegate(IntPtr @this, System.Numerics.Vector3* value); + static int GetRotationAxis(IntPtr @this, System.Numerics.Vector3* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RotationAxis; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRotationAxisDelegate(IntPtr @this, System.Numerics.Vector3 value); + static int SetRotationAxis(IntPtr @this, System.Numerics.Vector3 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRotationAxis(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetScaleDelegate(IntPtr @this, System.Numerics.Vector3* value); + static int GetScale(IntPtr @this, System.Numerics.Vector3* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Scale; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetScaleDelegate(IntPtr @this, System.Numerics.Vector3 value); + static int SetScale(IntPtr @this, System.Numerics.Vector3 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetScale(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSizeDelegate(IntPtr @this, System.Numerics.Vector2* value); + static int GetSize(IntPtr @this, System.Numerics.Vector2* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Size; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetSizeDelegate(IntPtr @this, System.Numerics.Vector2 value); + static int SetSize(IntPtr @this, System.Numerics.Vector2 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetSize(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetTransformMatrixDelegate(IntPtr @this, System.Numerics.Matrix4x4* value); + static int GetTransformMatrix(IntPtr @this, System.Numerics.Matrix4x4* value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.TransformMatrix; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetTransformMatrixDelegate(IntPtr @this, System.Numerics.Matrix4x4 value); + static int SetTransformMatrix(IntPtr @this, System.Numerics.Matrix4x4 value) + { + IVisual __target = null; + try + { + { + __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetTransformMatrix(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIVisualVTable() + { + base.AddMethod((GetAnchorPointDelegate)GetAnchorPoint); + base.AddMethod((SetAnchorPointDelegate)SetAnchorPoint); + base.AddMethod((GetBackfaceVisibilityDelegate)GetBackfaceVisibility); + base.AddMethod((SetBackfaceVisibilityDelegate)SetBackfaceVisibility); + base.AddMethod((GetBorderModeDelegate)GetBorderMode); + base.AddMethod((SetBorderModeDelegate)SetBorderMode); + base.AddMethod((GetCenterPointDelegate)GetCenterPoint); + base.AddMethod((SetCenterPointDelegate)SetCenterPoint); + base.AddMethod((GetClipDelegate)GetClip); + base.AddMethod((SetClipDelegate)SetClip); + base.AddMethod((GetCompositeModeDelegate)GetCompositeMode); + base.AddMethod((SetCompositeModeDelegate)SetCompositeMode); + base.AddMethod((GetIsVisibleDelegate)GetIsVisible); + base.AddMethod((SetIsVisibleDelegate)SetIsVisible); + base.AddMethod((GetOffsetDelegate)GetOffset); + base.AddMethod((SetOffsetDelegate)SetOffset); + base.AddMethod((GetOpacityDelegate)GetOpacity); + base.AddMethod((SetOpacityDelegate)SetOpacity); + base.AddMethod((GetOrientationDelegate)GetOrientation); + base.AddMethod((SetOrientationDelegate)SetOrientation); + base.AddMethod((GetParentDelegate)GetParent); + base.AddMethod((GetRotationAngleDelegate)GetRotationAngle); + base.AddMethod((SetRotationAngleDelegate)SetRotationAngle); + base.AddMethod((GetRotationAngleInDegreesDelegate)GetRotationAngleInDegrees); + base.AddMethod((SetRotationAngleInDegreesDelegate)SetRotationAngleInDegrees); + base.AddMethod((GetRotationAxisDelegate)GetRotationAxis); + base.AddMethod((SetRotationAxisDelegate)SetRotationAxis); + base.AddMethod((GetScaleDelegate)GetScale); + base.AddMethod((SetScaleDelegate)SetScale); + base.AddMethod((GetSizeDelegate)GetSize); + base.AddMethod((SetSizeDelegate)SetSize); + base.AddMethod((GetTransformMatrixDelegate)GetTransformMatrix); + base.AddMethod((SetTransformMatrixDelegate)SetTransformMatrix); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisual), new __MicroComIVisualVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIVisual2Proxy : __MicroComIInspectableProxy, IVisual2 + { + public IVisual ParentForTransform + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetParentForTransform failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public void SetParentForTransform(IVisual value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetParentForTransform failed", __result); + } + + public System.Numerics.Vector3 RelativeOffsetAdjustment + { + get + { + int __result; + System.Numerics.Vector3 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRelativeOffsetAdjustment failed", __result); + return value; + } + } + + public void SetRelativeOffsetAdjustment(System.Numerics.Vector3 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRelativeOffsetAdjustment failed", __result); + } + + public System.Numerics.Vector2 RelativeSizeAdjustment + { + get + { + int __result; + System.Numerics.Vector2 value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRelativeSizeAdjustment failed", __result); + return value; + } + } + + public void SetRelativeSizeAdjustment(System.Numerics.Vector2 value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRelativeSizeAdjustment failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisual2), new Guid("3052B611-56C3-4C3E-8BF3-F6E1AD473F06"), (p, owns) => new __MicroComIVisual2Proxy(p, owns)); + } + + public __MicroComIVisual2Proxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 6; + } + + unsafe class __MicroComIVisual2VTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetParentForTransformDelegate(IntPtr @this, void** value); + static int GetParentForTransform(IntPtr @this, void** value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.ParentForTransform; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetParentForTransformDelegate(IntPtr @this, void* value); + static int SetParentForTransform(IntPtr @this, void* value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetParentForTransform(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRelativeOffsetAdjustmentDelegate(IntPtr @this, System.Numerics.Vector3* value); + static int GetRelativeOffsetAdjustment(IntPtr @this, System.Numerics.Vector3* value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RelativeOffsetAdjustment; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRelativeOffsetAdjustmentDelegate(IntPtr @this, System.Numerics.Vector3 value); + static int SetRelativeOffsetAdjustment(IntPtr @this, System.Numerics.Vector3 value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRelativeOffsetAdjustment(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRelativeSizeAdjustmentDelegate(IntPtr @this, System.Numerics.Vector2* value); + static int GetRelativeSizeAdjustment(IntPtr @this, System.Numerics.Vector2* value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.RelativeSizeAdjustment; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRelativeSizeAdjustmentDelegate(IntPtr @this, System.Numerics.Vector2 value); + static int SetRelativeSizeAdjustment(IntPtr @this, System.Numerics.Vector2 value) + { + IVisual2 __target = null; + try + { + { + __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRelativeSizeAdjustment(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIVisual2VTable() + { + base.AddMethod((GetParentForTransformDelegate)GetParentForTransform); + base.AddMethod((SetParentForTransformDelegate)SetParentForTransform); + base.AddMethod((GetRelativeOffsetAdjustmentDelegate)GetRelativeOffsetAdjustment); + base.AddMethod((SetRelativeOffsetAdjustmentDelegate)SetRelativeOffsetAdjustment); + base.AddMethod((GetRelativeSizeAdjustmentDelegate)GetRelativeSizeAdjustment); + base.AddMethod((SetRelativeSizeAdjustmentDelegate)SetRelativeSizeAdjustment); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisual2), new __MicroComIVisual2VTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIContainerVisualProxy : __MicroComIInspectableProxy, IContainerVisual + { + public IVisualCollection Children + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetChildren failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IContainerVisual), new Guid("02F6BC74-ED20-4773-AFE6-D49B4A93DB32"), (p, owns) => new __MicroComIContainerVisualProxy(p, owns)); + } + + public __MicroComIContainerVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComIContainerVisualVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetChildrenDelegate(IntPtr @this, void** value); + static int GetChildren(IntPtr @this, void** value) + { + IContainerVisual __target = null; + try + { + { + __target = (IContainerVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Children; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIContainerVisualVTable() + { + base.AddMethod((GetChildrenDelegate)GetChildren); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IContainerVisual), new __MicroComIContainerVisualVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIVisualCollectionProxy : __MicroComIInspectableProxy, IVisualCollection + { + public int Count + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetCount failed", __result); + return value; + } + } + + public void InsertAbove(IVisual newChild, IVisual sibling) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), Avalonia.MicroCom.MicroComRuntime.GetNativePointer(sibling), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("InsertAbove failed", __result); + } + + public void InsertAtBottom(IVisual newChild) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("InsertAtBottom failed", __result); + } + + public void InsertAtTop(IVisual newChild) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("InsertAtTop failed", __result); + } + + public void InsertBelow(IVisual newChild, IVisual sibling) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), Avalonia.MicroCom.MicroComRuntime.GetNativePointer(sibling), (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("InsertBelow failed", __result); + } + + public void Remove(IVisual child) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(child), (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Remove failed", __result); + } + + public void RemoveAll() + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 6]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("RemoveAll failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisualCollection), new Guid("8B745505-FD3E-4A98-84A8-E949468C6BCB"), (p, owns) => new __MicroComIVisualCollectionProxy(p, owns)); + } + + public __MicroComIVisualCollectionProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 7; + } + + unsafe class __MicroComIVisualCollectionVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetCountDelegate(IntPtr @this, int* value); + static int GetCount(IntPtr @this, int* value) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Count; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InsertAboveDelegate(IntPtr @this, void* newChild, void* sibling); + static int InsertAbove(IntPtr @this, void* newChild, void* sibling) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.InsertAbove(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false), Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(sibling, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InsertAtBottomDelegate(IntPtr @this, void* newChild); + static int InsertAtBottom(IntPtr @this, void* newChild) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.InsertAtBottom(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InsertAtTopDelegate(IntPtr @this, void* newChild); + static int InsertAtTop(IntPtr @this, void* newChild) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.InsertAtTop(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int InsertBelowDelegate(IntPtr @this, void* newChild, void* sibling); + static int InsertBelow(IntPtr @this, void* newChild, void* sibling) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.InsertBelow(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false), Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(sibling, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int RemoveDelegate(IntPtr @this, void* child); + static int Remove(IntPtr @this, void* child) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.Remove(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(child, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int RemoveAllDelegate(IntPtr @this); + static int RemoveAll(IntPtr @this) + { + IVisualCollection __target = null; + try + { + { + __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.RemoveAll(); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIVisualCollectionVTable() + { + base.AddMethod((GetCountDelegate)GetCount); + base.AddMethod((InsertAboveDelegate)InsertAbove); + base.AddMethod((InsertAtBottomDelegate)InsertAtBottom); + base.AddMethod((InsertAtTopDelegate)InsertAtTop); + base.AddMethod((InsertBelowDelegate)InsertBelow); + base.AddMethod((RemoveDelegate)Remove); + base.AddMethod((RemoveAllDelegate)RemoveAll); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisualCollection), new __MicroComIVisualCollectionVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionTargetProxy : __MicroComIInspectableProxy, ICompositionTarget + { + public IVisual Root + { + get + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetRoot failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + } + + public void SetRoot(IVisual value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetRoot failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionTarget), new Guid("A1BEA8BA-D726-4663-8129-6B5E7927FFA6"), (p, owns) => new __MicroComICompositionTargetProxy(p, owns)); + } + + public __MicroComICompositionTargetProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComICompositionTargetVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetRootDelegate(IntPtr @this, void** value); + static int GetRoot(IntPtr @this, void** value) + { + ICompositionTarget __target = null; + try + { + { + __target = (ICompositionTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Root; + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetRootDelegate(IntPtr @this, void* value); + static int SetRoot(IntPtr @this, void* value) + { + ICompositionTarget __target = null; + try + { + { + __target = (ICompositionTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetRoot(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionTargetVTable() + { + base.AddMethod((GetRootDelegate)GetRoot); + base.AddMethod((SetRootDelegate)SetRoot); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionTarget), new __MicroComICompositionTargetVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIGraphicsEffectProxy : __MicroComIInspectableProxy, IGraphicsEffect + { + public IntPtr Name + { + get + { + int __result; + IntPtr name = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &name, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetName failed", __result); + return name; + } + } + + public void SetName(IntPtr name) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, name, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetName failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffect), new Guid("CB51C0CE-8FE6-4636-B202-861FAA07D8F3"), (p, owns) => new __MicroComIGraphicsEffectProxy(p, owns)); + } + + public __MicroComIGraphicsEffectProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComIGraphicsEffectVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetNameDelegate(IntPtr @this, IntPtr* name); + static int GetName(IntPtr @this, IntPtr* name) + { + IGraphicsEffect __target = null; + try + { + { + __target = (IGraphicsEffect)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Name; + *name = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetNameDelegate(IntPtr @this, IntPtr name); + static int SetName(IntPtr @this, IntPtr name) + { + IGraphicsEffect __target = null; + try + { + { + __target = (IGraphicsEffect)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetName(name); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIGraphicsEffectVTable() + { + base.AddMethod((GetNameDelegate)GetName); + base.AddMethod((SetNameDelegate)SetName); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffect), new __MicroComIGraphicsEffectVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIGraphicsEffectSourceProxy : __MicroComIInspectableProxy, IGraphicsEffectSource + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffectSource), new Guid("2D8F9DDC-4339-4EB9-9216-F9DEB75658A2"), (p, owns) => new __MicroComIGraphicsEffectSourceProxy(p, owns)); + } + + public __MicroComIGraphicsEffectSourceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComIGraphicsEffectSourceVTable : __MicroComIInspectableVTable + { + public __MicroComIGraphicsEffectSourceVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffectSource), new __MicroComIGraphicsEffectSourceVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComIGraphicsEffectD2D1InteropProxy : Avalonia.MicroCom.MicroComProxyBase, IGraphicsEffectD2D1Interop + { + public Guid EffectId + { + get + { + int __result; + Guid id = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &id, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetEffectId failed", __result); + return id; + } + } + + public void GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, name, index, mapping, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetNamedPropertyMapping failed", __result); + } + + public uint PropertyCount + { + get + { + int __result; + uint count = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &count, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetPropertyCount failed", __result); + return count; + } + } + + public IPropertyValue GetProperty(uint index) + { + int __result; + void* __marshal_value = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, index, &__marshal_value, (*PPV)[base.VTableSize + 3]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetProperty failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); + } + + public IGraphicsEffectSource GetSource(uint index) + { + int __result; + void* __marshal_source = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, index, &__marshal_source, (*PPV)[base.VTableSize + 4]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSource failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_source, true); + } + + public uint SourceCount + { + get + { + int __result; + uint count = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &count, (*PPV)[base.VTableSize + 5]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSourceCount failed", __result); + return count; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffectD2D1Interop), new Guid("2FC57384-A068-44D7-A331-30982FCF7177"), (p, owns) => new __MicroComIGraphicsEffectD2D1InteropProxy(p, owns)); + } + + public __MicroComIGraphicsEffectD2D1InteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 6; + } + + unsafe class __MicroComIGraphicsEffectD2D1InteropVTable : Avalonia.MicroCom.MicroComVtblBase + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetEffectIdDelegate(IntPtr @this, Guid* id); + static int GetEffectId(IntPtr @this, Guid* id) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.EffectId; + *id = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetNamedPropertyMappingDelegate(IntPtr @this, IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping); + static int GetNamedPropertyMapping(IntPtr @this, IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.GetNamedPropertyMapping(name, index, mapping); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetPropertyCountDelegate(IntPtr @this, uint* count); + static int GetPropertyCount(IntPtr @this, uint* count) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.PropertyCount; + *count = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetPropertyDelegate(IntPtr @this, uint index, void** value); + static int GetProperty(IntPtr @this, uint index, void** value) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetProperty(index); + *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSourceDelegate(IntPtr @this, uint index, void** source); + static int GetSource(IntPtr @this, uint index, void** source) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetSource(index); + *source = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSourceCountDelegate(IntPtr @this, uint* count); + static int GetSourceCount(IntPtr @this, uint* count) + { + IGraphicsEffectD2D1Interop __target = null; + try + { + { + __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.SourceCount; + *count = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComIGraphicsEffectD2D1InteropVTable() + { + base.AddMethod((GetEffectIdDelegate)GetEffectId); + base.AddMethod((GetNamedPropertyMappingDelegate)GetNamedPropertyMapping); + base.AddMethod((GetPropertyCountDelegate)GetPropertyCount); + base.AddMethod((GetPropertyDelegate)GetProperty); + base.AddMethod((GetSourceDelegate)GetSource); + base.AddMethod((GetSourceCountDelegate)GetSourceCount); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffectD2D1Interop), new __MicroComIGraphicsEffectD2D1InteropVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionEffectSourceParameterProxy : __MicroComIInspectableProxy, ICompositionEffectSourceParameter + { + public IntPtr Name + { + get + { + int __result; + IntPtr value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetName failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectSourceParameter), new Guid("858AB13A-3292-4E4E-B3BB-2B6C6544A6EE"), (p, owns) => new __MicroComICompositionEffectSourceParameterProxy(p, owns)); + } + + public __MicroComICompositionEffectSourceParameterProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComICompositionEffectSourceParameterVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetNameDelegate(IntPtr @this, IntPtr* value); + static int GetName(IntPtr @this, IntPtr* value) + { + ICompositionEffectSourceParameter __target = null; + try + { + { + __target = (ICompositionEffectSourceParameter)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Name; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionEffectSourceParameterVTable() + { + base.AddMethod((GetNameDelegate)GetName); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectSourceParameter), new __MicroComICompositionEffectSourceParameterVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionEffectSourceParameterFactoryProxy : __MicroComIInspectableProxy, ICompositionEffectSourceParameterFactory + { + public ICompositionEffectSourceParameter Create(IntPtr name) + { + int __result; + void* __marshal_instance = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, name, &__marshal_instance, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("Create failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_instance, true); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectSourceParameterFactory), new Guid("B3D9F276-ABA3-4724-ACF3-D0397464DB1C"), (p, owns) => new __MicroComICompositionEffectSourceParameterFactoryProxy(p, owns)); + } + + public __MicroComICompositionEffectSourceParameterFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 1; + } + + unsafe class __MicroComICompositionEffectSourceParameterFactoryVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateDelegate(IntPtr @this, IntPtr name, void** instance); + static int Create(IntPtr @this, IntPtr name, void** instance) + { + ICompositionEffectSourceParameterFactory __target = null; + try + { + { + __target = (ICompositionEffectSourceParameterFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Create(name); + *instance = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionEffectSourceParameterFactoryVTable() + { + base.AddMethod((CreateDelegate)Create); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectSourceParameterFactory), new __MicroComICompositionEffectSourceParameterFactoryVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionEffectFactoryProxy : __MicroComIInspectableProxy, ICompositionEffectFactory + { + public ICompositionEffectBrush CreateBrush() + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("CreateBrush failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public int ExtendedError + { + get + { + int __result; + int value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetExtendedError failed", __result); + return value; + } + } + + public CompositionEffectFactoryLoadStatus LoadStatus + { + get + { + int __result; + CompositionEffectFactoryLoadStatus value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetLoadStatus failed", __result); + return value; + } + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectFactory), new Guid("BE5624AF-BA7E-4510-9850-41C0B4FF74DF"), (p, owns) => new __MicroComICompositionEffectFactoryProxy(p, owns)); + } + + public __MicroComICompositionEffectFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 3; + } + + unsafe class __MicroComICompositionEffectFactoryVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int CreateBrushDelegate(IntPtr @this, void** result); + static int CreateBrush(IntPtr @this, void** result) + { + ICompositionEffectFactory __target = null; + try + { + { + __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.CreateBrush(); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetExtendedErrorDelegate(IntPtr @this, int* value); + static int GetExtendedError(IntPtr @this, int* value) + { + ICompositionEffectFactory __target = null; + try + { + { + __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.ExtendedError; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetLoadStatusDelegate(IntPtr @this, CompositionEffectFactoryLoadStatus* value); + static int GetLoadStatus(IntPtr @this, CompositionEffectFactoryLoadStatus* value) + { + ICompositionEffectFactory __target = null; + try + { + { + __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.LoadStatus; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionEffectFactoryVTable() + { + base.AddMethod((CreateBrushDelegate)CreateBrush); + base.AddMethod((GetExtendedErrorDelegate)GetExtendedError); + base.AddMethod((GetLoadStatusDelegate)GetLoadStatus); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectFactory), new __MicroComICompositionEffectFactoryVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionEffectBrushProxy : __MicroComIInspectableProxy, ICompositionEffectBrush + { + public ICompositionBrush GetSourceParameter(IntPtr name) + { + int __result; + void* __marshal_result = null; + __result = (int)LocalInterop.CalliStdCallint(PPV, name, &__marshal_result, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetSourceParameter failed", __result); + return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); + } + + public void SetSourceParameter(IntPtr name, ICompositionBrush source) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, name, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(source), (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetSourceParameter failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectBrush), new Guid("BF7F795E-83CC-44BF-A447-3E3C071789EC"), (p, owns) => new __MicroComICompositionEffectBrushProxy(p, owns)); + } + + public __MicroComICompositionEffectBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComICompositionEffectBrushVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetSourceParameterDelegate(IntPtr @this, IntPtr name, void** result); + static int GetSourceParameter(IntPtr @this, IntPtr name, void** result) + { + ICompositionEffectBrush __target = null; + try + { + { + __target = (ICompositionEffectBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.GetSourceParameter(name); + *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetSourceParameterDelegate(IntPtr @this, IntPtr name, void* source); + static int SetSourceParameter(IntPtr @this, IntPtr name, void* source) + { + ICompositionEffectBrush __target = null; + try + { + { + __target = (ICompositionEffectBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetSourceParameter(name, Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(source, false)); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionEffectBrushVTable() + { + base.AddMethod((GetSourceParameterDelegate)GetSourceParameter); + base.AddMethod((SetSourceParameterDelegate)SetSourceParameter); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectBrush), new __MicroComICompositionEffectBrushVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionBackdropBrushProxy : __MicroComIInspectableProxy, ICompositionBackdropBrush + { + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionBackdropBrush), new Guid("C5ACAE58-3898-499E-8D7F-224E91286A5D"), (p, owns) => new __MicroComICompositionBackdropBrushProxy(p, owns)); + } + + public __MicroComICompositionBackdropBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 0; + } + + unsafe class __MicroComICompositionBackdropBrushVTable : __MicroComIInspectableVTable + { + public __MicroComICompositionBackdropBrushVTable() + { + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionBackdropBrush), new __MicroComICompositionBackdropBrushVTable().CreateVTable()); + } + + unsafe internal partial class __MicroComICompositionColorBrushProxy : __MicroComIInspectableProxy, ICompositionColorBrush + { + public Avalonia.Win32.WinRT.WinRTColor Color + { + get + { + int __result; + Avalonia.Win32.WinRT.WinRTColor value = default; + __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("GetColor failed", __result); + return value; + } + } + + public void SetColor(Avalonia.Win32.WinRT.WinRTColor value) + { + int __result; + __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 1]); + if (__result != 0) + throw new System.Runtime.InteropServices.COMException("SetColor failed", __result); + } + + static internal void __MicroComModuleInit() + { + Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionColorBrush), new Guid("2B264C5E-BF35-4831-8642-CF70C20FFF2F"), (p, owns) => new __MicroComICompositionColorBrushProxy(p, owns)); + } + + public __MicroComICompositionColorBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) + { + } + + protected override int VTableSize => base.VTableSize + 2; + } + + unsafe class __MicroComICompositionColorBrushVTable : __MicroComIInspectableVTable + { + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int GetColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* value); + static int GetColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* value) + { + ICompositionColorBrush __target = null; + try + { + { + __target = (ICompositionColorBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + { + var __result = __target.Color; + *value = __result; + } + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] + delegate int SetColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor value); + static int SetColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor value) + { + ICompositionColorBrush __target = null; + try + { + { + __target = (ICompositionColorBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); + __target.SetColor(value); + } + } + catch (System.Runtime.InteropServices.COMException __com_exception__) + { + return __com_exception__.ErrorCode; + } + catch (System.Exception __exception__) + { + Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); + return unchecked((int)0x80004005u); + } + + return 0; + } + + public __MicroComICompositionColorBrushVTable() + { + base.AddMethod((GetColorDelegate)GetColor); + base.AddMethod((SetColorDelegate)SetColor); + } + + static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionColorBrush), new __MicroComICompositionColorBrushVTable().CreateVTable()); + } + + class LocalInterop + { + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, AsyncStatus arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector2 arg0, System.Numerics.Vector2 arg1, void* arg2, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* arg2, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, float arg0, float arg1, float arg2, float arg3, void* arg4, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, CompositionBatchTypes arg0, void* arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, int arg0, void* arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* arg2, void* arg3, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.Interop.UnmanagedMethods.POINT arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, int arg2, int arg3, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, int arg1, void* arg2, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, int arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, void* arg0, IntPtr arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.Interop.UnmanagedMethods.SIZE arg0, DirectXPixelFormat arg1, DirectXAlphaMode arg2, void* arg3, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector2 arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, CompositionBackfaceVisibility arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, CompositionBorderMode arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector3 arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, CompositionCompositeMode arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, float arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Quaternion arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Matrix4x4 arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* arg1, void* arg2, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, uint arg0, void* arg1, void* methodPtr) + { + throw null; + } + + static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.WinRT.WinRTColor arg0, void* methodPtr) + { + throw null; + } + } +} \ No newline at end of file diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs b/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs new file mode 100644 index 0000000000..786d698daa --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/WinRTColor.cs @@ -0,0 +1,18 @@ +using System.Runtime.InteropServices; + +namespace Avalonia.Win32.WinRT +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct WinRTColor + { + public byte A; + public byte R; + public byte G; + public byte B; + + public static WinRTColor FromArgb(byte a, byte r, byte g, byte b) => new WinRTColor() + { + A = a, R = r, G = g, B = b + }; + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRTInspectable.cs b/src/Windows/Avalonia.Win32/WinRT/WinRTInspectable.cs new file mode 100644 index 0000000000..d2ec957b8e --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/WinRTInspectable.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Avalonia.MicroCom; + +namespace Avalonia.Win32.WinRT +{ + class WinRTInspectable : IInspectable, IMicroComShadowContainer + { + public virtual void Dispose() + { + + } + + public unsafe void GetIids(ulong* iidCount, Guid** iids) + { + var interfaces = GetType().GetInterfaces().Where(typeof(IUnknown).IsAssignableFrom) + .Select(MicroComRuntime.GetGuidFor).ToArray(); + var mem = (Guid*)Marshal.AllocCoTaskMem(Unsafe.SizeOf() * interfaces.Length); + for (var c = 0; c < interfaces.Length; c++) + mem[c] = interfaces[c]; + *iids = mem; + *iidCount = (ulong) interfaces.Length; + } + + public IntPtr RuntimeClassName => NativeWinRTMethods.WindowsCreateString(GetType().FullName); + public TrustLevel TrustLevel => TrustLevel.BaseTrust; + public MicroComShadow Shadow { get; set; } + public virtual void OnReferencedFromNative() + { + } + + public virtual void OnUnreferencedFromNative() + { + } + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRTPropertyValue.cs b/src/Windows/Avalonia.Win32/WinRT/WinRTPropertyValue.cs new file mode 100644 index 0000000000..684e7ff7b5 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/WinRTPropertyValue.cs @@ -0,0 +1,89 @@ +using System; +using System.Runtime.InteropServices; + +namespace Avalonia.Win32.WinRT +{ + class WinRTPropertyValue : WinRTInspectable, IPropertyValue + { + public WinRTPropertyValue(float f) + { + Type = PropertyType.Single; + Single = f; + } + + public WinRTPropertyValue(uint u) + { + UInt32 = u; + Type = PropertyType.UInt32; + } + + public PropertyType Type { get; } + public int IsNumericScalar { get; } + public byte UInt8 { get; } + public short Int16 { get; } + public ushort UInt16 { get; } + public int Int32 { get; } + public uint UInt32 { get; } + public long Int64 { get; } + public ulong UInt64 { get; } + public float Single { get; } + public double Double { get; } + public char Char16 { get; } + public int Boolean { get; } + public IntPtr String { get; } + public Guid Guid { get; } + + private static COMException NotImplemented => new COMException("Not supported", unchecked((int)0x80004001)); + + public unsafe void GetDateTime(void* value) => throw NotImplemented; + + public unsafe void GetTimeSpan(void* value) => throw NotImplemented; + + public unsafe void GetPoint(void* value) => throw NotImplemented; + + public unsafe void GetSize(void* value) => throw NotImplemented; + + public unsafe void GetRect(void* value) => throw NotImplemented; + + public unsafe byte* GetUInt8Array(uint* __valueSize) => throw NotImplemented; + + public unsafe short* GetInt16Array(uint* __valueSize) => throw NotImplemented; + + public unsafe ushort* GetUInt16Array(uint* __valueSize) => throw NotImplemented; + + public unsafe int* GetInt32Array(uint* __valueSize) + { + throw NotImplemented; + } + + public unsafe uint* GetUInt32Array(uint* __valueSize) => throw NotImplemented; + + public unsafe long* GetInt64Array(uint* __valueSize) => throw NotImplemented; + + public unsafe ulong* GetUInt64Array(uint* __valueSize) => throw NotImplemented; + + public unsafe float* GetSingleArray(uint* __valueSize) => throw NotImplemented; + + public unsafe double* GetDoubleArray(uint* __valueSize) => throw NotImplemented; + + public unsafe char* GetChar16Array(uint* __valueSize) => throw NotImplemented; + + public unsafe int* GetBooleanArray(uint* __valueSize) => throw NotImplemented; + + public unsafe IntPtr* GetStringArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void** GetInspectableArray(uint* __valueSize) => throw NotImplemented; + + public unsafe Guid* GetGuidArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void* GetDateTimeArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void* GetTimeSpanArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void* GetPointArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void* GetSizeArray(uint* __valueSize) => throw NotImplemented; + + public unsafe void* GetRectArray(uint* __valueSize) => throw NotImplemented; + } +} diff --git a/src/Windows/Avalonia.Win32/WinRT/winrt.idl b/src/Windows/Avalonia.Win32/WinRT/winrt.idl new file mode 100644 index 0000000000..9107eecd42 --- /dev/null +++ b/src/Windows/Avalonia.Win32/WinRT/winrt.idl @@ -0,0 +1,651 @@ +@clr-namespace Avalonia.Win32.WinRT +@clr-access internal +@clr-map FLOAT float +@clr-map HSTRING IntPtr +@clr-map Vector2 System.Numerics.Vector2 +@clr-map Vector3 System.Numerics.Vector3 +@clr-map Quaternion System.Numerics.Quaternion +@clr-map Matrix4x4 System.Numerics.Matrix4x4 +@clr-map RECT Avalonia.Win32.Interop.UnmanagedMethods.RECT +@clr-map SIZE Avalonia.Win32.Interop.UnmanagedMethods.SIZE +@clr-map POINT Avalonia.Win32.Interop.UnmanagedMethods.POINT +@clr-map HWND IntPtr +@clr-map BOOL int +@clr-map DWORD int +@clr-map boolean int +@clr-map BYTE byte +@clr-map INT16 short +@clr-map INT32 int +@clr-map INT64 long +@clr-map UINT16 ushort +@clr-map UINT32 uint +@clr-map UINT64 ulong +@clr-map DOUBLE double +@clr-map GUID System.Guid +@clr-map WCHAR System.Char +@clr-map Color Avalonia.Win32.WinRT.WinRTColor + +enum TrustLevel +{ + BaseTrust, + PartialTrust, + FullTrust +} + +enum DirectXAlphaMode +{ + Unspecified, + Premultiplied, + Straight, + Ignore +} + +enum DirectXPixelFormat +{ + Unknown = 0, + R32G32B32A32Typeless = 1, + R32G32B32A32Float = 2, + R32G32B32A32UInt = 3, + R32G32B32A32Int = 4, + R32G32B32Typeless = 5, + R32G32B32Float = 6, + R32G32B32UInt = 7, + R32G32B32Int = 8, + R16G16B16A16Typeless = 9, + R16G16B16A16Float = 10, + R16G16B16A16UIntNormalized = 11, + R16G16B16A16UInt = 12, + R16G16B16A16IntNormalized = 13, + R16G16B16A16Int = 14, + R32G32Typeless = 15, + R32G32Float = 16, + R32G32UInt = 17, + R32G32Int = 18, + R32G8X24Typeless = 19, + D32FloatS8X24UInt = 20, + R32FloatX8X24Typeless = 21, + X32TypelessG8X24UInt = 22, + R10G10B10A2Typeless = 23, + R10G10B10A2UIntNormalized = 24, + R10G10B10A2UInt = 25, + R11G11B10Float = 26, + R8G8B8A8Typeless = 27, + R8G8B8A8UIntNormalized = 28, + R8G8B8A8UIntNormalizedSrgb = 29, + R8G8B8A8UInt = 30, + R8G8B8A8IntNormalized = 31, + R8G8B8A8Int = 32, + R16G16Typeless = 33, + R16G16Float = 34, + R16G16UIntNormalized = 35, + R16G16UInt = 36, + R16G16IntNormalized = 37, + R16G16Int = 38, + R32Typeless = 39, + D32Float = 40, + R32Float = 41, + R32UInt = 42, + R32Int = 43, + R24G8Typeless = 44, + D24UIntNormalizedS8UInt = 45, + R24UIntNormalizedX8Typeless = 46, + X24TypelessG8UInt = 47, + R8G8Typeless = 48, + R8G8UIntNormalized = 49, + R8G8UInt = 50, + R8G8IntNormalized = 51, + R8G8Int = 52, + R16Typeless = 53, + R16Float = 54, + D16UIntNormalized = 55, + R16UIntNormalized = 56, + R16UInt = 57, + R16IntNormalized = 58, + R16Int = 59, + R8Typeless = 60, + R8UIntNormalized = 61, + R8UInt = 62, + R8IntNormalized = 63, + R8Int = 64, + A8UIntNormalized = 65, + R1UIntNormalized = 66, + R9G9B9E5SharedExponent = 67, + R8G8B8G8UIntNormalized = 68, + G8R8G8B8UIntNormalized = 69, + BC1Typeless = 70, + BC1UIntNormalized = 71, + BC1UIntNormalizedSrgb = 72, + BC2Typeless = 73, + BC2UIntNormalized = 74, + BC2UIntNormalizedSrgb = 75, + BC3Typeless = 76, + BC3UIntNormalized = 77, + BC3UIntNormalizedSrgb = 78, + BC4Typeless = 79, + BC4UIntNormalized = 80, + BC4IntNormalized = 81, + BC5Typeless = 82, + BC5UIntNormalized = 83, + BC5IntNormalized = 84, + B5G6R5UIntNormalized = 85, + B5G5R5A1UIntNormalized = 86, + B8G8R8A8UIntNormalized = 87, + B8G8R8X8UIntNormalized = 88, + R10G10B10XRBiasA2UIntNormalized = 89, + B8G8R8A8Typeless = 90, + B8G8R8A8UIntNormalizedSrgb = 91, + B8G8R8X8Typeless = 92, + B8G8R8X8UIntNormalizedSrgb = 93, + BC6HTypeless = 94, + BC6H16UnsignedFloat = 95, + BC6H16Float = 96, + BC7Typeless = 97, + BC7UIntNormalized = 98, + BC7UIntNormalizedSrgb = 99, + Ayuv = 100, + Y410 = 101, + Y416 = 102, + NV12 = 103, + P010 = 104, + P016 = 105, + Opaque420 = 106, + Yuy2 = 107, + Y210 = 108, + Y216 = 109, + NV11 = 110, + AI44 = 111, + IA44 = 112, + P8 = 113, + A8P8 = 114, + B4G4R4A4UIntNormalized = 115, + P208 = 130, + V208 = 131, + V408 = 132, +} + +[uuid(AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90)] +interface IInspectable : IUnknown +{ + HRESULT GetIids(ulong * iidCount, Guid ** iids); + HRESULT GetRuntimeClassName( [out] IntPtr* className); + HRESULT GetTrustLevel([out] TrustLevel * trustLevel); +} + +enum PropertyType +{ + Empty = 0, + UInt8 = 1, + Int16 = 2, + UInt16 = 3, + Int32 = 4, + UInt32 = 5, + Int64 = 6, + UInt64 = 7, + Single = 8, + Double = 9, + Char16 = 10, + Boolean = 11, + String = 12, + Inspectable = 13, + DateTime = 14, + TimeSpan = 15, + Guid = 16, + Point = 17, + Size = 18, + Rect = 19, + OtherType = 20, + UInt8Array = 1025, + Int16Array = 1026, + UInt16Array = 1027, + Int32Array = 1028, + UInt32Array = 1029, + Int64Array = 1030, + UInt64Array = 1031, + SingleArray = 1032, + DoubleArray = 1033, + Char16Array = 1034, + BooleanArray = 1035, + StringArray = 1036, + InspectableArray = 1037, + DateTimeArray = 1038, + TimeSpanArray = 1039, + GuidArray = 1040, + PointArray = 1041, + SizeArray = 1042, + RectArray = 1043, + OtherTypeArray = 1044 +} + +[uuid(4BD682DD-7554-40E9-9A9B-82654EDE7E62)] +interface IPropertyValue : IInspectable +{ + [propget] HRESULT Type([out] [retval] PropertyType* value); + [propget] HRESULT IsNumericScalar([out] [retval] boolean* value); + HRESULT GetUInt8([out] [retval] BYTE* value); + HRESULT GetInt16([out] [retval] INT16* value); + HRESULT GetUInt16([out] [retval] UINT16* value); + HRESULT GetInt32([out] [retval] INT32* value); + HRESULT GetUInt32([out] [retval] UINT32* value); + HRESULT GetInt64([out] [retval] INT64* value); + HRESULT GetUInt64([out] [retval] UINT64* value); + HRESULT GetSingle([out] [retval] FLOAT* value); + HRESULT GetDouble([out] [retval] DOUBLE* value); + HRESULT GetChar16([out] [retval] WCHAR* value); + HRESULT GetBoolean([out] [retval] boolean* value); + HRESULT GetString([out] [retval] HSTRING* value); + HRESULT GetGuid([out] [retval] GUID* value); + HRESULT GetDateTime( void* value); + HRESULT GetTimeSpan(void* value); + HRESULT GetPoint(void* value); + HRESULT GetSize(void* value); + HRESULT GetRect(void* value); + HRESULT GetUInt8Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] BYTE** value); + HRESULT GetInt16Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] INT16** value); + HRESULT GetUInt16Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] UINT16** value); + HRESULT GetInt32Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] INT32** value); + HRESULT GetUInt32Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] UINT32** value); + HRESULT GetInt64Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] INT64** value); + HRESULT GetUInt64Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] UINT64** value); + HRESULT GetSingleArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] FLOAT** value); + HRESULT GetDoubleArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] DOUBLE** value); + HRESULT GetChar16Array([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] WCHAR** value); + HRESULT GetBooleanArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] boolean** value); + HRESULT GetStringArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] HSTRING** value); + HRESULT GetInspectableArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void*** value); + HRESULT GetGuidArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] GUID** value); + HRESULT GetDateTimeArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void** value); + HRESULT GetTimeSpanArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void** value); + HRESULT GetPointArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void** value); + HRESULT GetSizeArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void** value); + HRESULT GetRectArray([out] UINT32* __valueSize, [out] [size_is(, *__valueSize)] void** value); +} + +enum AsyncStatus { + Started = 0, + Completed, + Canceled, + Error, +} + +[uuid(A4ED5C81-76C9-40BD-8BE6-B1D90FB20AE7)] +interface IAsyncActionCompletedHandler : IUnknown +{ + HRESULT Invoke([in] IAsyncAction* asyncInfo, [in] AsyncStatus asyncStatus); +} + +[uuid(5A648006-843A-4DA9-865B-9D26E5DFAD7B)] +interface IAsyncAction : IInspectable +{ + HRESULT SetCompleted([in] IAsyncActionCompletedHandler* handler); + HRESULT GetCompleted([out] [retval] IAsyncActionCompletedHandler** ppv); + HRESULT GetResults(); +} + +[uuid(603E88E4-A338-4FFE-A457-A5CFB9CEB899)] +interface IDispatcherQueue : IInspectable +{ + //TODO +} + +[uuid(22F34E66-50DB-4E36-A98D-61C01B384D20)] +interface IDispatcherQueueController : IInspectable +{ + [propget] HRESULT DispatcherQueue([out] [retval] IDispatcherQueue** value); + HRESULT ShutdownQueueAsync([out] [retval] IAsyncAction** operation); +} + +[uuid(00000035-0000-0000-C000-000000000046)] +interface IActivationFactory : IInspectable +{ + HRESULT ActivateInstance([out, retval] IntPtr* instance); +} + +[flags] +enum CompositionBatchTypes +{ + None = 0x0, + Animation = 0x1, + Effect = 0x2, + InfiniteAnimation = 0x4, + AllAnimations = 0x5 +} + +[uuid(B403CA50-7F8C-4E83-985F-CC45060036D8)] +interface ICompositor : IInspectable +{ + HRESULT CreateColorKeyFrameAnimation([out] [retval] void** result); + [overload("CreateColorBrush")] HRESULT CreateColorBrush([out] [retval]void** result); + [overload("CreateColorBrush")] HRESULT CreateColorBrushWithColor([in] Color* color, [out] [retval] ICompositionColorBrush** result); + HRESULT CreateContainerVisual([out] [retval] IContainerVisual** result); + HRESULT CreateCubicBezierEasingFunction([in] Vector2 controlPoint1, [in] Vector2 controlPoint2, [out] [retval] void** result); + [overload("CreateEffectFactory")] HRESULT CreateEffectFactory([in] IGraphicsEffect* graphicsEffect, [out] [retval] ICompositionEffectFactory** result); + [overload("CreateEffectFactory")] HRESULT CreateEffectFactoryWithProperties([in] void* graphicsEffect, [in] void* animatableProperties, [out] [retval] void** result); + [overload("CreateExpressionAnimation")] HRESULT CreateExpressionAnimation([out] [retval] void** result); + [overload("CreateExpressionAnimation")] HRESULT CreateExpressionAnimationWithExpression([in] HSTRING expression, [out] [retval] void** result); + [overload("CreateInsetClip")] HRESULT CreateInsetClip([out] [retval] void** result); + [overload("CreateInsetClip")] HRESULT CreateInsetClipWithInsets([in] FLOAT leftInset, [in] FLOAT topInset, [in] FLOAT rightInset, [in] FLOAT bottomInset, [out] [retval] void** result); + HRESULT CreateLinearEasingFunction([out] [retval] void** result); + HRESULT CreatePropertySet([out] [retval] void** result); + HRESULT CreateQuaternionKeyFrameAnimation([out] [retval] void** result); + HRESULT CreateScalarKeyFrameAnimation([out] [retval] void** result); + HRESULT CreateScopedBatch([in] CompositionBatchTypes batchType, [out] [retval] void** result); + HRESULT CreateSpriteVisual([out] [retval] ISpriteVisual** result); + HRESULT CreateSurfaceBrush([out] [retval] ICompositionSurfaceBrush** result); + HRESULT CreateSurfaceBrushWithSurface([in] ICompositionSurface* surface, + [out] [retval] ICompositionSurfaceBrush** result); + HRESULT CreateTargetForCurrentView([out] [retval] void** result); + HRESULT CreateVector2KeyFrameAnimation([out] [retval] void** result); + HRESULT CreateVector3KeyFrameAnimation([out] [retval] void** result); + HRESULT CreateVector4KeyFrameAnimation([out] [retval] void** result); + HRESULT GetCommitBatch([in] CompositionBatchTypes batchType, [out] [retval] void** result); +} + +[uuid(735081DC-5E24-45DA-A38F-E32CC349A9A0)] +interface ICompositor2 : IInspectable +{ + HRESULT CreateAmbientLight([out] [retval] void** result); + HRESULT CreateAnimationGroup([out] [retval] void** result); + HRESULT CreateBackdropBrush([out] [retval] ICompositionBackdropBrush** result); + HRESULT CreateDistantLight([out] [retval] void** result); + HRESULT CreateDropShadow([out] [retval] void** result); + HRESULT CreateImplicitAnimationCollection([out] [retval] void** result); + HRESULT CreateLayerVisual([out] [retval] void** result); + HRESULT CreateMaskBrush([out] [retval] void** result); + HRESULT CreateNineGridBrush([out] [retval] void** result); + HRESULT CreatePointLight([out] [retval] void** result); + HRESULT CreateSpotLight([out] [retval] void** result); + [overload("CreateStepEasingFunction")] HRESULT CreateStepEasingFunction([out] [retval] void** result); + [overload("CreateStepEasingFunction")] HRESULT CreateStepEasingFunctionWithStepCount([in] INT32 stepCount, [out] [retval] void** result); +} + +[uuid(08E05581-1AD1-4F97-9757-402D76E4233B)] +interface ISpriteVisual : IInspectable +{ + [propget] HRESULT GetBrush([out] [retval] ICompositionBrush** value); + [propput] HRESULT SetBrush([in] ICompositionBrush* value); +} + +[uuid(FD04E6E3-FE0C-4C3C-AB19-A07601A576EE)] +interface ICompositionDrawingSurfaceInterop : IUnknown +{ + HRESULT BeginDraw(RECT* updateRect, Guid* iid, void** updateObject, [out, retval]POINT* updateOffset); + HRESULT EndDraw(); + HRESULT Resize(POINT sizePixels); + HRESULT Scroll(RECT * scrollRect, RECT * clipRect, int offsetX, int offsetY); + HRESULT ResumeDraw(); + HRESULT SuspendDraw(); +}; + +[uuid(A116FF71-F8BF-4C8A-9C98-70779A32A9C8)] +interface ICompositionGraphicsDeviceInterop : IUnknown +{ + HRESULT GetRenderingDevice([out] IUnknown ** value); + HRESULT SetRenderingDevice([out] IUnknown * value); +}; + +[uuid(25297D5C-3AD4-4C9C-B5CF-E36A38512330)] +interface ICompositorInterop : IUnknown +{ + HRESULT CreateCompositionSurfaceForHandle(IntPtr swapChain, [out] ICompositionSurface ** res); + HRESULT CreateCompositionSurfaceForSwapChain(IUnknown* swapChain, [out] ICompositionSurface ** result); + HRESULT CreateGraphicsDevice(IUnknown * renderingDevice, [out] ICompositionGraphicsDevice ** result); +}; + +[uuid(26f496a0-7f38-45fb-88f7-faaabe67dd59)] +interface ISwapChainInterop : IUnknown +{ + HRESULT SetSwapChain(IUnknown * swapChain); +}; + +/* +[uuid(2C9DB356-E70D-4642-8298-BC4AA5B4865C)] +interface ICompositionCapabilitiesInteropFactory : IInspectable +{ + HRESULT GetForWindow(IntPtr hwnd, [out] ICompositionCapabilities ** result); +}*/ + +[uuid(29E691FA-4567-4DCA-B319-D0F207EB6807)] +interface ICompositorDesktopInterop : IUnknown +{ + HRESULT CreateDesktopWindowTarget(HWND hwndTarget, BOOL isTopmost, [out] IDesktopWindowTarget ** result); + HRESULT EnsureOnThread(DWORD threadId); +}; + + +[uuid(35DBF59E-E3F9-45B0-81E7-FE75F4145DC9)] +interface IDesktopWindowTargetInterop : IUnknown +{ + HRESULT GetHWnd([out] IntPtr* value); +}; + +[uuid(37642806-F421-4FD0-9F82-23AE7C776182)] +interface IDesktopWindowContentBridgeInterop : IUnknown +{ + HRESULT Initialize(ICompositor* compositor, HWND parentHwnd); + HRESULT GetHWnd([out] IntPtr* value); + + HRESULT GetAppliedScaleFactor([out] float* value); +}; + +[uuid(FB22C6E1-80A2-4667-9936-DBEAF6EEFE95)] +interface ICompositionGraphicsDevice : IInspectable +{ + HRESULT CreateDrawingSurface([in] SIZE sizePixels, [in] DirectXPixelFormat pixelFormat, + [in] DirectXAlphaMode alphaMode, [out] [retval] ICompositionDrawingSurface** result); + HRESULT AddRenderingDeviceReplaced(void* handler, void* token); + HRESULT RemoveRenderingDeviceReplaced([in] int token); +} + +[uuid(1527540D-42C7-47A6-A408-668F79A90DFB)] +interface ICompositionSurface : IInspectable +{ +} + +[uuid(6329D6CA-3366-490E-9DB3-25312929AC51)] +interface IDesktopWindowTarget : IInspectable +{ + [propget] HRESULT IsTopmost([out] [retval] int* value); +} + + +[uuid(A166C300-FAD0-4D11-9E67-E433162FF49E)] +interface ICompositionDrawingSurface : IInspectable +{ + [propget] HRESULT GetAlphaMode([out] [retval] DirectXAlphaMode* value); + [propget] HRESULT GetPixelFormat([out] [retval] DirectXPixelFormat* value); + [propget] HRESULT GetSize([out] [retval] POINT* value); +} + + +[uuid(AD016D79-1E4C-4C0D-9C29-83338C87C162)] +interface ICompositionSurfaceBrush : IInspectable +{ + //TODO +} + +[uuid(AB0D7608-30C0-40E9-B568-B60A6BD1FB46)] +interface ICompositionBrush : IInspectable +{ +} + +enum CompositionBackfaceVisibility +{ + Inherit, + Visible, + Hidden +} + +enum CompositionBorderMode +{ + Inherit, + Soft, + Hard +} + +enum CompositionCompositeMode +{ + Inherit, + SourceOver, + DestinationInvert, + MinBlend, +} + +[uuid(117E202D-A859-4C89-873B-C2AA566788E3)] +interface IVisual : IInspectable +{ + [propget] HRESULT AnchorPoint([out] [retval] Vector2* value); + [propput] HRESULT AnchorPoint([in] Vector2 value); + [propget] HRESULT BackfaceVisibility([out] [retval] CompositionBackfaceVisibility* value); + [propput] HRESULT BackfaceVisibility([in] CompositionBackfaceVisibility value); + [propget] HRESULT BorderMode([out] [retval] CompositionBorderMode* value); + [propput] HRESULT BorderMode([in] CompositionBorderMode value); + [propget] HRESULT CenterPoint([out] [retval] Vector3* value); + [propput] HRESULT CenterPoint([in] Vector3 value); + [propget] HRESULT Clip([out] [retval]void** value); + [propput] HRESULT Clip([in] void* value); + [propget] HRESULT CompositeMode([out] [retval] CompositionCompositeMode* value); + [propput] HRESULT CompositeMode([in] CompositionCompositeMode value); + [propget] HRESULT IsVisible([out] [retval] boolean* value); + [propput] HRESULT IsVisible([in] boolean value); + [propget] HRESULT Offset([out] [retval] Vector3* value); + [propput] HRESULT Offset([in] Vector3 value); + [propget] HRESULT Opacity([out] [retval] FLOAT* value); + [propput] HRESULT Opacity([in] FLOAT value); + [propget] HRESULT Orientation([out] [retval] Quaternion* value); + [propput] HRESULT Orientation([in] Quaternion value); + [propget] HRESULT Parent([out] [retval] IContainerVisual** value); + [propget] HRESULT RotationAngle([out] [retval] FLOAT* value); + [propput] HRESULT RotationAngle([in] FLOAT value); + [propget] HRESULT RotationAngleInDegrees([out] [retval] FLOAT* value); + [propput] HRESULT RotationAngleInDegrees([in] FLOAT value); + [propget] HRESULT RotationAxis([out] [retval] Vector3* value); + [propput] HRESULT RotationAxis([in] Vector3 value); + [propget] HRESULT Scale([out] [retval] Vector3* value); + [propput] HRESULT Scale([in] Vector3 value); + [propget] HRESULT Size([out] [retval] Vector2* value); + [propput] HRESULT Size([in] Vector2 value); + [propget] HRESULT TransformMatrix([out] [retval] Matrix4x4* value); + [propput] HRESULT TransformMatrix([in] Matrix4x4 value); +} + +[uuid(3052B611-56C3-4C3E-8BF3-F6E1AD473F06)] +interface IVisual2 : IInspectable +{ + [propget] HRESULT ParentForTransform([out] [retval] IVisual** value); + [propput] HRESULT ParentForTransform([in] IVisual* value); + [propget] HRESULT RelativeOffsetAdjustment([out] [retval] Vector3* value); + [propput] HRESULT RelativeOffsetAdjustment([in] Vector3 value); + [propget] HRESULT RelativeSizeAdjustment([out] [retval] Vector2* value); + [propput] HRESULT RelativeSizeAdjustment([in] Vector2 value); +} + +[uuid(02F6BC74-ED20-4773-AFE6-D49B4A93DB32)] +interface IContainerVisual : IInspectable +{ + [propget] HRESULT GetChildren([out] [retval] IVisualCollection** value); +} + +[uuid(8B745505-FD3E-4A98-84A8-E949468C6BCB)] +interface IVisualCollection : IInspectable +{ + [propget] HRESULT GetCount([out] [retval] INT32* value); + HRESULT InsertAbove([in] IVisual* newChild, [in] IVisual* sibling); + HRESULT InsertAtBottom([in] IVisual* newChild); + HRESULT InsertAtTop([in] IVisual* newChild); + HRESULT InsertBelow([in] IVisual* newChild, [in] IVisual* sibling); + HRESULT Remove([in] IVisual* child); + HRESULT RemoveAll(); +} + +[uuid(A1BEA8BA-D726-4663-8129-6B5E7927FFA6)] +interface ICompositionTarget : IInspectable +{ + [propget] HRESULT Root([out] [retval] IVisual** value); + [propput] HRESULT Root([in] IVisual* value); +} + + +[uuid(CB51C0CE-8FE6-4636-B202-861FAA07D8F3)] +interface IGraphicsEffect : IInspectable +{ + [propget] HRESULT Name([out] [retval] HSTRING* name); + [propput] HRESULT Name([in] HSTRING name); +} + +[uuid(2D8F9DDC-4339-4EB9-9216-F9DEB75658A2)] +interface IGraphicsEffectSource : IInspectable +{ +} + +enum GRAPHICS_EFFECT_PROPERTY_MAPPING +{ + GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, + GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, + GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, + GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, + GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 +} + +[uuid(2FC57384-A068-44D7-A331-30982FCF7177)] +interface IGraphicsEffectD2D1Interop : IUnknown +{ + HRESULT GetEffectId([out] Guid* id); + HRESULT GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping); + HRESULT GetPropertyCount([out] uint* count); + HRESULT GetProperty(uint index, [out]IPropertyValue** value); + HRESULT GetSource(uint index, [out, retval] IGraphicsEffectSource** source); + HRESULT GetSourceCount([retval]uint *count); +}; + +[uuid(858AB13A-3292-4E4E-B3BB-2B6C6544A6EE)] +interface ICompositionEffectSourceParameter : IInspectable +{ + [propget] HRESULT Name([out] [retval] HSTRING* value); +} + +[uuid(B3D9F276-ABA3-4724-ACF3-D0397464DB1C)] +interface ICompositionEffectSourceParameterFactory : IInspectable +{ + HRESULT Create([in] HSTRING name, [out] [retval] ICompositionEffectSourceParameter** instance); +} + +enum CompositionEffectFactoryLoadStatus +{ + Success = 0, + EffectTooComplex = 1, + Pending = 2, + Other = -1 +} + +[uuid(BE5624AF-BA7E-4510-9850-41C0B4FF74DF)] +interface ICompositionEffectFactory : IInspectable +{ + HRESULT CreateBrush([out] [retval] ICompositionEffectBrush** result); + [propget] HRESULT ExtendedError([out] [retval] int* value); + [propget] HRESULT LoadStatus([out] [retval] CompositionEffectFactoryLoadStatus* value); +} + +[uuid(BF7F795E-83CC-44BF-A447-3E3C071789EC)] +interface ICompositionEffectBrush : IInspectable +{ + HRESULT GetSourceParameter([in] HSTRING name, [out] [retval] ICompositionBrush** result); + HRESULT SetSourceParameter([in] HSTRING name, [in] ICompositionBrush* source); +} + +[uuid(C5ACAE58-3898-499E-8D7F-224E91286A5D)] +interface ICompositionBackdropBrush : IInspectable +{ +} + +[uuid(2B264C5E-BF35-4831-8642-CF70C20FFF2F)] +interface ICompositionColorBrush : IInspectable +{ + [propget] HRESULT Color([out] [retval] Color* value); + [propput] HRESULT Color([in] Color value); +} diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 715c8fc01d..fcd92acd57 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -15,6 +15,8 @@ using Avalonia.Rendering; using Avalonia.Win32.Input; using Avalonia.Win32.Interop; using Avalonia.Win32.OpenGl; +using Avalonia.Win32.WinRT; +using Avalonia.Win32.WinRT.Composition; using static Avalonia.Win32.Interop.UnmanagedMethods; namespace Avalonia.Win32 @@ -107,7 +109,7 @@ namespace Avalonia.Win32 var glPlatform = AvaloniaLocator.Current.GetService(); - var compositionConnector = AvaloniaLocator.Current.GetService(); + var compositionConnector = AvaloniaLocator.Current.GetService(); _isUsingComposition = compositionConnector is { } && glPlatform is EglPlatformOpenGlInterface egl && @@ -121,8 +123,8 @@ namespace Avalonia.Win32 { if (_isUsingComposition) { - var cgl = new CompositionEglGlPlatformSurface(glPlatform as EglPlatformOpenGlInterface, this); - _blurHost = cgl.AttachToCompositionTree(compositionConnector, _hwnd); + var cgl = new WinUiCompositedWindowSurface(compositionConnector, this); + _blurHost = cgl; _gl = cgl; @@ -489,6 +491,8 @@ namespace Avalonia.Win32 public void Dispose() { + (_gl as IDisposable)?.Dispose(); + if (_dropTarget != null) { OleContext.Current?.UnregisterDragDrop(Handle); diff --git a/src/tools/MicroComGenerator/AstParser.cs b/src/tools/MicroComGenerator/AstParser.cs index 732c0496b3..388a8eb018 100644 --- a/src/tools/MicroComGenerator/AstParser.cs +++ b/src/tools/MicroComGenerator/AstParser.cs @@ -13,7 +13,8 @@ namespace MicroComGenerator while (!parser.Eof) { var attrs = ParseLocalAttributes(ref parser); - + if (parser.TryConsume(";")) + continue; if (parser.TryParseKeyword("enum")) idl.Enums.Add(ParseEnum(attrs, ref parser)); else if (parser.TryParseKeyword("struct")) @@ -64,7 +65,7 @@ namespace MicroComGenerator static AstAttributes ParseLocalAttributes(ref TokenParser parser) { var rv = new AstAttributes(); - if (parser.TryConsume("[")) + while (parser.TryConsume("[")) { while (!parser.TryConsume("]") && !parser.Eof) { @@ -78,7 +79,7 @@ namespace MicroComGenerator if (parser.TryConsume(']')) { rv.Add(new AstAttributeNode(ident, null)); - return rv; + break; } // No value, next attribute else if (parser.TryConsume(',')) diff --git a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs index 91ece81bd0..adb8faf938 100644 --- a/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.InterfaceGen.cs @@ -21,7 +21,7 @@ namespace MicroComGenerator { public string Name; public string NativeType; - + public AstAttributes Attributes { get; set; } public virtual StatementSyntax CreateFixed(StatementSyntax inner) => inner; public virtual void PreMarshal(List body) @@ -161,6 +161,13 @@ namespace MicroComGenerator return type; } + Arg ConvertArg(AstInterfaceMemberArgumentNode node) + { + var arg = ConvertArg(node.Name, node.Type); + arg.Attributes = node.Attributes.Clone(); + return arg; + } + Arg ConvertArg(string name, AstTypeNode type) { type = new AstTypeNode { Name = ConvertNativeType(type.Name), PointerLevel = type.PointerLevel }; @@ -190,12 +197,19 @@ namespace MicroComGenerator List vtblCtor, int num) { // Prepare method information - var args = member.Select(a => ConvertArg(a.Name, a.Type)).ToList(); + if (member.Name == "GetRenderingDevice") + Console.WriteLine(); + var args = member.Select(ConvertArg).ToList(); var returnArg = ConvertArg("__result", member.ReturnType); bool isHresult = member.ReturnType.Name == "HRESULT"; bool isHresultLastArgumentReturn = isHresult && args.Count > 0 - && (args.Last().Name == "ppv" || args.Last().Name == "retOut" || args.Last().Name == "ret") + && (args.Last().Name == "ppv" + || args.Last().Name == "retOut" + || args.Last().Name == "ret" + || args.Last().Attributes.HasAttribute("out") + || args.Last().Attributes.HasAttribute("retval") + ) && ((member.Last().Type.PointerLevel > 0 && !IsInterface(member.Last().Type)) || member.Last().Type.PointerLevel == 2); @@ -334,16 +348,27 @@ namespace MicroComGenerator BlockSyntax backBodyBlock = Block().AddStatements(backPreMarshal.ToArray()).AddStatements(backCallStatement); + var exceptions = new List() + { + CatchClause( + CatchDeclaration(ParseTypeName("System.Exception"), Identifier("__exception__")), null, + Block( + ParseStatement( + "Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__);"), + isHresult ? ParseStatement("return unchecked((int)0x80004005u);") + : isVoidReturn ? EmptyStatement() : ParseStatement("return default;") + )) + }; + + if (isHresult) + exceptions.Insert(0, CatchClause( + CatchDeclaration(ParseTypeName("System.Runtime.InteropServices.COMException"), + Identifier("__com_exception__")), + null, Block(ParseStatement("return __com_exception__.ErrorCode;")))); + backBodyBlock = Block( TryStatement( - SingletonList(CatchClause( - CatchDeclaration(ParseTypeName("System.Exception"), Identifier("__exception__")), null, - Block( - ParseStatement( - "Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__);"), - isHresult ? ParseStatement("return unchecked((int)0x80004005u);") - : isVoidReturn ? EmptyStatement() : ParseStatement("return default;") - )))) + List(exceptions)) .WithBlock(Block(backBodyBlock)) ); if (isHresult) diff --git a/src/tools/MicroComGenerator/CSharpGen.Utils.cs b/src/tools/MicroComGenerator/CSharpGen.Utils.cs index 3a62220d12..da845b0ecd 100644 --- a/src/tools/MicroComGenerator/CSharpGen.Utils.cs +++ b/src/tools/MicroComGenerator/CSharpGen.Utils.cs @@ -68,10 +68,11 @@ namespace MicroComGenerator bool IsPropertyRewriteCandidate(MethodDeclarationSyntax method) { - if(method.Identifier.Text.Contains("GetScaling")) - Console.WriteLine(); - return (method.Identifier.Text.StartsWith("Get") && - method.ParameterList.Parameters.Count == 0); + + return + method.ReturnType.ToFullString() != "void" + && method.Identifier.Text.StartsWith("Get") + && method.ParameterList.Parameters.Count == 0; } TypeDeclarationSyntax RewriteMethodsToProperties(T decl) where T : TypeDeclarationSyntax diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index 688036ffc2..c74e7af12e 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -22,7 +22,11 @@ namespace MicroComGenerator public CSharpGen(AstIdlNode idl) { _idl = idl.Clone(); - new AstRewriter().VisitAst(_idl); + new AstRewriter(_idl.Attributes.Where(a => a.Name == "clr-map") + .Select(x => x.Value.Trim().Split(' ')) + .ToDictionary(x => x[0], x => x[1]) + ).VisitAst(_idl); + _extraUsings = _idl.Attributes.Where(u => u.Name == "clr-using").Select(u => u.Value).ToList(); _namespace = _idl.GetAttribute("clr-namespace"); var visibilityString = _idl.GetAttribute("clr-access"); @@ -37,6 +41,13 @@ namespace MicroComGenerator class AstRewriter : AstVisitor { + private readonly Dictionary _typeMap = new Dictionary(); + + public AstRewriter(Dictionary typeMap) + { + _typeMap = typeMap; + } + void ConvertIntPtr(AstTypeNode type) { if (type.Name == "void" && type.PointerLevel > 0) @@ -60,6 +71,9 @@ namespace MicroComGenerator type.PointerLevel++; type.IsLink = false; } + + if (_typeMap.TryGetValue(type.Name, out var mapped)) + type.Name = mapped; base.VisitType(type); } @@ -80,6 +94,10 @@ namespace MicroComGenerator { if (member.HasAttribute("intptr")) ConvertIntPtr(member.ReturnType); + if (member.HasAttribute("propget") && !member.Name.StartsWith("Get")) + member.Name = "Get" + member.Name; + if (member.HasAttribute("propput") && !member.Name.StartsWith("Set")) + member.Name = "Set" + member.Name; base.VisitInterfaceMember(member); } } From 41e5133624326970a450999fff369d7bb38e91fa Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 02:21:30 +0300 Subject: [PATCH 092/314] Fixes --- .../WinRT/Composition/WinUICompositorConnection.cs | 8 ++++---- .../WinRT/Composition/WinUiCompositedWindowSurface.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs index 5056899106..dd0a918362 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -6,6 +6,7 @@ using Avalonia.MicroCom; using Avalonia.OpenGL; using Avalonia.OpenGL.Angle; using Avalonia.OpenGL.Egl; +using Avalonia.Rendering; using Avalonia.Win32.Interop; namespace Avalonia.Win32.WinRT.Composition @@ -29,9 +30,9 @@ namespace Avalonia.Win32.WinRT.Composition _angle = (AngleWin32EglDisplay)_gl.Display; _queue = NativeWinRTMethods.CreateDispatcherQueueController(new NativeWinRTMethods.DispatcherQueueOptions { - apartmentType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE, + apartmentType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_STA, dwSize = Marshal.SizeOf(), - threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT + threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_DEDICATED }); _compositor = NativeWinRTMethods.CreateInstance("Windows.UI.Composition.Compositor"); _compositor2 = _compositor.QueryInterface(); @@ -96,7 +97,6 @@ namespace Avalonia.Win32.WinRT.Composition spriteVisual.SetBrush(brush); using var visual = spriteVisual.QueryInterface(); using var visual2 = spriteVisual.QueryInterface(); - //visual2.SetRelativeSizeAdjustment(new Vector2(1, 1)); using var container = _compositor.CreateContainerVisual(); using var containerVisual = container.QueryInterface(); using var containerVisual2 = container.QueryInterface(); @@ -141,7 +141,7 @@ namespace Avalonia.Win32.WinRT.Composition spriteVisual.SetBrush(satBrush); - //visual.SetIsVisible(0); + visual.SetIsVisible(0); visual2.SetRelativeSizeAdjustment(new Vector2(1.0f, 1.0f)); return visual.CloneReference(); diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs index 9d80803b91..cc9952c226 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs @@ -76,9 +76,9 @@ namespace Avalonia.Win32.WinRT.Composition var res = base.BeginDraw(surface, _info, () => { - _window.Item.EndDraw(); - texture?.Dispose(); surface?.Dispose(); + texture?.Dispose(); + _window.Item.EndDraw(); contextLock?.Dispose(); }, true); success = true; From d8d4c5d58edf386310aedb4d96dea94fb0c69cd7 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 02:30:47 +0300 Subject: [PATCH 093/314] Fix codegen paths --- build/MicroCom.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/MicroCom.targets b/build/MicroCom.targets index 3577261738..b48e377fd4 100644 --- a/build/MicroCom.targets +++ b/build/MicroCom.targets @@ -2,7 +2,7 @@ - + false all true @@ -12,7 +12,7 @@ From c8b94b7fab902023e7732154b7538ed78f29ec4e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 02:36:33 +0300 Subject: [PATCH 094/314] Removed generated code --- src/Windows/Avalonia.Win32/.gitignore | 1 + .../Avalonia.Win32/WinRT/WinRT.Generated.cs | 8713 ----------------- 2 files changed, 1 insertion(+), 8713 deletions(-) create mode 100644 src/Windows/Avalonia.Win32/.gitignore delete mode 100644 src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs diff --git a/src/Windows/Avalonia.Win32/.gitignore b/src/Windows/Avalonia.Win32/.gitignore new file mode 100644 index 0000000000..7882fa6540 --- /dev/null +++ b/src/Windows/Avalonia.Win32/.gitignore @@ -0,0 +1 @@ +*.Generated.cs diff --git a/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs b/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs deleted file mode 100644 index 0968212fe0..0000000000 --- a/src/Windows/Avalonia.Win32/WinRT/WinRT.Generated.cs +++ /dev/null @@ -1,8713 +0,0 @@ -#pragma warning disable 108 -using System; -using System.Text; -using System.Collections; -using System.Collections.Generic; -using Avalonia.MicroCom; - -namespace Avalonia.Win32.WinRT -{ - internal enum TrustLevel - { - BaseTrust, - PartialTrust, - FullTrust - } - - internal enum DirectXAlphaMode - { - Unspecified, - Premultiplied, - Straight, - Ignore - } - - internal enum DirectXPixelFormat - { - Unknown = 0, - R32G32B32A32Typeless = 1, - R32G32B32A32Float = 2, - R32G32B32A32UInt = 3, - R32G32B32A32Int = 4, - R32G32B32Typeless = 5, - R32G32B32Float = 6, - R32G32B32UInt = 7, - R32G32B32Int = 8, - R16G16B16A16Typeless = 9, - R16G16B16A16Float = 10, - R16G16B16A16UIntNormalized = 11, - R16G16B16A16UInt = 12, - R16G16B16A16IntNormalized = 13, - R16G16B16A16Int = 14, - R32G32Typeless = 15, - R32G32Float = 16, - R32G32UInt = 17, - R32G32Int = 18, - R32G8X24Typeless = 19, - D32FloatS8X24UInt = 20, - R32FloatX8X24Typeless = 21, - X32TypelessG8X24UInt = 22, - R10G10B10A2Typeless = 23, - R10G10B10A2UIntNormalized = 24, - R10G10B10A2UInt = 25, - R11G11B10Float = 26, - R8G8B8A8Typeless = 27, - R8G8B8A8UIntNormalized = 28, - R8G8B8A8UIntNormalizedSrgb = 29, - R8G8B8A8UInt = 30, - R8G8B8A8IntNormalized = 31, - R8G8B8A8Int = 32, - R16G16Typeless = 33, - R16G16Float = 34, - R16G16UIntNormalized = 35, - R16G16UInt = 36, - R16G16IntNormalized = 37, - R16G16Int = 38, - R32Typeless = 39, - D32Float = 40, - R32Float = 41, - R32UInt = 42, - R32Int = 43, - R24G8Typeless = 44, - D24UIntNormalizedS8UInt = 45, - R24UIntNormalizedX8Typeless = 46, - X24TypelessG8UInt = 47, - R8G8Typeless = 48, - R8G8UIntNormalized = 49, - R8G8UInt = 50, - R8G8IntNormalized = 51, - R8G8Int = 52, - R16Typeless = 53, - R16Float = 54, - D16UIntNormalized = 55, - R16UIntNormalized = 56, - R16UInt = 57, - R16IntNormalized = 58, - R16Int = 59, - R8Typeless = 60, - R8UIntNormalized = 61, - R8UInt = 62, - R8IntNormalized = 63, - R8Int = 64, - A8UIntNormalized = 65, - R1UIntNormalized = 66, - R9G9B9E5SharedExponent = 67, - R8G8B8G8UIntNormalized = 68, - G8R8G8B8UIntNormalized = 69, - BC1Typeless = 70, - BC1UIntNormalized = 71, - BC1UIntNormalizedSrgb = 72, - BC2Typeless = 73, - BC2UIntNormalized = 74, - BC2UIntNormalizedSrgb = 75, - BC3Typeless = 76, - BC3UIntNormalized = 77, - BC3UIntNormalizedSrgb = 78, - BC4Typeless = 79, - BC4UIntNormalized = 80, - BC4IntNormalized = 81, - BC5Typeless = 82, - BC5UIntNormalized = 83, - BC5IntNormalized = 84, - B5G6R5UIntNormalized = 85, - B5G5R5A1UIntNormalized = 86, - B8G8R8A8UIntNormalized = 87, - B8G8R8X8UIntNormalized = 88, - R10G10B10XRBiasA2UIntNormalized = 89, - B8G8R8A8Typeless = 90, - B8G8R8A8UIntNormalizedSrgb = 91, - B8G8R8X8Typeless = 92, - B8G8R8X8UIntNormalizedSrgb = 93, - BC6HTypeless = 94, - BC6H16UnsignedFloat = 95, - BC6H16Float = 96, - BC7Typeless = 97, - BC7UIntNormalized = 98, - BC7UIntNormalizedSrgb = 99, - Ayuv = 100, - Y410 = 101, - Y416 = 102, - NV12 = 103, - P010 = 104, - P016 = 105, - Opaque420 = 106, - Yuy2 = 107, - Y210 = 108, - Y216 = 109, - NV11 = 110, - AI44 = 111, - IA44 = 112, - P8 = 113, - A8P8 = 114, - B4G4R4A4UIntNormalized = 115, - P208 = 130, - V208 = 131, - V408 = 132 - } - - internal enum PropertyType - { - Empty = 0, - UInt8 = 1, - Int16 = 2, - UInt16 = 3, - Int32 = 4, - UInt32 = 5, - Int64 = 6, - UInt64 = 7, - Single = 8, - Double = 9, - Char16 = 10, - Boolean = 11, - String = 12, - Inspectable = 13, - DateTime = 14, - TimeSpan = 15, - Guid = 16, - Point = 17, - Size = 18, - Rect = 19, - OtherType = 20, - UInt8Array = 1025, - Int16Array = 1026, - UInt16Array = 1027, - Int32Array = 1028, - UInt32Array = 1029, - Int64Array = 1030, - UInt64Array = 1031, - SingleArray = 1032, - DoubleArray = 1033, - Char16Array = 1034, - BooleanArray = 1035, - StringArray = 1036, - InspectableArray = 1037, - DateTimeArray = 1038, - TimeSpanArray = 1039, - GuidArray = 1040, - PointArray = 1041, - SizeArray = 1042, - RectArray = 1043, - OtherTypeArray = 1044 - } - - internal enum AsyncStatus - { - Started = 0, - Completed, - Canceled, - Error - } - - internal enum CompositionBatchTypes - { - None = 0x0, - Animation = 0x1, - Effect = 0x2, - InfiniteAnimation = 0x4, - AllAnimations = 0x5 - } - - internal enum CompositionBackfaceVisibility - { - Inherit, - Visible, - Hidden - } - - internal enum CompositionBorderMode - { - Inherit, - Soft, - Hard - } - - internal enum CompositionCompositeMode - { - Inherit, - SourceOver, - DestinationInvert, - MinBlend - } - - internal enum GRAPHICS_EFFECT_PROPERTY_MAPPING - { - GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN, - GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORX, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORY, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORZ, - GRAPHICS_EFFECT_PROPERTY_MAPPING_VECTORW, - GRAPHICS_EFFECT_PROPERTY_MAPPING_RECT_TO_VECTOR4, - GRAPHICS_EFFECT_PROPERTY_MAPPING_RADIANS_TO_DEGREES, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLORMATRIX_ALPHA_MODE, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR3, - GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4 - } - - internal enum CompositionEffectFactoryLoadStatus - { - Success = 0, - EffectTooComplex = 1, - Pending = 2, - Other = -1 - } - - internal unsafe partial interface IInspectable : Avalonia.MicroCom.IUnknown - { - void GetIids(ulong* iidCount, Guid** iids); - IntPtr RuntimeClassName - { - get; - } - - TrustLevel TrustLevel - { - get; - } - } - - internal unsafe partial interface IPropertyValue : IInspectable - { - PropertyType Type - { - get; - } - - int IsNumericScalar - { - get; - } - - byte UInt8 - { - get; - } - - short Int16 - { - get; - } - - ushort UInt16 - { - get; - } - - int Int32 - { - get; - } - - uint UInt32 - { - get; - } - - long Int64 - { - get; - } - - ulong UInt64 - { - get; - } - - float Single - { - get; - } - - double Double - { - get; - } - - System.Char Char16 - { - get; - } - - int Boolean - { - get; - } - - IntPtr String - { - get; - } - - System.Guid Guid - { - get; - } - - void GetDateTime(void* value); - void GetTimeSpan(void* value); - void GetPoint(void* value); - void GetSize(void* value); - void GetRect(void* value); - byte* GetUInt8Array(uint* __valueSize); - short* GetInt16Array(uint* __valueSize); - ushort* GetUInt16Array(uint* __valueSize); - int* GetInt32Array(uint* __valueSize); - uint* GetUInt32Array(uint* __valueSize); - long* GetInt64Array(uint* __valueSize); - ulong* GetUInt64Array(uint* __valueSize); - float* GetSingleArray(uint* __valueSize); - double* GetDoubleArray(uint* __valueSize); - System.Char* GetChar16Array(uint* __valueSize); - int* GetBooleanArray(uint* __valueSize); - IntPtr* GetStringArray(uint* __valueSize); - void** GetInspectableArray(uint* __valueSize); - System.Guid* GetGuidArray(uint* __valueSize); - void* GetDateTimeArray(uint* __valueSize); - void* GetTimeSpanArray(uint* __valueSize); - void* GetPointArray(uint* __valueSize); - void* GetSizeArray(uint* __valueSize); - void* GetRectArray(uint* __valueSize); - } - - internal unsafe partial interface IAsyncActionCompletedHandler : Avalonia.MicroCom.IUnknown - { - void Invoke(IAsyncAction asyncInfo, AsyncStatus asyncStatus); - } - - internal unsafe partial interface IAsyncAction : IInspectable - { - void SetCompleted(IAsyncActionCompletedHandler handler); - IAsyncActionCompletedHandler Completed - { - get; - } - - void GetResults(); - } - - internal unsafe partial interface IDispatcherQueue : IInspectable - { - } - - internal unsafe partial interface IDispatcherQueueController : IInspectable - { - IDispatcherQueue DispatcherQueue - { - get; - } - - IAsyncAction ShutdownQueueAsync(); - } - - internal unsafe partial interface IActivationFactory : IInspectable - { - IntPtr ActivateInstance(); - } - - internal unsafe partial interface ICompositor : IInspectable - { - void* CreateColorKeyFrameAnimation(); - void* CreateColorBrush(); - ICompositionColorBrush CreateColorBrushWithColor(Avalonia.Win32.WinRT.WinRTColor* color); - IContainerVisual CreateContainerVisual(); - void* CreateCubicBezierEasingFunction(System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2); - ICompositionEffectFactory CreateEffectFactory(IGraphicsEffect graphicsEffect); - void* CreateEffectFactoryWithProperties(void* graphicsEffect, void* animatableProperties); - void* CreateExpressionAnimation(); - void* CreateExpressionAnimationWithExpression(IntPtr expression); - void* CreateInsetClip(); - void* CreateInsetClipWithInsets(float leftInset, float topInset, float rightInset, float bottomInset); - void* CreateLinearEasingFunction(); - void* CreatePropertySet(); - void* CreateQuaternionKeyFrameAnimation(); - void* CreateScalarKeyFrameAnimation(); - void* CreateScopedBatch(CompositionBatchTypes batchType); - ISpriteVisual CreateSpriteVisual(); - ICompositionSurfaceBrush CreateSurfaceBrush(); - ICompositionSurfaceBrush CreateSurfaceBrushWithSurface(ICompositionSurface surface); - void* CreateTargetForCurrentView(); - void* CreateVector2KeyFrameAnimation(); - void* CreateVector3KeyFrameAnimation(); - void* CreateVector4KeyFrameAnimation(); - void* GetCommitBatch(CompositionBatchTypes batchType); - } - - internal unsafe partial interface ICompositor2 : IInspectable - { - void* CreateAmbientLight(); - void* CreateAnimationGroup(); - ICompositionBackdropBrush CreateBackdropBrush(); - void* CreateDistantLight(); - void* CreateDropShadow(); - void* CreateImplicitAnimationCollection(); - void* CreateLayerVisual(); - void* CreateMaskBrush(); - void* CreateNineGridBrush(); - void* CreatePointLight(); - void* CreateSpotLight(); - void* CreateStepEasingFunction(); - void* CreateStepEasingFunctionWithStepCount(int stepCount); - } - - internal unsafe partial interface ISpriteVisual : IInspectable - { - ICompositionBrush Brush - { - get; - } - - void SetBrush(ICompositionBrush value); - } - - internal unsafe partial interface ICompositionDrawingSurfaceInterop : Avalonia.MicroCom.IUnknown - { - Avalonia.Win32.Interop.UnmanagedMethods.POINT BeginDraw(Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject); - void EndDraw(); - void Resize(Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels); - void Scroll(Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY); - void ResumeDraw(); - void SuspendDraw(); - } - - internal unsafe partial interface ICompositionGraphicsDeviceInterop : Avalonia.MicroCom.IUnknown - { - IUnknown RenderingDevice - { - get; - } - - void SetRenderingDevice(IUnknown value); - } - - internal unsafe partial interface ICompositorInterop : Avalonia.MicroCom.IUnknown - { - ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain); - ICompositionSurface CreateCompositionSurfaceForSwapChain(IUnknown swapChain); - ICompositionGraphicsDevice CreateGraphicsDevice(IUnknown renderingDevice); - } - - internal unsafe partial interface ISwapChainInterop : Avalonia.MicroCom.IUnknown - { - void SetSwapChain(IUnknown swapChain); - } - - internal unsafe partial interface ICompositorDesktopInterop : Avalonia.MicroCom.IUnknown - { - IDesktopWindowTarget CreateDesktopWindowTarget(IntPtr hwndTarget, int isTopmost); - void EnsureOnThread(int threadId); - } - - internal unsafe partial interface IDesktopWindowTargetInterop : Avalonia.MicroCom.IUnknown - { - IntPtr HWnd - { - get; - } - } - - internal unsafe partial interface IDesktopWindowContentBridgeInterop : Avalonia.MicroCom.IUnknown - { - void Initialize(ICompositor compositor, IntPtr parentHwnd); - IntPtr HWnd - { - get; - } - - float AppliedScaleFactor - { - get; - } - } - - internal unsafe partial interface ICompositionGraphicsDevice : IInspectable - { - ICompositionDrawingSurface CreateDrawingSurface(Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode); - void AddRenderingDeviceReplaced(void* handler, void* token); - void RemoveRenderingDeviceReplaced(int token); - } - - internal unsafe partial interface ICompositionSurface : IInspectable - { - } - - internal unsafe partial interface IDesktopWindowTarget : IInspectable - { - int IsTopmost - { - get; - } - } - - internal unsafe partial interface ICompositionDrawingSurface : IInspectable - { - DirectXAlphaMode AlphaMode - { - get; - } - - DirectXPixelFormat PixelFormat - { - get; - } - - Avalonia.Win32.Interop.UnmanagedMethods.POINT Size - { - get; - } - } - - internal unsafe partial interface ICompositionSurfaceBrush : IInspectable - { - } - - internal unsafe partial interface ICompositionBrush : IInspectable - { - } - - internal unsafe partial interface IVisual : IInspectable - { - System.Numerics.Vector2 AnchorPoint - { - get; - } - - void SetAnchorPoint(System.Numerics.Vector2 value); - CompositionBackfaceVisibility BackfaceVisibility - { - get; - } - - void SetBackfaceVisibility(CompositionBackfaceVisibility value); - CompositionBorderMode BorderMode - { - get; - } - - void SetBorderMode(CompositionBorderMode value); - System.Numerics.Vector3 CenterPoint - { - get; - } - - void SetCenterPoint(System.Numerics.Vector3 value); - void* Clip - { - get; - } - - void SetClip(void* value); - CompositionCompositeMode CompositeMode - { - get; - } - - void SetCompositeMode(CompositionCompositeMode value); - int IsVisible - { - get; - } - - void SetIsVisible(int value); - System.Numerics.Vector3 Offset - { - get; - } - - void SetOffset(System.Numerics.Vector3 value); - float Opacity - { - get; - } - - void SetOpacity(float value); - System.Numerics.Quaternion Orientation - { - get; - } - - void SetOrientation(System.Numerics.Quaternion value); - IContainerVisual Parent - { - get; - } - - float RotationAngle - { - get; - } - - void SetRotationAngle(float value); - float RotationAngleInDegrees - { - get; - } - - void SetRotationAngleInDegrees(float value); - System.Numerics.Vector3 RotationAxis - { - get; - } - - void SetRotationAxis(System.Numerics.Vector3 value); - System.Numerics.Vector3 Scale - { - get; - } - - void SetScale(System.Numerics.Vector3 value); - System.Numerics.Vector2 Size - { - get; - } - - void SetSize(System.Numerics.Vector2 value); - System.Numerics.Matrix4x4 TransformMatrix - { - get; - } - - void SetTransformMatrix(System.Numerics.Matrix4x4 value); - } - - internal unsafe partial interface IVisual2 : IInspectable - { - IVisual ParentForTransform - { - get; - } - - void SetParentForTransform(IVisual value); - System.Numerics.Vector3 RelativeOffsetAdjustment - { - get; - } - - void SetRelativeOffsetAdjustment(System.Numerics.Vector3 value); - System.Numerics.Vector2 RelativeSizeAdjustment - { - get; - } - - void SetRelativeSizeAdjustment(System.Numerics.Vector2 value); - } - - internal unsafe partial interface IContainerVisual : IInspectable - { - IVisualCollection Children - { - get; - } - } - - internal unsafe partial interface IVisualCollection : IInspectable - { - int Count - { - get; - } - - void InsertAbove(IVisual newChild, IVisual sibling); - void InsertAtBottom(IVisual newChild); - void InsertAtTop(IVisual newChild); - void InsertBelow(IVisual newChild, IVisual sibling); - void Remove(IVisual child); - void RemoveAll(); - } - - internal unsafe partial interface ICompositionTarget : IInspectable - { - IVisual Root - { - get; - } - - void SetRoot(IVisual value); - } - - internal unsafe partial interface IGraphicsEffect : IInspectable - { - IntPtr Name - { - get; - } - - void SetName(IntPtr name); - } - - internal unsafe partial interface IGraphicsEffectSource : IInspectable - { - } - - internal unsafe partial interface IGraphicsEffectD2D1Interop : Avalonia.MicroCom.IUnknown - { - Guid EffectId - { - get; - } - - void GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping); - uint PropertyCount - { - get; - } - - IPropertyValue GetProperty(uint index); - IGraphicsEffectSource GetSource(uint index); - uint SourceCount - { - get; - } - } - - internal unsafe partial interface ICompositionEffectSourceParameter : IInspectable - { - IntPtr Name - { - get; - } - } - - internal unsafe partial interface ICompositionEffectSourceParameterFactory : IInspectable - { - ICompositionEffectSourceParameter Create(IntPtr name); - } - - internal unsafe partial interface ICompositionEffectFactory : IInspectable - { - ICompositionEffectBrush CreateBrush(); - int ExtendedError - { - get; - } - - CompositionEffectFactoryLoadStatus LoadStatus - { - get; - } - } - - internal unsafe partial interface ICompositionEffectBrush : IInspectable - { - ICompositionBrush GetSourceParameter(IntPtr name); - void SetSourceParameter(IntPtr name, ICompositionBrush source); - } - - internal unsafe partial interface ICompositionBackdropBrush : IInspectable - { - } - - internal unsafe partial interface ICompositionColorBrush : IInspectable - { - Avalonia.Win32.WinRT.WinRTColor Color - { - get; - } - - void SetColor(Avalonia.Win32.WinRT.WinRTColor value); - } -} - -namespace Avalonia.Win32.WinRT.Impl -{ - unsafe internal partial class __MicroComIInspectableProxy : Avalonia.MicroCom.MicroComProxyBase, IInspectable - { - public void GetIids(ulong* iidCount, Guid** iids) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, iidCount, iids, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetIids failed", __result); - } - - public IntPtr RuntimeClassName - { - get - { - int __result; - IntPtr className = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &className, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRuntimeClassName failed", __result); - return className; - } - } - - public TrustLevel TrustLevel - { - get - { - int __result; - TrustLevel trustLevel = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &trustLevel, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetTrustLevel failed", __result); - return trustLevel; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IInspectable), new Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90"), (p, owns) => new __MicroComIInspectableProxy(p, owns)); - } - - public __MicroComIInspectableProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComIInspectableVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetIidsDelegate(IntPtr @this, ulong* iidCount, Guid** iids); - static int GetIids(IntPtr @this, ulong* iidCount, Guid** iids) - { - IInspectable __target = null; - try - { - { - __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetIids(iidCount, iids); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRuntimeClassNameDelegate(IntPtr @this, IntPtr* className); - static int GetRuntimeClassName(IntPtr @this, IntPtr* className) - { - IInspectable __target = null; - try - { - { - __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RuntimeClassName; - *className = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetTrustLevelDelegate(IntPtr @this, TrustLevel* trustLevel); - static int GetTrustLevel(IntPtr @this, TrustLevel* trustLevel) - { - IInspectable __target = null; - try - { - { - __target = (IInspectable)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.TrustLevel; - *trustLevel = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIInspectableVTable() - { - base.AddMethod((GetIidsDelegate)GetIids); - base.AddMethod((GetRuntimeClassNameDelegate)GetRuntimeClassName); - base.AddMethod((GetTrustLevelDelegate)GetTrustLevel); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IInspectable), new __MicroComIInspectableVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIPropertyValueProxy : __MicroComIInspectableProxy, IPropertyValue - { - public PropertyType Type - { - get - { - int __result; - PropertyType value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetType failed", __result); - return value; - } - } - - public int IsNumericScalar - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetIsNumericScalar failed", __result); - return value; - } - } - - public byte UInt8 - { - get - { - int __result; - byte value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt8 failed", __result); - return value; - } - } - - public short Int16 - { - get - { - int __result; - short value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt16 failed", __result); - return value; - } - } - - public ushort UInt16 - { - get - { - int __result; - ushort value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt16 failed", __result); - return value; - } - } - - public int Int32 - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt32 failed", __result); - return value; - } - } - - public uint UInt32 - { - get - { - int __result; - uint value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 6]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt32 failed", __result); - return value; - } - } - - public long Int64 - { - get - { - int __result; - long value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 7]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt64 failed", __result); - return value; - } - } - - public ulong UInt64 - { - get - { - int __result; - ulong value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 8]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt64 failed", __result); - return value; - } - } - - public float Single - { - get - { - int __result; - float value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 9]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSingle failed", __result); - return value; - } - } - - public double Double - { - get - { - int __result; - double value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 10]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetDouble failed", __result); - return value; - } - } - - public System.Char Char16 - { - get - { - int __result; - System.Char value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 11]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetChar16 failed", __result); - return value; - } - } - - public int Boolean - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 12]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetBoolean failed", __result); - return value; - } - } - - public IntPtr String - { - get - { - int __result; - IntPtr value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 13]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetString failed", __result); - return value; - } - } - - public System.Guid Guid - { - get - { - int __result; - System.Guid value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 14]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetGuid failed", __result); - return value; - } - } - - public void GetDateTime(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 15]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetDateTime failed", __result); - } - - public void GetTimeSpan(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 16]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetTimeSpan failed", __result); - } - - public void GetPoint(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 17]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetPoint failed", __result); - } - - public void GetSize(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 18]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); - } - - public void GetRect(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 19]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRect failed", __result); - } - - public byte* GetUInt8Array(uint* __valueSize) - { - int __result; - byte* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 20]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt8Array failed", __result); - return value; - } - - public short* GetInt16Array(uint* __valueSize) - { - int __result; - short* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 21]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt16Array failed", __result); - return value; - } - - public ushort* GetUInt16Array(uint* __valueSize) - { - int __result; - ushort* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 22]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt16Array failed", __result); - return value; - } - - public int* GetInt32Array(uint* __valueSize) - { - int __result; - int* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 23]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt32Array failed", __result); - return value; - } - - public uint* GetUInt32Array(uint* __valueSize) - { - int __result; - uint* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 24]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt32Array failed", __result); - return value; - } - - public long* GetInt64Array(uint* __valueSize) - { - int __result; - long* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 25]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInt64Array failed", __result); - return value; - } - - public ulong* GetUInt64Array(uint* __valueSize) - { - int __result; - ulong* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 26]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetUInt64Array failed", __result); - return value; - } - - public float* GetSingleArray(uint* __valueSize) - { - int __result; - float* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 27]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSingleArray failed", __result); - return value; - } - - public double* GetDoubleArray(uint* __valueSize) - { - int __result; - double* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 28]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetDoubleArray failed", __result); - return value; - } - - public System.Char* GetChar16Array(uint* __valueSize) - { - int __result; - System.Char* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 29]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetChar16Array failed", __result); - return value; - } - - public int* GetBooleanArray(uint* __valueSize) - { - int __result; - int* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 30]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetBooleanArray failed", __result); - return value; - } - - public IntPtr* GetStringArray(uint* __valueSize) - { - int __result; - IntPtr* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 31]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetStringArray failed", __result); - return value; - } - - public void** GetInspectableArray(uint* __valueSize) - { - int __result; - void** value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 32]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetInspectableArray failed", __result); - return value; - } - - public System.Guid* GetGuidArray(uint* __valueSize) - { - int __result; - System.Guid* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 33]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetGuidArray failed", __result); - return value; - } - - public void* GetDateTimeArray(uint* __valueSize) - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 34]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetDateTimeArray failed", __result); - return value; - } - - public void* GetTimeSpanArray(uint* __valueSize) - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 35]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetTimeSpanArray failed", __result); - return value; - } - - public void* GetPointArray(uint* __valueSize) - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 36]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetPointArray failed", __result); - return value; - } - - public void* GetSizeArray(uint* __valueSize) - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 37]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSizeArray failed", __result); - return value; - } - - public void* GetRectArray(uint* __valueSize) - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, __valueSize, &value, (*PPV)[base.VTableSize + 38]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRectArray failed", __result); - return value; - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IPropertyValue), new Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62"), (p, owns) => new __MicroComIPropertyValueProxy(p, owns)); - } - - public __MicroComIPropertyValueProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 39; - } - - unsafe class __MicroComIPropertyValueVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetTypeDelegate(IntPtr @this, PropertyType* value); - static int GetType(IntPtr @this, PropertyType* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Type; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetIsNumericScalarDelegate(IntPtr @this, int* value); - static int GetIsNumericScalar(IntPtr @this, int* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.IsNumericScalar; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt8Delegate(IntPtr @this, byte* value); - static int GetUInt8(IntPtr @this, byte* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.UInt8; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt16Delegate(IntPtr @this, short* value); - static int GetInt16(IntPtr @this, short* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Int16; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt16Delegate(IntPtr @this, ushort* value); - static int GetUInt16(IntPtr @this, ushort* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.UInt16; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt32Delegate(IntPtr @this, int* value); - static int GetInt32(IntPtr @this, int* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Int32; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt32Delegate(IntPtr @this, uint* value); - static int GetUInt32(IntPtr @this, uint* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.UInt32; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt64Delegate(IntPtr @this, long* value); - static int GetInt64(IntPtr @this, long* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Int64; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt64Delegate(IntPtr @this, ulong* value); - static int GetUInt64(IntPtr @this, ulong* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.UInt64; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSingleDelegate(IntPtr @this, float* value); - static int GetSingle(IntPtr @this, float* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Single; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetDoubleDelegate(IntPtr @this, double* value); - static int GetDouble(IntPtr @this, double* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Double; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetChar16Delegate(IntPtr @this, System.Char* value); - static int GetChar16(IntPtr @this, System.Char* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Char16; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetBooleanDelegate(IntPtr @this, int* value); - static int GetBoolean(IntPtr @this, int* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Boolean; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetStringDelegate(IntPtr @this, IntPtr* value); - static int GetString(IntPtr @this, IntPtr* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.String; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetGuidDelegate(IntPtr @this, System.Guid* value); - static int GetGuid(IntPtr @this, System.Guid* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Guid; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetDateTimeDelegate(IntPtr @this, void* value); - static int GetDateTime(IntPtr @this, void* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetDateTime(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetTimeSpanDelegate(IntPtr @this, void* value); - static int GetTimeSpan(IntPtr @this, void* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetTimeSpan(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetPointDelegate(IntPtr @this, void* value); - static int GetPoint(IntPtr @this, void* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetPoint(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSizeDelegate(IntPtr @this, void* value); - static int GetSize(IntPtr @this, void* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetSize(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRectDelegate(IntPtr @this, void* value); - static int GetRect(IntPtr @this, void* value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetRect(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt8ArrayDelegate(IntPtr @this, uint* __valueSize, byte** value); - static int GetUInt8Array(IntPtr @this, uint* __valueSize, byte** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetUInt8Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt16ArrayDelegate(IntPtr @this, uint* __valueSize, short** value); - static int GetInt16Array(IntPtr @this, uint* __valueSize, short** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetInt16Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt16ArrayDelegate(IntPtr @this, uint* __valueSize, ushort** value); - static int GetUInt16Array(IntPtr @this, uint* __valueSize, ushort** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetUInt16Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt32ArrayDelegate(IntPtr @this, uint* __valueSize, int** value); - static int GetInt32Array(IntPtr @this, uint* __valueSize, int** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetInt32Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt32ArrayDelegate(IntPtr @this, uint* __valueSize, uint** value); - static int GetUInt32Array(IntPtr @this, uint* __valueSize, uint** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetUInt32Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInt64ArrayDelegate(IntPtr @this, uint* __valueSize, long** value); - static int GetInt64Array(IntPtr @this, uint* __valueSize, long** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetInt64Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetUInt64ArrayDelegate(IntPtr @this, uint* __valueSize, ulong** value); - static int GetUInt64Array(IntPtr @this, uint* __valueSize, ulong** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetUInt64Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSingleArrayDelegate(IntPtr @this, uint* __valueSize, float** value); - static int GetSingleArray(IntPtr @this, uint* __valueSize, float** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetSingleArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetDoubleArrayDelegate(IntPtr @this, uint* __valueSize, double** value); - static int GetDoubleArray(IntPtr @this, uint* __valueSize, double** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetDoubleArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetChar16ArrayDelegate(IntPtr @this, uint* __valueSize, System.Char** value); - static int GetChar16Array(IntPtr @this, uint* __valueSize, System.Char** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetChar16Array(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetBooleanArrayDelegate(IntPtr @this, uint* __valueSize, int** value); - static int GetBooleanArray(IntPtr @this, uint* __valueSize, int** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetBooleanArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetStringArrayDelegate(IntPtr @this, uint* __valueSize, IntPtr** value); - static int GetStringArray(IntPtr @this, uint* __valueSize, IntPtr** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetStringArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetInspectableArrayDelegate(IntPtr @this, uint* __valueSize, void*** value); - static int GetInspectableArray(IntPtr @this, uint* __valueSize, void*** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetInspectableArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetGuidArrayDelegate(IntPtr @this, uint* __valueSize, System.Guid** value); - static int GetGuidArray(IntPtr @this, uint* __valueSize, System.Guid** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetGuidArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetDateTimeArrayDelegate(IntPtr @this, uint* __valueSize, void** value); - static int GetDateTimeArray(IntPtr @this, uint* __valueSize, void** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetDateTimeArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetTimeSpanArrayDelegate(IntPtr @this, uint* __valueSize, void** value); - static int GetTimeSpanArray(IntPtr @this, uint* __valueSize, void** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetTimeSpanArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetPointArrayDelegate(IntPtr @this, uint* __valueSize, void** value); - static int GetPointArray(IntPtr @this, uint* __valueSize, void** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetPointArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSizeArrayDelegate(IntPtr @this, uint* __valueSize, void** value); - static int GetSizeArray(IntPtr @this, uint* __valueSize, void** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetSizeArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRectArrayDelegate(IntPtr @this, uint* __valueSize, void** value); - static int GetRectArray(IntPtr @this, uint* __valueSize, void** value) - { - IPropertyValue __target = null; - try - { - { - __target = (IPropertyValue)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetRectArray(__valueSize); - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIPropertyValueVTable() - { - base.AddMethod((GetTypeDelegate)GetType); - base.AddMethod((GetIsNumericScalarDelegate)GetIsNumericScalar); - base.AddMethod((GetUInt8Delegate)GetUInt8); - base.AddMethod((GetInt16Delegate)GetInt16); - base.AddMethod((GetUInt16Delegate)GetUInt16); - base.AddMethod((GetInt32Delegate)GetInt32); - base.AddMethod((GetUInt32Delegate)GetUInt32); - base.AddMethod((GetInt64Delegate)GetInt64); - base.AddMethod((GetUInt64Delegate)GetUInt64); - base.AddMethod((GetSingleDelegate)GetSingle); - base.AddMethod((GetDoubleDelegate)GetDouble); - base.AddMethod((GetChar16Delegate)GetChar16); - base.AddMethod((GetBooleanDelegate)GetBoolean); - base.AddMethod((GetStringDelegate)GetString); - base.AddMethod((GetGuidDelegate)GetGuid); - base.AddMethod((GetDateTimeDelegate)GetDateTime); - base.AddMethod((GetTimeSpanDelegate)GetTimeSpan); - base.AddMethod((GetPointDelegate)GetPoint); - base.AddMethod((GetSizeDelegate)GetSize); - base.AddMethod((GetRectDelegate)GetRect); - base.AddMethod((GetUInt8ArrayDelegate)GetUInt8Array); - base.AddMethod((GetInt16ArrayDelegate)GetInt16Array); - base.AddMethod((GetUInt16ArrayDelegate)GetUInt16Array); - base.AddMethod((GetInt32ArrayDelegate)GetInt32Array); - base.AddMethod((GetUInt32ArrayDelegate)GetUInt32Array); - base.AddMethod((GetInt64ArrayDelegate)GetInt64Array); - base.AddMethod((GetUInt64ArrayDelegate)GetUInt64Array); - base.AddMethod((GetSingleArrayDelegate)GetSingleArray); - base.AddMethod((GetDoubleArrayDelegate)GetDoubleArray); - base.AddMethod((GetChar16ArrayDelegate)GetChar16Array); - base.AddMethod((GetBooleanArrayDelegate)GetBooleanArray); - base.AddMethod((GetStringArrayDelegate)GetStringArray); - base.AddMethod((GetInspectableArrayDelegate)GetInspectableArray); - base.AddMethod((GetGuidArrayDelegate)GetGuidArray); - base.AddMethod((GetDateTimeArrayDelegate)GetDateTimeArray); - base.AddMethod((GetTimeSpanArrayDelegate)GetTimeSpanArray); - base.AddMethod((GetPointArrayDelegate)GetPointArray); - base.AddMethod((GetSizeArrayDelegate)GetSizeArray); - base.AddMethod((GetRectArrayDelegate)GetRectArray); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IPropertyValue), new __MicroComIPropertyValueVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIAsyncActionCompletedHandlerProxy : Avalonia.MicroCom.MicroComProxyBase, IAsyncActionCompletedHandler - { - public void Invoke(IAsyncAction asyncInfo, AsyncStatus asyncStatus) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(asyncInfo), asyncStatus, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Invoke failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IAsyncActionCompletedHandler), new Guid("A4ED5C81-76C9-40BD-8BE6-B1D90FB20AE7"), (p, owns) => new __MicroComIAsyncActionCompletedHandlerProxy(p, owns)); - } - - public __MicroComIAsyncActionCompletedHandlerProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComIAsyncActionCompletedHandlerVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InvokeDelegate(IntPtr @this, void* asyncInfo, AsyncStatus asyncStatus); - static int Invoke(IntPtr @this, void* asyncInfo, AsyncStatus asyncStatus) - { - IAsyncActionCompletedHandler __target = null; - try - { - { - __target = (IAsyncActionCompletedHandler)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.Invoke(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(asyncInfo, false), asyncStatus); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIAsyncActionCompletedHandlerVTable() - { - base.AddMethod((InvokeDelegate)Invoke); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IAsyncActionCompletedHandler), new __MicroComIAsyncActionCompletedHandlerVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIAsyncActionProxy : __MicroComIInspectableProxy, IAsyncAction - { - public void SetCompleted(IAsyncActionCompletedHandler handler) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(handler), (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetCompleted failed", __result); - } - - public IAsyncActionCompletedHandler Completed - { - get - { - int __result; - void* __marshal_ppv = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_ppv, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetCompleted failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_ppv, true); - } - } - - public void GetResults() - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetResults failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IAsyncAction), new Guid("5A648006-843A-4DA9-865B-9D26E5DFAD7B"), (p, owns) => new __MicroComIAsyncActionProxy(p, owns)); - } - - public __MicroComIAsyncActionProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComIAsyncActionVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetCompletedDelegate(IntPtr @this, void* handler); - static int SetCompleted(IntPtr @this, void* handler) - { - IAsyncAction __target = null; - try - { - { - __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetCompleted(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(handler, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetCompletedDelegate(IntPtr @this, void** ppv); - static int GetCompleted(IntPtr @this, void** ppv) - { - IAsyncAction __target = null; - try - { - { - __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Completed; - *ppv = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetResultsDelegate(IntPtr @this); - static int GetResults(IntPtr @this) - { - IAsyncAction __target = null; - try - { - { - __target = (IAsyncAction)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetResults(); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIAsyncActionVTable() - { - base.AddMethod((SetCompletedDelegate)SetCompleted); - base.AddMethod((GetCompletedDelegate)GetCompleted); - base.AddMethod((GetResultsDelegate)GetResults); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IAsyncAction), new __MicroComIAsyncActionVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIDispatcherQueueProxy : __MicroComIInspectableProxy, IDispatcherQueue - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDispatcherQueue), new Guid("603E88E4-A338-4FFE-A457-A5CFB9CEB899"), (p, owns) => new __MicroComIDispatcherQueueProxy(p, owns)); - } - - public __MicroComIDispatcherQueueProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComIDispatcherQueueVTable : __MicroComIInspectableVTable - { - public __MicroComIDispatcherQueueVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDispatcherQueue), new __MicroComIDispatcherQueueVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIDispatcherQueueControllerProxy : __MicroComIInspectableProxy, IDispatcherQueueController - { - public IDispatcherQueue DispatcherQueue - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetDispatcherQueue failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public IAsyncAction ShutdownQueueAsync() - { - int __result; - void* __marshal_operation = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_operation, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("ShutdownQueueAsync failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_operation, true); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDispatcherQueueController), new Guid("22F34E66-50DB-4E36-A98D-61C01B384D20"), (p, owns) => new __MicroComIDispatcherQueueControllerProxy(p, owns)); - } - - public __MicroComIDispatcherQueueControllerProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComIDispatcherQueueControllerVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetDispatcherQueueDelegate(IntPtr @this, void** value); - static int GetDispatcherQueue(IntPtr @this, void** value) - { - IDispatcherQueueController __target = null; - try - { - { - __target = (IDispatcherQueueController)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.DispatcherQueue; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int ShutdownQueueAsyncDelegate(IntPtr @this, void** operation); - static int ShutdownQueueAsync(IntPtr @this, void** operation) - { - IDispatcherQueueController __target = null; - try - { - { - __target = (IDispatcherQueueController)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.ShutdownQueueAsync(); - *operation = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIDispatcherQueueControllerVTable() - { - base.AddMethod((GetDispatcherQueueDelegate)GetDispatcherQueue); - base.AddMethod((ShutdownQueueAsyncDelegate)ShutdownQueueAsync); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDispatcherQueueController), new __MicroComIDispatcherQueueControllerVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIActivationFactoryProxy : __MicroComIInspectableProxy, IActivationFactory - { - public IntPtr ActivateInstance() - { - int __result; - IntPtr instance = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &instance, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("ActivateInstance failed", __result); - return instance; - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IActivationFactory), new Guid("00000035-0000-0000-C000-000000000046"), (p, owns) => new __MicroComIActivationFactoryProxy(p, owns)); - } - - public __MicroComIActivationFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComIActivationFactoryVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int ActivateInstanceDelegate(IntPtr @this, IntPtr* instance); - static int ActivateInstance(IntPtr @this, IntPtr* instance) - { - IActivationFactory __target = null; - try - { - { - __target = (IActivationFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.ActivateInstance(); - *instance = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIActivationFactoryVTable() - { - base.AddMethod((ActivateInstanceDelegate)ActivateInstance); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IActivationFactory), new __MicroComIActivationFactoryVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositorProxy : __MicroComIInspectableProxy, ICompositor - { - public void* CreateColorKeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateColorKeyFrameAnimation failed", __result); - return result; - } - - public void* CreateColorBrush() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateColorBrush failed", __result); - return result; - } - - public ICompositionColorBrush CreateColorBrushWithColor(Avalonia.Win32.WinRT.WinRTColor* color) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, color, &__marshal_result, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateColorBrushWithColor failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public IContainerVisual CreateContainerVisual() - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateContainerVisual failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void* CreateCubicBezierEasingFunction(System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, controlPoint1, controlPoint2, &result, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateCubicBezierEasingFunction failed", __result); - return result; - } - - public ICompositionEffectFactory CreateEffectFactory(IGraphicsEffect graphicsEffect) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(graphicsEffect), &__marshal_result, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateEffectFactory failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void* CreateEffectFactoryWithProperties(void* graphicsEffect, void* animatableProperties) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, graphicsEffect, animatableProperties, &result, (*PPV)[base.VTableSize + 6]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateEffectFactoryWithProperties failed", __result); - return result; - } - - public void* CreateExpressionAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 7]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateExpressionAnimation failed", __result); - return result; - } - - public void* CreateExpressionAnimationWithExpression(IntPtr expression) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, expression, &result, (*PPV)[base.VTableSize + 8]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateExpressionAnimationWithExpression failed", __result); - return result; - } - - public void* CreateInsetClip() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 9]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateInsetClip failed", __result); - return result; - } - - public void* CreateInsetClipWithInsets(float leftInset, float topInset, float rightInset, float bottomInset) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, leftInset, topInset, rightInset, bottomInset, &result, (*PPV)[base.VTableSize + 10]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateInsetClipWithInsets failed", __result); - return result; - } - - public void* CreateLinearEasingFunction() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 11]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateLinearEasingFunction failed", __result); - return result; - } - - public void* CreatePropertySet() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 12]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreatePropertySet failed", __result); - return result; - } - - public void* CreateQuaternionKeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 13]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateQuaternionKeyFrameAnimation failed", __result); - return result; - } - - public void* CreateScalarKeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 14]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateScalarKeyFrameAnimation failed", __result); - return result; - } - - public void* CreateScopedBatch(CompositionBatchTypes batchType) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, batchType, &result, (*PPV)[base.VTableSize + 15]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateScopedBatch failed", __result); - return result; - } - - public ISpriteVisual CreateSpriteVisual() - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 16]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateSpriteVisual failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public ICompositionSurfaceBrush CreateSurfaceBrush() - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 17]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateSurfaceBrush failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public ICompositionSurfaceBrush CreateSurfaceBrushWithSurface(ICompositionSurface surface) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(surface), &__marshal_result, (*PPV)[base.VTableSize + 18]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateSurfaceBrushWithSurface failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void* CreateTargetForCurrentView() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 19]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateTargetForCurrentView failed", __result); - return result; - } - - public void* CreateVector2KeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 20]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateVector2KeyFrameAnimation failed", __result); - return result; - } - - public void* CreateVector3KeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 21]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateVector3KeyFrameAnimation failed", __result); - return result; - } - - public void* CreateVector4KeyFrameAnimation() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 22]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateVector4KeyFrameAnimation failed", __result); - return result; - } - - public void* GetCommitBatch(CompositionBatchTypes batchType) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, batchType, &result, (*PPV)[base.VTableSize + 23]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetCommitBatch failed", __result); - return result; - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositor), new Guid("B403CA50-7F8C-4E83-985F-CC45060036D8"), (p, owns) => new __MicroComICompositorProxy(p, owns)); - } - - public __MicroComICompositorProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 24; - } - - unsafe class __MicroComICompositorVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateColorKeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateColorKeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateColorKeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateColorBrushDelegate(IntPtr @this, void** result); - static int CreateColorBrush(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateColorBrush(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateColorBrushWithColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* color, void** result); - static int CreateColorBrushWithColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* color, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateColorBrushWithColor(color); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateContainerVisualDelegate(IntPtr @this, void** result); - static int CreateContainerVisual(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateContainerVisual(); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateCubicBezierEasingFunctionDelegate(IntPtr @this, System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2, void** result); - static int CreateCubicBezierEasingFunction(IntPtr @this, System.Numerics.Vector2 controlPoint1, System.Numerics.Vector2 controlPoint2, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateCubicBezierEasingFunction(controlPoint1, controlPoint2); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateEffectFactoryDelegate(IntPtr @this, void* graphicsEffect, void** result); - static int CreateEffectFactory(IntPtr @this, void* graphicsEffect, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateEffectFactory(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(graphicsEffect, false)); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateEffectFactoryWithPropertiesDelegate(IntPtr @this, void* graphicsEffect, void* animatableProperties, void** result); - static int CreateEffectFactoryWithProperties(IntPtr @this, void* graphicsEffect, void* animatableProperties, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateEffectFactoryWithProperties(graphicsEffect, animatableProperties); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateExpressionAnimationDelegate(IntPtr @this, void** result); - static int CreateExpressionAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateExpressionAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateExpressionAnimationWithExpressionDelegate(IntPtr @this, IntPtr expression, void** result); - static int CreateExpressionAnimationWithExpression(IntPtr @this, IntPtr expression, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateExpressionAnimationWithExpression(expression); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateInsetClipDelegate(IntPtr @this, void** result); - static int CreateInsetClip(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateInsetClip(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateInsetClipWithInsetsDelegate(IntPtr @this, float leftInset, float topInset, float rightInset, float bottomInset, void** result); - static int CreateInsetClipWithInsets(IntPtr @this, float leftInset, float topInset, float rightInset, float bottomInset, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateInsetClipWithInsets(leftInset, topInset, rightInset, bottomInset); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateLinearEasingFunctionDelegate(IntPtr @this, void** result); - static int CreateLinearEasingFunction(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateLinearEasingFunction(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreatePropertySetDelegate(IntPtr @this, void** result); - static int CreatePropertySet(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreatePropertySet(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateQuaternionKeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateQuaternionKeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateQuaternionKeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateScalarKeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateScalarKeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateScalarKeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateScopedBatchDelegate(IntPtr @this, CompositionBatchTypes batchType, void** result); - static int CreateScopedBatch(IntPtr @this, CompositionBatchTypes batchType, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateScopedBatch(batchType); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateSpriteVisualDelegate(IntPtr @this, void** result); - static int CreateSpriteVisual(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateSpriteVisual(); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateSurfaceBrushDelegate(IntPtr @this, void** result); - static int CreateSurfaceBrush(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateSurfaceBrush(); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateSurfaceBrushWithSurfaceDelegate(IntPtr @this, void* surface, void** result); - static int CreateSurfaceBrushWithSurface(IntPtr @this, void* surface, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateSurfaceBrushWithSurface(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(surface, false)); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateTargetForCurrentViewDelegate(IntPtr @this, void** result); - static int CreateTargetForCurrentView(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateTargetForCurrentView(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateVector2KeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateVector2KeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateVector2KeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateVector3KeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateVector3KeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateVector3KeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateVector4KeyFrameAnimationDelegate(IntPtr @this, void** result); - static int CreateVector4KeyFrameAnimation(IntPtr @this, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateVector4KeyFrameAnimation(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetCommitBatchDelegate(IntPtr @this, CompositionBatchTypes batchType, void** result); - static int GetCommitBatch(IntPtr @this, CompositionBatchTypes batchType, void** result) - { - ICompositor __target = null; - try - { - { - __target = (ICompositor)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetCommitBatch(batchType); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositorVTable() - { - base.AddMethod((CreateColorKeyFrameAnimationDelegate)CreateColorKeyFrameAnimation); - base.AddMethod((CreateColorBrushDelegate)CreateColorBrush); - base.AddMethod((CreateColorBrushWithColorDelegate)CreateColorBrushWithColor); - base.AddMethod((CreateContainerVisualDelegate)CreateContainerVisual); - base.AddMethod((CreateCubicBezierEasingFunctionDelegate)CreateCubicBezierEasingFunction); - base.AddMethod((CreateEffectFactoryDelegate)CreateEffectFactory); - base.AddMethod((CreateEffectFactoryWithPropertiesDelegate)CreateEffectFactoryWithProperties); - base.AddMethod((CreateExpressionAnimationDelegate)CreateExpressionAnimation); - base.AddMethod((CreateExpressionAnimationWithExpressionDelegate)CreateExpressionAnimationWithExpression); - base.AddMethod((CreateInsetClipDelegate)CreateInsetClip); - base.AddMethod((CreateInsetClipWithInsetsDelegate)CreateInsetClipWithInsets); - base.AddMethod((CreateLinearEasingFunctionDelegate)CreateLinearEasingFunction); - base.AddMethod((CreatePropertySetDelegate)CreatePropertySet); - base.AddMethod((CreateQuaternionKeyFrameAnimationDelegate)CreateQuaternionKeyFrameAnimation); - base.AddMethod((CreateScalarKeyFrameAnimationDelegate)CreateScalarKeyFrameAnimation); - base.AddMethod((CreateScopedBatchDelegate)CreateScopedBatch); - base.AddMethod((CreateSpriteVisualDelegate)CreateSpriteVisual); - base.AddMethod((CreateSurfaceBrushDelegate)CreateSurfaceBrush); - base.AddMethod((CreateSurfaceBrushWithSurfaceDelegate)CreateSurfaceBrushWithSurface); - base.AddMethod((CreateTargetForCurrentViewDelegate)CreateTargetForCurrentView); - base.AddMethod((CreateVector2KeyFrameAnimationDelegate)CreateVector2KeyFrameAnimation); - base.AddMethod((CreateVector3KeyFrameAnimationDelegate)CreateVector3KeyFrameAnimation); - base.AddMethod((CreateVector4KeyFrameAnimationDelegate)CreateVector4KeyFrameAnimation); - base.AddMethod((GetCommitBatchDelegate)GetCommitBatch); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositor), new __MicroComICompositorVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositor2Proxy : __MicroComIInspectableProxy, ICompositor2 - { - public void* CreateAmbientLight() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateAmbientLight failed", __result); - return result; - } - - public void* CreateAnimationGroup() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateAnimationGroup failed", __result); - return result; - } - - public ICompositionBackdropBrush CreateBackdropBrush() - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateBackdropBrush failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void* CreateDistantLight() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateDistantLight failed", __result); - return result; - } - - public void* CreateDropShadow() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateDropShadow failed", __result); - return result; - } - - public void* CreateImplicitAnimationCollection() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateImplicitAnimationCollection failed", __result); - return result; - } - - public void* CreateLayerVisual() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 6]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateLayerVisual failed", __result); - return result; - } - - public void* CreateMaskBrush() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 7]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateMaskBrush failed", __result); - return result; - } - - public void* CreateNineGridBrush() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 8]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateNineGridBrush failed", __result); - return result; - } - - public void* CreatePointLight() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 9]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreatePointLight failed", __result); - return result; - } - - public void* CreateSpotLight() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 10]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateSpotLight failed", __result); - return result; - } - - public void* CreateStepEasingFunction() - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &result, (*PPV)[base.VTableSize + 11]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateStepEasingFunction failed", __result); - return result; - } - - public void* CreateStepEasingFunctionWithStepCount(int stepCount) - { - int __result; - void* result = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, stepCount, &result, (*PPV)[base.VTableSize + 12]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateStepEasingFunctionWithStepCount failed", __result); - return result; - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositor2), new Guid("735081DC-5E24-45DA-A38F-E32CC349A9A0"), (p, owns) => new __MicroComICompositor2Proxy(p, owns)); - } - - public __MicroComICompositor2Proxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 13; - } - - unsafe class __MicroComICompositor2VTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateAmbientLightDelegate(IntPtr @this, void** result); - static int CreateAmbientLight(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateAmbientLight(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateAnimationGroupDelegate(IntPtr @this, void** result); - static int CreateAnimationGroup(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateAnimationGroup(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateBackdropBrushDelegate(IntPtr @this, void** result); - static int CreateBackdropBrush(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateBackdropBrush(); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateDistantLightDelegate(IntPtr @this, void** result); - static int CreateDistantLight(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateDistantLight(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateDropShadowDelegate(IntPtr @this, void** result); - static int CreateDropShadow(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateDropShadow(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateImplicitAnimationCollectionDelegate(IntPtr @this, void** result); - static int CreateImplicitAnimationCollection(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateImplicitAnimationCollection(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateLayerVisualDelegate(IntPtr @this, void** result); - static int CreateLayerVisual(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateLayerVisual(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateMaskBrushDelegate(IntPtr @this, void** result); - static int CreateMaskBrush(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateMaskBrush(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateNineGridBrushDelegate(IntPtr @this, void** result); - static int CreateNineGridBrush(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateNineGridBrush(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreatePointLightDelegate(IntPtr @this, void** result); - static int CreatePointLight(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreatePointLight(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateSpotLightDelegate(IntPtr @this, void** result); - static int CreateSpotLight(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateSpotLight(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateStepEasingFunctionDelegate(IntPtr @this, void** result); - static int CreateStepEasingFunction(IntPtr @this, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateStepEasingFunction(); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateStepEasingFunctionWithStepCountDelegate(IntPtr @this, int stepCount, void** result); - static int CreateStepEasingFunctionWithStepCount(IntPtr @this, int stepCount, void** result) - { - ICompositor2 __target = null; - try - { - { - __target = (ICompositor2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateStepEasingFunctionWithStepCount(stepCount); - *result = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositor2VTable() - { - base.AddMethod((CreateAmbientLightDelegate)CreateAmbientLight); - base.AddMethod((CreateAnimationGroupDelegate)CreateAnimationGroup); - base.AddMethod((CreateBackdropBrushDelegate)CreateBackdropBrush); - base.AddMethod((CreateDistantLightDelegate)CreateDistantLight); - base.AddMethod((CreateDropShadowDelegate)CreateDropShadow); - base.AddMethod((CreateImplicitAnimationCollectionDelegate)CreateImplicitAnimationCollection); - base.AddMethod((CreateLayerVisualDelegate)CreateLayerVisual); - base.AddMethod((CreateMaskBrushDelegate)CreateMaskBrush); - base.AddMethod((CreateNineGridBrushDelegate)CreateNineGridBrush); - base.AddMethod((CreatePointLightDelegate)CreatePointLight); - base.AddMethod((CreateSpotLightDelegate)CreateSpotLight); - base.AddMethod((CreateStepEasingFunctionDelegate)CreateStepEasingFunction); - base.AddMethod((CreateStepEasingFunctionWithStepCountDelegate)CreateStepEasingFunctionWithStepCount); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositor2), new __MicroComICompositor2VTable().CreateVTable()); - } - - unsafe internal partial class __MicroComISpriteVisualProxy : __MicroComIInspectableProxy, ISpriteVisual - { - public ICompositionBrush Brush - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetBrush failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public void SetBrush(ICompositionBrush value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetBrush failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ISpriteVisual), new Guid("08E05581-1AD1-4F97-9757-402D76E4233B"), (p, owns) => new __MicroComISpriteVisualProxy(p, owns)); - } - - public __MicroComISpriteVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComISpriteVisualVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetBrushDelegate(IntPtr @this, void** value); - static int GetBrush(IntPtr @this, void** value) - { - ISpriteVisual __target = null; - try - { - { - __target = (ISpriteVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Brush; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetBrushDelegate(IntPtr @this, void* value); - static int SetBrush(IntPtr @this, void* value) - { - ISpriteVisual __target = null; - try - { - { - __target = (ISpriteVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetBrush(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComISpriteVisualVTable() - { - base.AddMethod((GetBrushDelegate)GetBrush); - base.AddMethod((SetBrushDelegate)SetBrush); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ISpriteVisual), new __MicroComISpriteVisualVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionDrawingSurfaceInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositionDrawingSurfaceInterop - { - public Avalonia.Win32.Interop.UnmanagedMethods.POINT BeginDraw(Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject) - { - int __result; - Avalonia.Win32.Interop.UnmanagedMethods.POINT updateOffset = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, updateRect, iid, updateObject, &updateOffset, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("BeginDraw failed", __result); - return updateOffset; - } - - public void EndDraw() - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("EndDraw failed", __result); - } - - public void Resize(Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, sizePixels, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Resize failed", __result); - } - - public void Scroll(Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, scrollRect, clipRect, offsetX, offsetY, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Scroll failed", __result); - } - - public void ResumeDraw() - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("ResumeDraw failed", __result); - } - - public void SuspendDraw() - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SuspendDraw failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionDrawingSurfaceInterop), new Guid("FD04E6E3-FE0C-4C3C-AB19-A07601A576EE"), (p, owns) => new __MicroComICompositionDrawingSurfaceInteropProxy(p, owns)); - } - - public __MicroComICompositionDrawingSurfaceInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 6; - } - - unsafe class __MicroComICompositionDrawingSurfaceInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int BeginDrawDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject, Avalonia.Win32.Interop.UnmanagedMethods.POINT* updateOffset); - static int BeginDraw(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* updateRect, Guid* iid, void** updateObject, Avalonia.Win32.Interop.UnmanagedMethods.POINT* updateOffset) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.BeginDraw(updateRect, iid, updateObject); - *updateOffset = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int EndDrawDelegate(IntPtr @this); - static int EndDraw(IntPtr @this) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.EndDraw(); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int ResizeDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels); - static int Resize(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT sizePixels) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.Resize(sizePixels); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int ScrollDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY); - static int Scroll(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.RECT* scrollRect, Avalonia.Win32.Interop.UnmanagedMethods.RECT* clipRect, int offsetX, int offsetY) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.Scroll(scrollRect, clipRect, offsetX, offsetY); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int ResumeDrawDelegate(IntPtr @this); - static int ResumeDraw(IntPtr @this) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.ResumeDraw(); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SuspendDrawDelegate(IntPtr @this); - static int SuspendDraw(IntPtr @this) - { - ICompositionDrawingSurfaceInterop __target = null; - try - { - { - __target = (ICompositionDrawingSurfaceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SuspendDraw(); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionDrawingSurfaceInteropVTable() - { - base.AddMethod((BeginDrawDelegate)BeginDraw); - base.AddMethod((EndDrawDelegate)EndDraw); - base.AddMethod((ResizeDelegate)Resize); - base.AddMethod((ScrollDelegate)Scroll); - base.AddMethod((ResumeDrawDelegate)ResumeDraw); - base.AddMethod((SuspendDrawDelegate)SuspendDraw); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionDrawingSurfaceInterop), new __MicroComICompositionDrawingSurfaceInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionGraphicsDeviceInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositionGraphicsDeviceInterop - { - public IUnknown RenderingDevice - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRenderingDevice failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public void SetRenderingDevice(IUnknown value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRenderingDevice failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionGraphicsDeviceInterop), new Guid("A116FF71-F8BF-4C8A-9C98-70779A32A9C8"), (p, owns) => new __MicroComICompositionGraphicsDeviceInteropProxy(p, owns)); - } - - public __MicroComICompositionGraphicsDeviceInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComICompositionGraphicsDeviceInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRenderingDeviceDelegate(IntPtr @this, void** value); - static int GetRenderingDevice(IntPtr @this, void** value) - { - ICompositionGraphicsDeviceInterop __target = null; - try - { - { - __target = (ICompositionGraphicsDeviceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RenderingDevice; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRenderingDeviceDelegate(IntPtr @this, void* value); - static int SetRenderingDevice(IntPtr @this, void* value) - { - ICompositionGraphicsDeviceInterop __target = null; - try - { - { - __target = (ICompositionGraphicsDeviceInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRenderingDevice(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionGraphicsDeviceInteropVTable() - { - base.AddMethod((GetRenderingDeviceDelegate)GetRenderingDevice); - base.AddMethod((SetRenderingDeviceDelegate)SetRenderingDevice); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionGraphicsDeviceInterop), new __MicroComICompositionGraphicsDeviceInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositorInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositorInterop - { - public ICompositionSurface CreateCompositionSurfaceForHandle(IntPtr swapChain) - { - int __result; - void* __marshal_res = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, swapChain, &__marshal_res, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateCompositionSurfaceForHandle failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_res, true); - } - - public ICompositionSurface CreateCompositionSurfaceForSwapChain(IUnknown swapChain) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(swapChain), &__marshal_result, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateCompositionSurfaceForSwapChain failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public ICompositionGraphicsDevice CreateGraphicsDevice(IUnknown renderingDevice) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(renderingDevice), &__marshal_result, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateGraphicsDevice failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositorInterop), new Guid("25297D5C-3AD4-4C9C-B5CF-E36A38512330"), (p, owns) => new __MicroComICompositorInteropProxy(p, owns)); - } - - public __MicroComICompositorInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComICompositorInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateCompositionSurfaceForHandleDelegate(IntPtr @this, IntPtr swapChain, void** res); - static int CreateCompositionSurfaceForHandle(IntPtr @this, IntPtr swapChain, void** res) - { - ICompositorInterop __target = null; - try - { - { - __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateCompositionSurfaceForHandle(swapChain); - *res = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateCompositionSurfaceForSwapChainDelegate(IntPtr @this, void* swapChain, void** result); - static int CreateCompositionSurfaceForSwapChain(IntPtr @this, void* swapChain, void** result) - { - ICompositorInterop __target = null; - try - { - { - __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateCompositionSurfaceForSwapChain(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(swapChain, false)); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateGraphicsDeviceDelegate(IntPtr @this, void* renderingDevice, void** result); - static int CreateGraphicsDevice(IntPtr @this, void* renderingDevice, void** result) - { - ICompositorInterop __target = null; - try - { - { - __target = (ICompositorInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateGraphicsDevice(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(renderingDevice, false)); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositorInteropVTable() - { - base.AddMethod((CreateCompositionSurfaceForHandleDelegate)CreateCompositionSurfaceForHandle); - base.AddMethod((CreateCompositionSurfaceForSwapChainDelegate)CreateCompositionSurfaceForSwapChain); - base.AddMethod((CreateGraphicsDeviceDelegate)CreateGraphicsDevice); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositorInterop), new __MicroComICompositorInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComISwapChainInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ISwapChainInterop - { - public void SetSwapChain(IUnknown swapChain) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(swapChain), (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetSwapChain failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ISwapChainInterop), new Guid("26f496a0-7f38-45fb-88f7-faaabe67dd59"), (p, owns) => new __MicroComISwapChainInteropProxy(p, owns)); - } - - public __MicroComISwapChainInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComISwapChainInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetSwapChainDelegate(IntPtr @this, void* swapChain); - static int SetSwapChain(IntPtr @this, void* swapChain) - { - ISwapChainInterop __target = null; - try - { - { - __target = (ISwapChainInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetSwapChain(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(swapChain, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComISwapChainInteropVTable() - { - base.AddMethod((SetSwapChainDelegate)SetSwapChain); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ISwapChainInterop), new __MicroComISwapChainInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositorDesktopInteropProxy : Avalonia.MicroCom.MicroComProxyBase, ICompositorDesktopInterop - { - public IDesktopWindowTarget CreateDesktopWindowTarget(IntPtr hwndTarget, int isTopmost) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, hwndTarget, isTopmost, &__marshal_result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateDesktopWindowTarget failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void EnsureOnThread(int threadId) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, threadId, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("EnsureOnThread failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositorDesktopInterop), new Guid("29E691FA-4567-4DCA-B319-D0F207EB6807"), (p, owns) => new __MicroComICompositorDesktopInteropProxy(p, owns)); - } - - public __MicroComICompositorDesktopInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComICompositorDesktopInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateDesktopWindowTargetDelegate(IntPtr @this, IntPtr hwndTarget, int isTopmost, void** result); - static int CreateDesktopWindowTarget(IntPtr @this, IntPtr hwndTarget, int isTopmost, void** result) - { - ICompositorDesktopInterop __target = null; - try - { - { - __target = (ICompositorDesktopInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateDesktopWindowTarget(hwndTarget, isTopmost); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int EnsureOnThreadDelegate(IntPtr @this, int threadId); - static int EnsureOnThread(IntPtr @this, int threadId) - { - ICompositorDesktopInterop __target = null; - try - { - { - __target = (ICompositorDesktopInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.EnsureOnThread(threadId); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositorDesktopInteropVTable() - { - base.AddMethod((CreateDesktopWindowTargetDelegate)CreateDesktopWindowTarget); - base.AddMethod((EnsureOnThreadDelegate)EnsureOnThread); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositorDesktopInterop), new __MicroComICompositorDesktopInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIDesktopWindowTargetInteropProxy : Avalonia.MicroCom.MicroComProxyBase, IDesktopWindowTargetInterop - { - public IntPtr HWnd - { - get - { - int __result; - IntPtr value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetHWnd failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowTargetInterop), new Guid("35DBF59E-E3F9-45B0-81E7-FE75F4145DC9"), (p, owns) => new __MicroComIDesktopWindowTargetInteropProxy(p, owns)); - } - - public __MicroComIDesktopWindowTargetInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComIDesktopWindowTargetInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetHWndDelegate(IntPtr @this, IntPtr* value); - static int GetHWnd(IntPtr @this, IntPtr* value) - { - IDesktopWindowTargetInterop __target = null; - try - { - { - __target = (IDesktopWindowTargetInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.HWnd; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIDesktopWindowTargetInteropVTable() - { - base.AddMethod((GetHWndDelegate)GetHWnd); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowTargetInterop), new __MicroComIDesktopWindowTargetInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIDesktopWindowContentBridgeInteropProxy : Avalonia.MicroCom.MicroComProxyBase, IDesktopWindowContentBridgeInterop - { - public void Initialize(ICompositor compositor, IntPtr parentHwnd) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(compositor), parentHwnd, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Initialize failed", __result); - } - - public IntPtr HWnd - { - get - { - int __result; - IntPtr value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetHWnd failed", __result); - return value; - } - } - - public float AppliedScaleFactor - { - get - { - int __result; - float value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetAppliedScaleFactor failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowContentBridgeInterop), new Guid("37642806-F421-4FD0-9F82-23AE7C776182"), (p, owns) => new __MicroComIDesktopWindowContentBridgeInteropProxy(p, owns)); - } - - public __MicroComIDesktopWindowContentBridgeInteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComIDesktopWindowContentBridgeInteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InitializeDelegate(IntPtr @this, void* compositor, IntPtr parentHwnd); - static int Initialize(IntPtr @this, void* compositor, IntPtr parentHwnd) - { - IDesktopWindowContentBridgeInterop __target = null; - try - { - { - __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.Initialize(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(compositor, false), parentHwnd); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetHWndDelegate(IntPtr @this, IntPtr* value); - static int GetHWnd(IntPtr @this, IntPtr* value) - { - IDesktopWindowContentBridgeInterop __target = null; - try - { - { - __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.HWnd; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetAppliedScaleFactorDelegate(IntPtr @this, float* value); - static int GetAppliedScaleFactor(IntPtr @this, float* value) - { - IDesktopWindowContentBridgeInterop __target = null; - try - { - { - __target = (IDesktopWindowContentBridgeInterop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.AppliedScaleFactor; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIDesktopWindowContentBridgeInteropVTable() - { - base.AddMethod((InitializeDelegate)Initialize); - base.AddMethod((GetHWndDelegate)GetHWnd); - base.AddMethod((GetAppliedScaleFactorDelegate)GetAppliedScaleFactor); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowContentBridgeInterop), new __MicroComIDesktopWindowContentBridgeInteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionGraphicsDeviceProxy : __MicroComIInspectableProxy, ICompositionGraphicsDevice - { - public ICompositionDrawingSurface CreateDrawingSurface(Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, sizePixels, pixelFormat, alphaMode, &__marshal_result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateDrawingSurface failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void AddRenderingDeviceReplaced(void* handler, void* token) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, handler, token, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("AddRenderingDeviceReplaced failed", __result); - } - - public void RemoveRenderingDeviceReplaced(int token) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, token, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("RemoveRenderingDeviceReplaced failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionGraphicsDevice), new Guid("FB22C6E1-80A2-4667-9936-DBEAF6EEFE95"), (p, owns) => new __MicroComICompositionGraphicsDeviceProxy(p, owns)); - } - - public __MicroComICompositionGraphicsDeviceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComICompositionGraphicsDeviceVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateDrawingSurfaceDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode, void** result); - static int CreateDrawingSurface(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.SIZE sizePixels, DirectXPixelFormat pixelFormat, DirectXAlphaMode alphaMode, void** result) - { - ICompositionGraphicsDevice __target = null; - try - { - { - __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateDrawingSurface(sizePixels, pixelFormat, alphaMode); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int AddRenderingDeviceReplacedDelegate(IntPtr @this, void* handler, void* token); - static int AddRenderingDeviceReplaced(IntPtr @this, void* handler, void* token) - { - ICompositionGraphicsDevice __target = null; - try - { - { - __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.AddRenderingDeviceReplaced(handler, token); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int RemoveRenderingDeviceReplacedDelegate(IntPtr @this, int token); - static int RemoveRenderingDeviceReplaced(IntPtr @this, int token) - { - ICompositionGraphicsDevice __target = null; - try - { - { - __target = (ICompositionGraphicsDevice)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.RemoveRenderingDeviceReplaced(token); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionGraphicsDeviceVTable() - { - base.AddMethod((CreateDrawingSurfaceDelegate)CreateDrawingSurface); - base.AddMethod((AddRenderingDeviceReplacedDelegate)AddRenderingDeviceReplaced); - base.AddMethod((RemoveRenderingDeviceReplacedDelegate)RemoveRenderingDeviceReplaced); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionGraphicsDevice), new __MicroComICompositionGraphicsDeviceVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionSurfaceProxy : __MicroComIInspectableProxy, ICompositionSurface - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionSurface), new Guid("1527540D-42C7-47A6-A408-668F79A90DFB"), (p, owns) => new __MicroComICompositionSurfaceProxy(p, owns)); - } - - public __MicroComICompositionSurfaceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComICompositionSurfaceVTable : __MicroComIInspectableVTable - { - public __MicroComICompositionSurfaceVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionSurface), new __MicroComICompositionSurfaceVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIDesktopWindowTargetProxy : __MicroComIInspectableProxy, IDesktopWindowTarget - { - public int IsTopmost - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetIsTopmost failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IDesktopWindowTarget), new Guid("6329D6CA-3366-490E-9DB3-25312929AC51"), (p, owns) => new __MicroComIDesktopWindowTargetProxy(p, owns)); - } - - public __MicroComIDesktopWindowTargetProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComIDesktopWindowTargetVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetIsTopmostDelegate(IntPtr @this, int* value); - static int GetIsTopmost(IntPtr @this, int* value) - { - IDesktopWindowTarget __target = null; - try - { - { - __target = (IDesktopWindowTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.IsTopmost; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIDesktopWindowTargetVTable() - { - base.AddMethod((GetIsTopmostDelegate)GetIsTopmost); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IDesktopWindowTarget), new __MicroComIDesktopWindowTargetVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionDrawingSurfaceProxy : __MicroComIInspectableProxy, ICompositionDrawingSurface - { - public DirectXAlphaMode AlphaMode - { - get - { - int __result; - DirectXAlphaMode value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetAlphaMode failed", __result); - return value; - } - } - - public DirectXPixelFormat PixelFormat - { - get - { - int __result; - DirectXPixelFormat value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetPixelFormat failed", __result); - return value; - } - } - - public Avalonia.Win32.Interop.UnmanagedMethods.POINT Size - { - get - { - int __result; - Avalonia.Win32.Interop.UnmanagedMethods.POINT value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionDrawingSurface), new Guid("A166C300-FAD0-4D11-9E67-E433162FF49E"), (p, owns) => new __MicroComICompositionDrawingSurfaceProxy(p, owns)); - } - - public __MicroComICompositionDrawingSurfaceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComICompositionDrawingSurfaceVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetAlphaModeDelegate(IntPtr @this, DirectXAlphaMode* value); - static int GetAlphaMode(IntPtr @this, DirectXAlphaMode* value) - { - ICompositionDrawingSurface __target = null; - try - { - { - __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.AlphaMode; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetPixelFormatDelegate(IntPtr @this, DirectXPixelFormat* value); - static int GetPixelFormat(IntPtr @this, DirectXPixelFormat* value) - { - ICompositionDrawingSurface __target = null; - try - { - { - __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.PixelFormat; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSizeDelegate(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT* value); - static int GetSize(IntPtr @this, Avalonia.Win32.Interop.UnmanagedMethods.POINT* value) - { - ICompositionDrawingSurface __target = null; - try - { - { - __target = (ICompositionDrawingSurface)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Size; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionDrawingSurfaceVTable() - { - base.AddMethod((GetAlphaModeDelegate)GetAlphaMode); - base.AddMethod((GetPixelFormatDelegate)GetPixelFormat); - base.AddMethod((GetSizeDelegate)GetSize); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionDrawingSurface), new __MicroComICompositionDrawingSurfaceVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionSurfaceBrushProxy : __MicroComIInspectableProxy, ICompositionSurfaceBrush - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionSurfaceBrush), new Guid("AD016D79-1E4C-4C0D-9C29-83338C87C162"), (p, owns) => new __MicroComICompositionSurfaceBrushProxy(p, owns)); - } - - public __MicroComICompositionSurfaceBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComICompositionSurfaceBrushVTable : __MicroComIInspectableVTable - { - public __MicroComICompositionSurfaceBrushVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionSurfaceBrush), new __MicroComICompositionSurfaceBrushVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionBrushProxy : __MicroComIInspectableProxy, ICompositionBrush - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionBrush), new Guid("AB0D7608-30C0-40E9-B568-B60A6BD1FB46"), (p, owns) => new __MicroComICompositionBrushProxy(p, owns)); - } - - public __MicroComICompositionBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComICompositionBrushVTable : __MicroComIInspectableVTable - { - public __MicroComICompositionBrushVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionBrush), new __MicroComICompositionBrushVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIVisualProxy : __MicroComIInspectableProxy, IVisual - { - public System.Numerics.Vector2 AnchorPoint - { - get - { - int __result; - System.Numerics.Vector2 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetAnchorPoint failed", __result); - return value; - } - } - - public void SetAnchorPoint(System.Numerics.Vector2 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetAnchorPoint failed", __result); - } - - public CompositionBackfaceVisibility BackfaceVisibility - { - get - { - int __result; - CompositionBackfaceVisibility value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetBackfaceVisibility failed", __result); - return value; - } - } - - public void SetBackfaceVisibility(CompositionBackfaceVisibility value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetBackfaceVisibility failed", __result); - } - - public CompositionBorderMode BorderMode - { - get - { - int __result; - CompositionBorderMode value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetBorderMode failed", __result); - return value; - } - } - - public void SetBorderMode(CompositionBorderMode value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetBorderMode failed", __result); - } - - public System.Numerics.Vector3 CenterPoint - { - get - { - int __result; - System.Numerics.Vector3 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 6]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetCenterPoint failed", __result); - return value; - } - } - - public void SetCenterPoint(System.Numerics.Vector3 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 7]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetCenterPoint failed", __result); - } - - public void* Clip - { - get - { - int __result; - void* value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 8]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetClip failed", __result); - return value; - } - } - - public void SetClip(void* value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 9]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetClip failed", __result); - } - - public CompositionCompositeMode CompositeMode - { - get - { - int __result; - CompositionCompositeMode value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 10]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetCompositeMode failed", __result); - return value; - } - } - - public void SetCompositeMode(CompositionCompositeMode value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 11]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetCompositeMode failed", __result); - } - - public int IsVisible - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 12]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetIsVisible failed", __result); - return value; - } - } - - public void SetIsVisible(int value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 13]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetIsVisible failed", __result); - } - - public System.Numerics.Vector3 Offset - { - get - { - int __result; - System.Numerics.Vector3 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 14]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetOffset failed", __result); - return value; - } - } - - public void SetOffset(System.Numerics.Vector3 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 15]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetOffset failed", __result); - } - - public float Opacity - { - get - { - int __result; - float value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 16]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetOpacity failed", __result); - return value; - } - } - - public void SetOpacity(float value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 17]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetOpacity failed", __result); - } - - public System.Numerics.Quaternion Orientation - { - get - { - int __result; - System.Numerics.Quaternion value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 18]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetOrientation failed", __result); - return value; - } - } - - public void SetOrientation(System.Numerics.Quaternion value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 19]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetOrientation failed", __result); - } - - public IContainerVisual Parent - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 20]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetParent failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public float RotationAngle - { - get - { - int __result; - float value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 21]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRotationAngle failed", __result); - return value; - } - } - - public void SetRotationAngle(float value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 22]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRotationAngle failed", __result); - } - - public float RotationAngleInDegrees - { - get - { - int __result; - float value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 23]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRotationAngleInDegrees failed", __result); - return value; - } - } - - public void SetRotationAngleInDegrees(float value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 24]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRotationAngleInDegrees failed", __result); - } - - public System.Numerics.Vector3 RotationAxis - { - get - { - int __result; - System.Numerics.Vector3 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 25]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRotationAxis failed", __result); - return value; - } - } - - public void SetRotationAxis(System.Numerics.Vector3 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 26]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRotationAxis failed", __result); - } - - public System.Numerics.Vector3 Scale - { - get - { - int __result; - System.Numerics.Vector3 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 27]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetScale failed", __result); - return value; - } - } - - public void SetScale(System.Numerics.Vector3 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 28]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetScale failed", __result); - } - - public System.Numerics.Vector2 Size - { - get - { - int __result; - System.Numerics.Vector2 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 29]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSize failed", __result); - return value; - } - } - - public void SetSize(System.Numerics.Vector2 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 30]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetSize failed", __result); - } - - public System.Numerics.Matrix4x4 TransformMatrix - { - get - { - int __result; - System.Numerics.Matrix4x4 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 31]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetTransformMatrix failed", __result); - return value; - } - } - - public void SetTransformMatrix(System.Numerics.Matrix4x4 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 32]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetTransformMatrix failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisual), new Guid("117E202D-A859-4C89-873B-C2AA566788E3"), (p, owns) => new __MicroComIVisualProxy(p, owns)); - } - - public __MicroComIVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 33; - } - - unsafe class __MicroComIVisualVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetAnchorPointDelegate(IntPtr @this, System.Numerics.Vector2* value); - static int GetAnchorPoint(IntPtr @this, System.Numerics.Vector2* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.AnchorPoint; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetAnchorPointDelegate(IntPtr @this, System.Numerics.Vector2 value); - static int SetAnchorPoint(IntPtr @this, System.Numerics.Vector2 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetAnchorPoint(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetBackfaceVisibilityDelegate(IntPtr @this, CompositionBackfaceVisibility* value); - static int GetBackfaceVisibility(IntPtr @this, CompositionBackfaceVisibility* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.BackfaceVisibility; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetBackfaceVisibilityDelegate(IntPtr @this, CompositionBackfaceVisibility value); - static int SetBackfaceVisibility(IntPtr @this, CompositionBackfaceVisibility value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetBackfaceVisibility(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetBorderModeDelegate(IntPtr @this, CompositionBorderMode* value); - static int GetBorderMode(IntPtr @this, CompositionBorderMode* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.BorderMode; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetBorderModeDelegate(IntPtr @this, CompositionBorderMode value); - static int SetBorderMode(IntPtr @this, CompositionBorderMode value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetBorderMode(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetCenterPointDelegate(IntPtr @this, System.Numerics.Vector3* value); - static int GetCenterPoint(IntPtr @this, System.Numerics.Vector3* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CenterPoint; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetCenterPointDelegate(IntPtr @this, System.Numerics.Vector3 value); - static int SetCenterPoint(IntPtr @this, System.Numerics.Vector3 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetCenterPoint(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetClipDelegate(IntPtr @this, void** value); - static int GetClip(IntPtr @this, void** value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Clip; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetClipDelegate(IntPtr @this, void* value); - static int SetClip(IntPtr @this, void* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetClip(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetCompositeModeDelegate(IntPtr @this, CompositionCompositeMode* value); - static int GetCompositeMode(IntPtr @this, CompositionCompositeMode* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CompositeMode; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetCompositeModeDelegate(IntPtr @this, CompositionCompositeMode value); - static int SetCompositeMode(IntPtr @this, CompositionCompositeMode value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetCompositeMode(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetIsVisibleDelegate(IntPtr @this, int* value); - static int GetIsVisible(IntPtr @this, int* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.IsVisible; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetIsVisibleDelegate(IntPtr @this, int value); - static int SetIsVisible(IntPtr @this, int value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetIsVisible(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetOffsetDelegate(IntPtr @this, System.Numerics.Vector3* value); - static int GetOffset(IntPtr @this, System.Numerics.Vector3* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Offset; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetOffsetDelegate(IntPtr @this, System.Numerics.Vector3 value); - static int SetOffset(IntPtr @this, System.Numerics.Vector3 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetOffset(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetOpacityDelegate(IntPtr @this, float* value); - static int GetOpacity(IntPtr @this, float* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Opacity; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetOpacityDelegate(IntPtr @this, float value); - static int SetOpacity(IntPtr @this, float value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetOpacity(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetOrientationDelegate(IntPtr @this, System.Numerics.Quaternion* value); - static int GetOrientation(IntPtr @this, System.Numerics.Quaternion* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Orientation; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetOrientationDelegate(IntPtr @this, System.Numerics.Quaternion value); - static int SetOrientation(IntPtr @this, System.Numerics.Quaternion value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetOrientation(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetParentDelegate(IntPtr @this, void** value); - static int GetParent(IntPtr @this, void** value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Parent; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRotationAngleDelegate(IntPtr @this, float* value); - static int GetRotationAngle(IntPtr @this, float* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RotationAngle; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRotationAngleDelegate(IntPtr @this, float value); - static int SetRotationAngle(IntPtr @this, float value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRotationAngle(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRotationAngleInDegreesDelegate(IntPtr @this, float* value); - static int GetRotationAngleInDegrees(IntPtr @this, float* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RotationAngleInDegrees; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRotationAngleInDegreesDelegate(IntPtr @this, float value); - static int SetRotationAngleInDegrees(IntPtr @this, float value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRotationAngleInDegrees(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRotationAxisDelegate(IntPtr @this, System.Numerics.Vector3* value); - static int GetRotationAxis(IntPtr @this, System.Numerics.Vector3* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RotationAxis; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRotationAxisDelegate(IntPtr @this, System.Numerics.Vector3 value); - static int SetRotationAxis(IntPtr @this, System.Numerics.Vector3 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRotationAxis(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetScaleDelegate(IntPtr @this, System.Numerics.Vector3* value); - static int GetScale(IntPtr @this, System.Numerics.Vector3* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Scale; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetScaleDelegate(IntPtr @this, System.Numerics.Vector3 value); - static int SetScale(IntPtr @this, System.Numerics.Vector3 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetScale(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSizeDelegate(IntPtr @this, System.Numerics.Vector2* value); - static int GetSize(IntPtr @this, System.Numerics.Vector2* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Size; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetSizeDelegate(IntPtr @this, System.Numerics.Vector2 value); - static int SetSize(IntPtr @this, System.Numerics.Vector2 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetSize(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetTransformMatrixDelegate(IntPtr @this, System.Numerics.Matrix4x4* value); - static int GetTransformMatrix(IntPtr @this, System.Numerics.Matrix4x4* value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.TransformMatrix; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetTransformMatrixDelegate(IntPtr @this, System.Numerics.Matrix4x4 value); - static int SetTransformMatrix(IntPtr @this, System.Numerics.Matrix4x4 value) - { - IVisual __target = null; - try - { - { - __target = (IVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetTransformMatrix(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIVisualVTable() - { - base.AddMethod((GetAnchorPointDelegate)GetAnchorPoint); - base.AddMethod((SetAnchorPointDelegate)SetAnchorPoint); - base.AddMethod((GetBackfaceVisibilityDelegate)GetBackfaceVisibility); - base.AddMethod((SetBackfaceVisibilityDelegate)SetBackfaceVisibility); - base.AddMethod((GetBorderModeDelegate)GetBorderMode); - base.AddMethod((SetBorderModeDelegate)SetBorderMode); - base.AddMethod((GetCenterPointDelegate)GetCenterPoint); - base.AddMethod((SetCenterPointDelegate)SetCenterPoint); - base.AddMethod((GetClipDelegate)GetClip); - base.AddMethod((SetClipDelegate)SetClip); - base.AddMethod((GetCompositeModeDelegate)GetCompositeMode); - base.AddMethod((SetCompositeModeDelegate)SetCompositeMode); - base.AddMethod((GetIsVisibleDelegate)GetIsVisible); - base.AddMethod((SetIsVisibleDelegate)SetIsVisible); - base.AddMethod((GetOffsetDelegate)GetOffset); - base.AddMethod((SetOffsetDelegate)SetOffset); - base.AddMethod((GetOpacityDelegate)GetOpacity); - base.AddMethod((SetOpacityDelegate)SetOpacity); - base.AddMethod((GetOrientationDelegate)GetOrientation); - base.AddMethod((SetOrientationDelegate)SetOrientation); - base.AddMethod((GetParentDelegate)GetParent); - base.AddMethod((GetRotationAngleDelegate)GetRotationAngle); - base.AddMethod((SetRotationAngleDelegate)SetRotationAngle); - base.AddMethod((GetRotationAngleInDegreesDelegate)GetRotationAngleInDegrees); - base.AddMethod((SetRotationAngleInDegreesDelegate)SetRotationAngleInDegrees); - base.AddMethod((GetRotationAxisDelegate)GetRotationAxis); - base.AddMethod((SetRotationAxisDelegate)SetRotationAxis); - base.AddMethod((GetScaleDelegate)GetScale); - base.AddMethod((SetScaleDelegate)SetScale); - base.AddMethod((GetSizeDelegate)GetSize); - base.AddMethod((SetSizeDelegate)SetSize); - base.AddMethod((GetTransformMatrixDelegate)GetTransformMatrix); - base.AddMethod((SetTransformMatrixDelegate)SetTransformMatrix); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisual), new __MicroComIVisualVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIVisual2Proxy : __MicroComIInspectableProxy, IVisual2 - { - public IVisual ParentForTransform - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetParentForTransform failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public void SetParentForTransform(IVisual value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetParentForTransform failed", __result); - } - - public System.Numerics.Vector3 RelativeOffsetAdjustment - { - get - { - int __result; - System.Numerics.Vector3 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRelativeOffsetAdjustment failed", __result); - return value; - } - } - - public void SetRelativeOffsetAdjustment(System.Numerics.Vector3 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRelativeOffsetAdjustment failed", __result); - } - - public System.Numerics.Vector2 RelativeSizeAdjustment - { - get - { - int __result; - System.Numerics.Vector2 value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRelativeSizeAdjustment failed", __result); - return value; - } - } - - public void SetRelativeSizeAdjustment(System.Numerics.Vector2 value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRelativeSizeAdjustment failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisual2), new Guid("3052B611-56C3-4C3E-8BF3-F6E1AD473F06"), (p, owns) => new __MicroComIVisual2Proxy(p, owns)); - } - - public __MicroComIVisual2Proxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 6; - } - - unsafe class __MicroComIVisual2VTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetParentForTransformDelegate(IntPtr @this, void** value); - static int GetParentForTransform(IntPtr @this, void** value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.ParentForTransform; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetParentForTransformDelegate(IntPtr @this, void* value); - static int SetParentForTransform(IntPtr @this, void* value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetParentForTransform(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRelativeOffsetAdjustmentDelegate(IntPtr @this, System.Numerics.Vector3* value); - static int GetRelativeOffsetAdjustment(IntPtr @this, System.Numerics.Vector3* value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RelativeOffsetAdjustment; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRelativeOffsetAdjustmentDelegate(IntPtr @this, System.Numerics.Vector3 value); - static int SetRelativeOffsetAdjustment(IntPtr @this, System.Numerics.Vector3 value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRelativeOffsetAdjustment(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRelativeSizeAdjustmentDelegate(IntPtr @this, System.Numerics.Vector2* value); - static int GetRelativeSizeAdjustment(IntPtr @this, System.Numerics.Vector2* value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.RelativeSizeAdjustment; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRelativeSizeAdjustmentDelegate(IntPtr @this, System.Numerics.Vector2 value); - static int SetRelativeSizeAdjustment(IntPtr @this, System.Numerics.Vector2 value) - { - IVisual2 __target = null; - try - { - { - __target = (IVisual2)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRelativeSizeAdjustment(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIVisual2VTable() - { - base.AddMethod((GetParentForTransformDelegate)GetParentForTransform); - base.AddMethod((SetParentForTransformDelegate)SetParentForTransform); - base.AddMethod((GetRelativeOffsetAdjustmentDelegate)GetRelativeOffsetAdjustment); - base.AddMethod((SetRelativeOffsetAdjustmentDelegate)SetRelativeOffsetAdjustment); - base.AddMethod((GetRelativeSizeAdjustmentDelegate)GetRelativeSizeAdjustment); - base.AddMethod((SetRelativeSizeAdjustmentDelegate)SetRelativeSizeAdjustment); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisual2), new __MicroComIVisual2VTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIContainerVisualProxy : __MicroComIInspectableProxy, IContainerVisual - { - public IVisualCollection Children - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetChildren failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IContainerVisual), new Guid("02F6BC74-ED20-4773-AFE6-D49B4A93DB32"), (p, owns) => new __MicroComIContainerVisualProxy(p, owns)); - } - - public __MicroComIContainerVisualProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComIContainerVisualVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetChildrenDelegate(IntPtr @this, void** value); - static int GetChildren(IntPtr @this, void** value) - { - IContainerVisual __target = null; - try - { - { - __target = (IContainerVisual)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Children; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIContainerVisualVTable() - { - base.AddMethod((GetChildrenDelegate)GetChildren); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IContainerVisual), new __MicroComIContainerVisualVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIVisualCollectionProxy : __MicroComIInspectableProxy, IVisualCollection - { - public int Count - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetCount failed", __result); - return value; - } - } - - public void InsertAbove(IVisual newChild, IVisual sibling) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), Avalonia.MicroCom.MicroComRuntime.GetNativePointer(sibling), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("InsertAbove failed", __result); - } - - public void InsertAtBottom(IVisual newChild) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("InsertAtBottom failed", __result); - } - - public void InsertAtTop(IVisual newChild) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("InsertAtTop failed", __result); - } - - public void InsertBelow(IVisual newChild, IVisual sibling) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(newChild), Avalonia.MicroCom.MicroComRuntime.GetNativePointer(sibling), (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("InsertBelow failed", __result); - } - - public void Remove(IVisual child) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(child), (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Remove failed", __result); - } - - public void RemoveAll() - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, (*PPV)[base.VTableSize + 6]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("RemoveAll failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IVisualCollection), new Guid("8B745505-FD3E-4A98-84A8-E949468C6BCB"), (p, owns) => new __MicroComIVisualCollectionProxy(p, owns)); - } - - public __MicroComIVisualCollectionProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 7; - } - - unsafe class __MicroComIVisualCollectionVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetCountDelegate(IntPtr @this, int* value); - static int GetCount(IntPtr @this, int* value) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Count; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InsertAboveDelegate(IntPtr @this, void* newChild, void* sibling); - static int InsertAbove(IntPtr @this, void* newChild, void* sibling) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.InsertAbove(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false), Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(sibling, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InsertAtBottomDelegate(IntPtr @this, void* newChild); - static int InsertAtBottom(IntPtr @this, void* newChild) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.InsertAtBottom(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InsertAtTopDelegate(IntPtr @this, void* newChild); - static int InsertAtTop(IntPtr @this, void* newChild) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.InsertAtTop(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int InsertBelowDelegate(IntPtr @this, void* newChild, void* sibling); - static int InsertBelow(IntPtr @this, void* newChild, void* sibling) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.InsertBelow(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(newChild, false), Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(sibling, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int RemoveDelegate(IntPtr @this, void* child); - static int Remove(IntPtr @this, void* child) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.Remove(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(child, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int RemoveAllDelegate(IntPtr @this); - static int RemoveAll(IntPtr @this) - { - IVisualCollection __target = null; - try - { - { - __target = (IVisualCollection)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.RemoveAll(); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIVisualCollectionVTable() - { - base.AddMethod((GetCountDelegate)GetCount); - base.AddMethod((InsertAboveDelegate)InsertAbove); - base.AddMethod((InsertAtBottomDelegate)InsertAtBottom); - base.AddMethod((InsertAtTopDelegate)InsertAtTop); - base.AddMethod((InsertBelowDelegate)InsertBelow); - base.AddMethod((RemoveDelegate)Remove); - base.AddMethod((RemoveAllDelegate)RemoveAll); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IVisualCollection), new __MicroComIVisualCollectionVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionTargetProxy : __MicroComIInspectableProxy, ICompositionTarget - { - public IVisual Root - { - get - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetRoot failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - } - - public void SetRoot(IVisual value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(value), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetRoot failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionTarget), new Guid("A1BEA8BA-D726-4663-8129-6B5E7927FFA6"), (p, owns) => new __MicroComICompositionTargetProxy(p, owns)); - } - - public __MicroComICompositionTargetProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComICompositionTargetVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetRootDelegate(IntPtr @this, void** value); - static int GetRoot(IntPtr @this, void** value) - { - ICompositionTarget __target = null; - try - { - { - __target = (ICompositionTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Root; - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetRootDelegate(IntPtr @this, void* value); - static int SetRoot(IntPtr @this, void* value) - { - ICompositionTarget __target = null; - try - { - { - __target = (ICompositionTarget)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetRoot(Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(value, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionTargetVTable() - { - base.AddMethod((GetRootDelegate)GetRoot); - base.AddMethod((SetRootDelegate)SetRoot); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionTarget), new __MicroComICompositionTargetVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIGraphicsEffectProxy : __MicroComIInspectableProxy, IGraphicsEffect - { - public IntPtr Name - { - get - { - int __result; - IntPtr name = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &name, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetName failed", __result); - return name; - } - } - - public void SetName(IntPtr name) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, name, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetName failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffect), new Guid("CB51C0CE-8FE6-4636-B202-861FAA07D8F3"), (p, owns) => new __MicroComIGraphicsEffectProxy(p, owns)); - } - - public __MicroComIGraphicsEffectProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComIGraphicsEffectVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetNameDelegate(IntPtr @this, IntPtr* name); - static int GetName(IntPtr @this, IntPtr* name) - { - IGraphicsEffect __target = null; - try - { - { - __target = (IGraphicsEffect)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Name; - *name = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetNameDelegate(IntPtr @this, IntPtr name); - static int SetName(IntPtr @this, IntPtr name) - { - IGraphicsEffect __target = null; - try - { - { - __target = (IGraphicsEffect)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetName(name); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIGraphicsEffectVTable() - { - base.AddMethod((GetNameDelegate)GetName); - base.AddMethod((SetNameDelegate)SetName); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffect), new __MicroComIGraphicsEffectVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIGraphicsEffectSourceProxy : __MicroComIInspectableProxy, IGraphicsEffectSource - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffectSource), new Guid("2D8F9DDC-4339-4EB9-9216-F9DEB75658A2"), (p, owns) => new __MicroComIGraphicsEffectSourceProxy(p, owns)); - } - - public __MicroComIGraphicsEffectSourceProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComIGraphicsEffectSourceVTable : __MicroComIInspectableVTable - { - public __MicroComIGraphicsEffectSourceVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffectSource), new __MicroComIGraphicsEffectSourceVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComIGraphicsEffectD2D1InteropProxy : Avalonia.MicroCom.MicroComProxyBase, IGraphicsEffectD2D1Interop - { - public Guid EffectId - { - get - { - int __result; - Guid id = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &id, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetEffectId failed", __result); - return id; - } - } - - public void GetNamedPropertyMapping(IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, name, index, mapping, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetNamedPropertyMapping failed", __result); - } - - public uint PropertyCount - { - get - { - int __result; - uint count = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &count, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetPropertyCount failed", __result); - return count; - } - } - - public IPropertyValue GetProperty(uint index) - { - int __result; - void* __marshal_value = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, index, &__marshal_value, (*PPV)[base.VTableSize + 3]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetProperty failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_value, true); - } - - public IGraphicsEffectSource GetSource(uint index) - { - int __result; - void* __marshal_source = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, index, &__marshal_source, (*PPV)[base.VTableSize + 4]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSource failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_source, true); - } - - public uint SourceCount - { - get - { - int __result; - uint count = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &count, (*PPV)[base.VTableSize + 5]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSourceCount failed", __result); - return count; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(IGraphicsEffectD2D1Interop), new Guid("2FC57384-A068-44D7-A331-30982FCF7177"), (p, owns) => new __MicroComIGraphicsEffectD2D1InteropProxy(p, owns)); - } - - public __MicroComIGraphicsEffectD2D1InteropProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 6; - } - - unsafe class __MicroComIGraphicsEffectD2D1InteropVTable : Avalonia.MicroCom.MicroComVtblBase - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetEffectIdDelegate(IntPtr @this, Guid* id); - static int GetEffectId(IntPtr @this, Guid* id) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.EffectId; - *id = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetNamedPropertyMappingDelegate(IntPtr @this, IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping); - static int GetNamedPropertyMapping(IntPtr @this, IntPtr name, uint* index, GRAPHICS_EFFECT_PROPERTY_MAPPING* mapping) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.GetNamedPropertyMapping(name, index, mapping); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetPropertyCountDelegate(IntPtr @this, uint* count); - static int GetPropertyCount(IntPtr @this, uint* count) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.PropertyCount; - *count = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetPropertyDelegate(IntPtr @this, uint index, void** value); - static int GetProperty(IntPtr @this, uint index, void** value) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetProperty(index); - *value = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSourceDelegate(IntPtr @this, uint index, void** source); - static int GetSource(IntPtr @this, uint index, void** source) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetSource(index); - *source = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSourceCountDelegate(IntPtr @this, uint* count); - static int GetSourceCount(IntPtr @this, uint* count) - { - IGraphicsEffectD2D1Interop __target = null; - try - { - { - __target = (IGraphicsEffectD2D1Interop)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.SourceCount; - *count = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComIGraphicsEffectD2D1InteropVTable() - { - base.AddMethod((GetEffectIdDelegate)GetEffectId); - base.AddMethod((GetNamedPropertyMappingDelegate)GetNamedPropertyMapping); - base.AddMethod((GetPropertyCountDelegate)GetPropertyCount); - base.AddMethod((GetPropertyDelegate)GetProperty); - base.AddMethod((GetSourceDelegate)GetSource); - base.AddMethod((GetSourceCountDelegate)GetSourceCount); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(IGraphicsEffectD2D1Interop), new __MicroComIGraphicsEffectD2D1InteropVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionEffectSourceParameterProxy : __MicroComIInspectableProxy, ICompositionEffectSourceParameter - { - public IntPtr Name - { - get - { - int __result; - IntPtr value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetName failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectSourceParameter), new Guid("858AB13A-3292-4E4E-B3BB-2B6C6544A6EE"), (p, owns) => new __MicroComICompositionEffectSourceParameterProxy(p, owns)); - } - - public __MicroComICompositionEffectSourceParameterProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComICompositionEffectSourceParameterVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetNameDelegate(IntPtr @this, IntPtr* value); - static int GetName(IntPtr @this, IntPtr* value) - { - ICompositionEffectSourceParameter __target = null; - try - { - { - __target = (ICompositionEffectSourceParameter)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Name; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionEffectSourceParameterVTable() - { - base.AddMethod((GetNameDelegate)GetName); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectSourceParameter), new __MicroComICompositionEffectSourceParameterVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionEffectSourceParameterFactoryProxy : __MicroComIInspectableProxy, ICompositionEffectSourceParameterFactory - { - public ICompositionEffectSourceParameter Create(IntPtr name) - { - int __result; - void* __marshal_instance = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, name, &__marshal_instance, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("Create failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_instance, true); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectSourceParameterFactory), new Guid("B3D9F276-ABA3-4724-ACF3-D0397464DB1C"), (p, owns) => new __MicroComICompositionEffectSourceParameterFactoryProxy(p, owns)); - } - - public __MicroComICompositionEffectSourceParameterFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 1; - } - - unsafe class __MicroComICompositionEffectSourceParameterFactoryVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateDelegate(IntPtr @this, IntPtr name, void** instance); - static int Create(IntPtr @this, IntPtr name, void** instance) - { - ICompositionEffectSourceParameterFactory __target = null; - try - { - { - __target = (ICompositionEffectSourceParameterFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Create(name); - *instance = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionEffectSourceParameterFactoryVTable() - { - base.AddMethod((CreateDelegate)Create); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectSourceParameterFactory), new __MicroComICompositionEffectSourceParameterFactoryVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionEffectFactoryProxy : __MicroComIInspectableProxy, ICompositionEffectFactory - { - public ICompositionEffectBrush CreateBrush() - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, &__marshal_result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("CreateBrush failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public int ExtendedError - { - get - { - int __result; - int value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetExtendedError failed", __result); - return value; - } - } - - public CompositionEffectFactoryLoadStatus LoadStatus - { - get - { - int __result; - CompositionEffectFactoryLoadStatus value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 2]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetLoadStatus failed", __result); - return value; - } - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectFactory), new Guid("BE5624AF-BA7E-4510-9850-41C0B4FF74DF"), (p, owns) => new __MicroComICompositionEffectFactoryProxy(p, owns)); - } - - public __MicroComICompositionEffectFactoryProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 3; - } - - unsafe class __MicroComICompositionEffectFactoryVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int CreateBrushDelegate(IntPtr @this, void** result); - static int CreateBrush(IntPtr @this, void** result) - { - ICompositionEffectFactory __target = null; - try - { - { - __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.CreateBrush(); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetExtendedErrorDelegate(IntPtr @this, int* value); - static int GetExtendedError(IntPtr @this, int* value) - { - ICompositionEffectFactory __target = null; - try - { - { - __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.ExtendedError; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetLoadStatusDelegate(IntPtr @this, CompositionEffectFactoryLoadStatus* value); - static int GetLoadStatus(IntPtr @this, CompositionEffectFactoryLoadStatus* value) - { - ICompositionEffectFactory __target = null; - try - { - { - __target = (ICompositionEffectFactory)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.LoadStatus; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionEffectFactoryVTable() - { - base.AddMethod((CreateBrushDelegate)CreateBrush); - base.AddMethod((GetExtendedErrorDelegate)GetExtendedError); - base.AddMethod((GetLoadStatusDelegate)GetLoadStatus); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectFactory), new __MicroComICompositionEffectFactoryVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionEffectBrushProxy : __MicroComIInspectableProxy, ICompositionEffectBrush - { - public ICompositionBrush GetSourceParameter(IntPtr name) - { - int __result; - void* __marshal_result = null; - __result = (int)LocalInterop.CalliStdCallint(PPV, name, &__marshal_result, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetSourceParameter failed", __result); - return Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(__marshal_result, true); - } - - public void SetSourceParameter(IntPtr name, ICompositionBrush source) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, name, Avalonia.MicroCom.MicroComRuntime.GetNativePointer(source), (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetSourceParameter failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionEffectBrush), new Guid("BF7F795E-83CC-44BF-A447-3E3C071789EC"), (p, owns) => new __MicroComICompositionEffectBrushProxy(p, owns)); - } - - public __MicroComICompositionEffectBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComICompositionEffectBrushVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetSourceParameterDelegate(IntPtr @this, IntPtr name, void** result); - static int GetSourceParameter(IntPtr @this, IntPtr name, void** result) - { - ICompositionEffectBrush __target = null; - try - { - { - __target = (ICompositionEffectBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.GetSourceParameter(name); - *result = Avalonia.MicroCom.MicroComRuntime.GetNativePointer(__result, true); - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetSourceParameterDelegate(IntPtr @this, IntPtr name, void* source); - static int SetSourceParameter(IntPtr @this, IntPtr name, void* source) - { - ICompositionEffectBrush __target = null; - try - { - { - __target = (ICompositionEffectBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetSourceParameter(name, Avalonia.MicroCom.MicroComRuntime.CreateProxyFor(source, false)); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionEffectBrushVTable() - { - base.AddMethod((GetSourceParameterDelegate)GetSourceParameter); - base.AddMethod((SetSourceParameterDelegate)SetSourceParameter); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionEffectBrush), new __MicroComICompositionEffectBrushVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionBackdropBrushProxy : __MicroComIInspectableProxy, ICompositionBackdropBrush - { - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionBackdropBrush), new Guid("C5ACAE58-3898-499E-8D7F-224E91286A5D"), (p, owns) => new __MicroComICompositionBackdropBrushProxy(p, owns)); - } - - public __MicroComICompositionBackdropBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 0; - } - - unsafe class __MicroComICompositionBackdropBrushVTable : __MicroComIInspectableVTable - { - public __MicroComICompositionBackdropBrushVTable() - { - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionBackdropBrush), new __MicroComICompositionBackdropBrushVTable().CreateVTable()); - } - - unsafe internal partial class __MicroComICompositionColorBrushProxy : __MicroComIInspectableProxy, ICompositionColorBrush - { - public Avalonia.Win32.WinRT.WinRTColor Color - { - get - { - int __result; - Avalonia.Win32.WinRT.WinRTColor value = default; - __result = (int)LocalInterop.CalliStdCallint(PPV, &value, (*PPV)[base.VTableSize + 0]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("GetColor failed", __result); - return value; - } - } - - public void SetColor(Avalonia.Win32.WinRT.WinRTColor value) - { - int __result; - __result = (int)LocalInterop.CalliStdCallint(PPV, value, (*PPV)[base.VTableSize + 1]); - if (__result != 0) - throw new System.Runtime.InteropServices.COMException("SetColor failed", __result); - } - - static internal void __MicroComModuleInit() - { - Avalonia.MicroCom.MicroComRuntime.Register(typeof(ICompositionColorBrush), new Guid("2B264C5E-BF35-4831-8642-CF70C20FFF2F"), (p, owns) => new __MicroComICompositionColorBrushProxy(p, owns)); - } - - public __MicroComICompositionColorBrushProxy(IntPtr nativePointer, bool ownsHandle) : base(nativePointer, ownsHandle) - { - } - - protected override int VTableSize => base.VTableSize + 2; - } - - unsafe class __MicroComICompositionColorBrushVTable : __MicroComIInspectableVTable - { - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int GetColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* value); - static int GetColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor* value) - { - ICompositionColorBrush __target = null; - try - { - { - __target = (ICompositionColorBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - { - var __result = __target.Color; - *value = __result; - } - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)] - delegate int SetColorDelegate(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor value); - static int SetColor(IntPtr @this, Avalonia.Win32.WinRT.WinRTColor value) - { - ICompositionColorBrush __target = null; - try - { - { - __target = (ICompositionColorBrush)Avalonia.MicroCom.MicroComRuntime.GetObjectFromCcw(@this); - __target.SetColor(value); - } - } - catch (System.Runtime.InteropServices.COMException __com_exception__) - { - return __com_exception__.ErrorCode; - } - catch (System.Exception __exception__) - { - Avalonia.MicroCom.MicroComRuntime.UnhandledException(__target, __exception__); - return unchecked((int)0x80004005u); - } - - return 0; - } - - public __MicroComICompositionColorBrushVTable() - { - base.AddMethod((GetColorDelegate)GetColor); - base.AddMethod((SetColorDelegate)SetColor); - } - - static internal void __MicroComModuleInit() => Avalonia.MicroCom.MicroComRuntime.RegisterVTable(typeof(ICompositionColorBrush), new __MicroComICompositionColorBrushVTable().CreateVTable()); - } - - class LocalInterop - { - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, AsyncStatus arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector2 arg0, System.Numerics.Vector2 arg1, void* arg2, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* arg2, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, float arg0, float arg1, float arg2, float arg3, void* arg4, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, CompositionBatchTypes arg0, void* arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, int arg0, void* arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, void* arg2, void* arg3, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.Interop.UnmanagedMethods.POINT arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, void* arg1, int arg2, int arg3, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, int arg1, void* arg2, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, int arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, void* arg0, IntPtr arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.Interop.UnmanagedMethods.SIZE arg0, DirectXPixelFormat arg1, DirectXAlphaMode arg2, void* arg3, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector2 arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, CompositionBackfaceVisibility arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, CompositionBorderMode arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Vector3 arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, CompositionCompositeMode arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, float arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Quaternion arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, System.Numerics.Matrix4x4 arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, IntPtr arg0, void* arg1, void* arg2, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, uint arg0, void* arg1, void* methodPtr) - { - throw null; - } - - static unsafe public int CalliStdCallint(void* thisObj, Avalonia.Win32.WinRT.WinRTColor arg0, void* methodPtr) - { - throw null; - } - } -} \ No newline at end of file From c06bfa1d6a0922c5c8be2dd685277c41721df1a1 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 03:31:46 +0300 Subject: [PATCH 095/314] Use a dedicated STA thread for compositor dispatch queue --- .../Composition/WinUICompositorConnection.cs | 65 ++++++++++++++----- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs index dd0a918362..8be68bbfe2 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -1,6 +1,8 @@ using System; using System.Numerics; using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; using Avalonia.Logging; using Avalonia.MicroCom; using Avalonia.OpenGL; @@ -11,7 +13,7 @@ using Avalonia.Win32.Interop; namespace Avalonia.Win32.WinRT.Composition { - public class WinUICompositorConnection + class WinUICompositorConnection { private readonly EglContext _syncContext; private IntPtr _queue; @@ -22,18 +24,13 @@ namespace Avalonia.Win32.WinRT.Composition private ICompositionGraphicsDevice _device; private EglPlatformOpenGlInterface _gl; private ICompositorDesktopInterop _compositorDesktopInterop; + private ICompositionBrush _blurBrush; public WinUICompositorConnection(EglPlatformOpenGlInterface gl) { _gl = gl; _syncContext = _gl.PrimaryEglContext; _angle = (AngleWin32EglDisplay)_gl.Display; - _queue = NativeWinRTMethods.CreateDispatcherQueueController(new NativeWinRTMethods.DispatcherQueueOptions - { - apartmentType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_STA, - dwSize = Marshal.SizeOf(), - threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_DEDICATED - }); _compositor = NativeWinRTMethods.CreateInstance("Windows.UI.Composition.Compositor"); _compositor2 = _compositor.QueryInterface(); _compositorInterop = _compositor.QueryInterface(); @@ -41,10 +38,44 @@ namespace Avalonia.Win32.WinRT.Composition using var device = MicroComRuntime.CreateProxyFor(_angle.GetDirect3DDevice(), true); _device = _compositorInterop.CreateGraphicsDevice(device); + _blurBrush = CreateBlurBrush(); } public EglPlatformOpenGlInterface Egl => _gl; + static WinUICompositorConnection TryCreateCore(EglPlatformOpenGlInterface angle) + { + var tcs = new TaskCompletionSource(); + var th = new Thread(() => + { + try + { + NativeWinRTMethods.CreateDispatcherQueueController(new NativeWinRTMethods.DispatcherQueueOptions + { + apartmentType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE, + dwSize = Marshal.SizeOf(), + threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT + }); + tcs.SetResult(new WinUICompositorConnection(angle)); + while (true) + { + while (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) != 0) + UnmanagedMethods.DispatchMessage(ref msg); + } + } + catch (Exception e) + { + tcs.SetException(e); + } + }) + { + IsBackground = true + }; + th.SetApartmentState(ApartmentState.STA); + th.Start(); + return tcs.Task.Result; + } + public static WinUICompositorConnection TryCreate(EglPlatformOpenGlInterface angle) { const int majorRequired = 10; @@ -58,7 +89,7 @@ namespace Avalonia.Win32.WinRT.Composition { try { - return new WinUICompositorConnection(angle); + return TryCreateCore(angle); } catch (Exception e) { @@ -105,16 +136,16 @@ namespace Avalonia.Win32.WinRT.Composition target.SetRoot(containerVisual); - using var blur = CreateBlur(); + using var blur = CreateBlurVisual(); containerChildren.InsertAtTop(blur); containerChildren.InsertAtTop(visual); - //visual.SetCompositeMode(CompositionCompositeMode.SourceOver); return new WinUICompositedWindow(_syncContext, target, surfaceInterop, visual, blur); } - private unsafe IVisual CreateBlur() + + private unsafe ICompositionBrush CreateBlurBrush() { using var backDropParameterFactory = NativeWinRTMethods.CreateActivationFactory( "Windows.UI.Composition.CompositionEffectSourceParameter"); @@ -131,16 +162,18 @@ namespace Avalonia.Win32.WinRT.Composition var saturateEffect = new SaturationEffect(blurEffect); using var satEffectFactory = _compositor.CreateEffectFactory(saturateEffect); using var sat = satEffectFactory.CreateBrush(); - using var satBrush = sat.QueryInterface(); sat.SetSourceParameter(backdropString.Handle, backdropBrush); - + return sat.QueryInterface(); + } + + private unsafe IVisual CreateBlurVisual() + { using var spriteVisual = _compositor.CreateSpriteVisual(); using var visual = spriteVisual.QueryInterface(); using var visual2 = spriteVisual.QueryInterface(); - - + - spriteVisual.SetBrush(satBrush); + spriteVisual.SetBrush(_blurBrush); visual.SetIsVisible(0); visual2.SetRelativeSizeAdjustment(new Vector2(1.0f, 1.0f)); From 16fc224a0fa7e27e6d8a446d4037687a67fe3113 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 04:23:05 +0300 Subject: [PATCH 096/314] Reduce flicker --- .../Composition/WinUICompositedWindow.cs | 28 ++++++++++- .../Composition/WinUICompositorConnection.cs | 18 ++++++-- .../WinUiCompositedWindowSurface.cs | 4 ++ src/Windows/Avalonia.Win32/WinRT/winrt.idl | 46 ++++++++++++++++++- src/tools/MicroComGenerator/CSharpGen.cs | 10 ++-- 5 files changed, 94 insertions(+), 12 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs index da56c98d56..e9b002a208 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs @@ -1,5 +1,7 @@ using System; using System.Numerics; +using System.Reactive.Disposables; +using System.Threading; using Avalonia.MicroCom; using Avalonia.OpenGL; using Avalonia.OpenGL.Egl; @@ -10,6 +12,7 @@ namespace Avalonia.Win32.WinRT.Composition public class WinUICompositedWindow : IDisposable { private EglContext _syncContext; + private readonly object _pumpLock; private readonly IVisual _blurVisual; private ICompositionTarget _compositionTarget; private IVisual _contentVisual; @@ -17,14 +20,19 @@ namespace Avalonia.Win32.WinRT.Composition private PixelSize _size; private static Guid IID_ID3D11Texture2D = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); - + private ICompositor _compositor; + internal WinUICompositedWindow(EglContext syncContext, + ICompositor compositor, + object pumpLock, ICompositionTarget compositionTarget, ICompositionDrawingSurfaceInterop surfaceInterop, IVisual contentVisual, IVisual blurVisual) { + _compositor = compositor.CloneReference(); _syncContext = syncContext; + _pumpLock = pumpLock; _blurVisual = blurVisual.CloneReference(); _compositionTarget = compositionTarget.CloneReference(); _contentVisual = contentVisual.CloneReference(); @@ -36,7 +44,7 @@ namespace Avalonia.Win32.WinRT.Composition { using (_syncContext.EnsureLocked()) { - if (_size != size) + //if (_size != size) { _surfaceInterop.Resize(new UnmanagedMethods.POINT { X = size.Width, Y = size.Height }); _contentVisual.SetSize(new Vector2(size.Width, size.Height)); @@ -70,10 +78,26 @@ namespace Avalonia.Win32.WinRT.Composition _blurVisual.SetIsVisible(enable ? 1 : 0); } + public IDisposable BeginTransaction() + { + Monitor.Enter(_pumpLock); + //var batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Effect); + + return Disposable.Create(() => + { + Monitor.Exit(_pumpLock); + /* + batch?.End(); + batch?.Dispose(); + batch = null;*/ + }); + } + public void Dispose() { if (_syncContext == null) { + _compositor.Dispose(); _blurVisual.Dispose(); _contentVisual.Dispose(); _surfaceInterop.Dispose(); diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs index 8be68bbfe2..393019b547 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -25,10 +25,12 @@ namespace Avalonia.Win32.WinRT.Composition private EglPlatformOpenGlInterface _gl; private ICompositorDesktopInterop _compositorDesktopInterop; private ICompositionBrush _blurBrush; + private object _pumpLock = new object(); - public WinUICompositorConnection(EglPlatformOpenGlInterface gl) + public WinUICompositorConnection(EglPlatformOpenGlInterface gl, object pumpLock) { _gl = gl; + _pumpLock = pumpLock; _syncContext = _gl.PrimaryEglContext; _angle = (AngleWin32EglDisplay)_gl.Display; _compositor = NativeWinRTMethods.CreateInstance("Windows.UI.Composition.Compositor"); @@ -46,6 +48,7 @@ namespace Avalonia.Win32.WinRT.Composition static WinUICompositorConnection TryCreateCore(EglPlatformOpenGlInterface angle) { var tcs = new TaskCompletionSource(); + var pumpLock = new object(); var th = new Thread(() => { try @@ -56,11 +59,16 @@ namespace Avalonia.Win32.WinRT.Composition dwSize = Marshal.SizeOf(), threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT }); - tcs.SetResult(new WinUICompositorConnection(angle)); + tcs.SetResult(new WinUICompositorConnection(angle, pumpLock)); while (true) { - while (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) != 0) - UnmanagedMethods.DispatchMessage(ref msg); + while (true) + { + if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) == 0) + return; + lock (pumpLock) + UnmanagedMethods.DispatchMessage(ref msg); + } } } catch (Exception e) @@ -141,7 +149,7 @@ namespace Avalonia.Win32.WinRT.Composition containerChildren.InsertAtTop(blur); containerChildren.InsertAtTop(visual); - return new WinUICompositedWindow(_syncContext, target, surfaceInterop, visual, blur); + return new WinUICompositedWindow(_syncContext, _compositor, _pumpLock, target, surfaceInterop, visual, blur); } diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs index cc9952c226..f59d50860a 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs @@ -60,6 +60,7 @@ namespace Avalonia.Win32.WinRT.Composition var contextLock = _egl.PrimaryEglContext.EnsureCurrent(); IUnknown texture = null; EglSurface surface = null; + IDisposable transaction = null; var success = false; try { @@ -67,6 +68,7 @@ namespace Avalonia.Win32.WinRT.Composition throw new ObjectDisposedException(GetType().FullName); var size = _info.Size; + transaction = _window.Item.BeginTransaction(); _window.Item.ResizeIfNeeded(size); texture = _window.Item.BeginDrawToTexture(out var offset); @@ -79,6 +81,7 @@ namespace Avalonia.Win32.WinRT.Composition surface?.Dispose(); texture?.Dispose(); _window.Item.EndDraw(); + transaction?.Dispose(); contextLock?.Dispose(); }, true); success = true; @@ -90,6 +93,7 @@ namespace Avalonia.Win32.WinRT.Composition { surface?.Dispose(); texture?.Dispose(); + transaction?.Dispose(); contextLock.Dispose(); } } diff --git a/src/Windows/Avalonia.Win32/WinRT/winrt.idl b/src/Windows/Avalonia.Win32/WinRT/winrt.idl index 9107eecd42..bdc757138c 100644 --- a/src/Windows/Avalonia.Win32/WinRT/winrt.idl +++ b/src/Windows/Avalonia.Win32/WinRT/winrt.idl @@ -328,7 +328,7 @@ interface ICompositor : IInspectable HRESULT CreatePropertySet([out] [retval] void** result); HRESULT CreateQuaternionKeyFrameAnimation([out] [retval] void** result); HRESULT CreateScalarKeyFrameAnimation([out] [retval] void** result); - HRESULT CreateScopedBatch([in] CompositionBatchTypes batchType, [out] [retval] void** result); + HRESULT CreateScopedBatch([in] CompositionBatchTypes batchType, [out] [retval] ICompositionScopedBatch** result); HRESULT CreateSpriteVisual([out] [retval] ISpriteVisual** result); HRESULT CreateSurfaceBrush([out] [retval] ICompositionSurfaceBrush** result); HRESULT CreateSurfaceBrushWithSurface([in] ICompositionSurface* surface, @@ -456,11 +456,41 @@ interface ICompositionDrawingSurface : IInspectable [propget] HRESULT GetSize([out] [retval] POINT* value); } +enum CompositionBitmapInterpolationMode +{ + NearestNeighbor, + Linear, + MagLinearMinLinearMipLinear, + MagLinearMinLinearMipNearest, + MagLinearMinNearestMipLinear, + MagLinearMinNearestMipNearest, + MagNearestMinLinearMipLinear, + MagNearestMinLinearMipNearest, + MagNearestMinNearestMipLinear, + MagNearestMinNearestMipNearest, +} + +enum CompositionStretch +{ + None, + Fill, + Uniform, + UniformToFill, +} [uuid(AD016D79-1E4C-4C0D-9C29-83338C87C162)] interface ICompositionSurfaceBrush : IInspectable { - //TODO + [propget] HRESULT BitmapInterpolationMode([out] [retval] CompositionBitmapInterpolationMode* value); + [propput] HRESULT BitmapInterpolationMode([in] CompositionBitmapInterpolationMode value); + [propget] HRESULT HorizontalAlignmentRatio([out] [retval] FLOAT* value); + [propput] HRESULT HorizontalAlignmentRatio([in] FLOAT value); + [propget] HRESULT Stretch([out] [retval] CompositionStretch* value); + [propput] HRESULT Stretch([in] CompositionStretch value); + [propget] HRESULT Surface([out] [retval] ICompositionSurface** value); + [propput] HRESULT Surface([in] ICompositionSurface* value); + [propget] HRESULT VerticalAlignmentRatio([out] [retval] FLOAT* value); + [propput] HRESULT VerticalAlignmentRatio([in] FLOAT value); } [uuid(AB0D7608-30C0-40E9-B568-B60A6BD1FB46)] @@ -649,3 +679,15 @@ interface ICompositionColorBrush : IInspectable [propget] HRESULT Color([out] [retval] Color* value); [propput] HRESULT Color([in] Color value); } + +[uuid(0D00DAD0-FB07-46FD-8C72-6280D1A3D1DD)] +interface ICompositionScopedBatch : IInspectable +{ + [propget] HRESULT IsActive([out] [retval] boolean* value); + [propget] HRESULT IsEnded([out] [retval] boolean* value); + HRESULT End(); + HRESULT Resume(); + HRESULT Suspend(); + [eventadd] HRESULT AddCompleted([in] void* handler, [out] [retval] int* token); + [eventremove] HRESULT RemoveCompleted([in] int token); +} diff --git a/src/tools/MicroComGenerator/CSharpGen.cs b/src/tools/MicroComGenerator/CSharpGen.cs index c74e7af12e..ff4c351fd9 100644 --- a/src/tools/MicroComGenerator/CSharpGen.cs +++ b/src/tools/MicroComGenerator/CSharpGen.cs @@ -121,7 +121,8 @@ namespace MicroComGenerator NamespaceDeclarationSyntax GenerateEnums(NamespaceDeclarationSyntax ns) { return ns.AddMembers(_idl.Enums.Select(e => - EnumDeclaration(e.Name) + { + var dec = EnumDeclaration(e.Name) .WithModifiers(TokenList(Token(_visibility))) .WithMembers(SeparatedList(e.Select(m => { @@ -129,8 +130,11 @@ namespace MicroComGenerator if (m.Value != null) return member.WithEqualsValue(EqualsValueClause(ParseExpression(m.Value))); return member; - }))) - ).ToArray()); + }))); + if (e.HasAttribute("flags")) + dec = dec.AddAttribute("System.Flags"); + return dec; + }).ToArray()); } NamespaceDeclarationSyntax GenerateStructs(NamespaceDeclarationSyntax ns) From c3154963d8fa50036bb984fd6584923982646e53 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 6 Nov 2020 04:24:52 +0300 Subject: [PATCH 097/314] ... --- .../WinRT/Composition/WinUICompositedWindow.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs index e9b002a208..4ae9c08410 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositedWindow.cs @@ -44,7 +44,7 @@ namespace Avalonia.Win32.WinRT.Composition { using (_syncContext.EnsureLocked()) { - //if (_size != size) + if (_size != size) { _surfaceInterop.Resize(new UnmanagedMethods.POINT { X = size.Width, Y = size.Height }); _contentVisual.SetSize(new Vector2(size.Width, size.Height)); @@ -81,16 +81,7 @@ namespace Avalonia.Win32.WinRT.Composition public IDisposable BeginTransaction() { Monitor.Enter(_pumpLock); - //var batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Effect); - - return Disposable.Create(() => - { - Monitor.Exit(_pumpLock); - /* - batch?.End(); - batch?.Dispose(); - batch = null;*/ - }); + return Disposable.Create(() => Monitor.Exit(_pumpLock)); } public void Dispose() From 8946f4f80d17e848b16639c033470b9eff84f294 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 6 Nov 2020 17:51:10 +0000 Subject: [PATCH 098/314] prevent NRE when popup is open and main window closes. --- src/Avalonia.Native/WindowImplBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 2cf1fe2963..41009232e4 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -155,6 +155,7 @@ namespace Avalonia.Native } finally { + _parent._native = null; n?.Dispose(); } From 13cd835bc0b2b33e8a2884f21b91080d72c8126d Mon Sep 17 00:00:00 2001 From: adospace Date: Sat, 7 Nov 2020 00:00:18 +0100 Subject: [PATCH 099/314] ItemsControl+ItemVirtualizerSimple did not recreated item containers when Items or ItemTemplate were replaced --- global.json | 2 +- src/Avalonia.Controls/ItemsControl.cs | 6 +- .../Presenters/ItemVirtualizerSimple.cs | 4 + .../Presenters/ItemsPresenterBase.cs | 4 +- .../ItemsControlTests.cs | 92 ++++++++++++++ .../ListBoxTests.cs | 112 ++++++++++++++++++ 6 files changed, 217 insertions(+), 3 deletions(-) diff --git a/global.json b/global.json index b2b2da7c4f..684d9bed71 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.401" + "version": "3.1.301" }, "msbuild-sdks": { "Microsoft.Build.Traversal": "1.0.43", diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 4dc8aec6f3..f955df5f21 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -449,7 +449,11 @@ namespace Avalonia.Controls if (_itemContainerGenerator != null) { _itemContainerGenerator.ItemTemplate = (IDataTemplate)e.NewValue; - // TODO: Rebuild the item containers. + + if (e.OldValue != null && Presenter != null) + { + Presenter.ItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + } } } diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs index 7d50ef7d33..51dbc969a8 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs @@ -200,6 +200,10 @@ namespace Avalonia.Controls.Presenters break; case NotifyCollectionChangedAction.Reset: + Owner.ItemContainerGenerator.Clear(); + VirtualizingPanel.Children.Clear(); + FirstIndex = NextIndex = 0; + RecycleContainersOnRemove(); CreateAndRemoveContainers(); panel.ForceInvalidateMeasure(); diff --git a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs index 52f173fc71..6c408bbed9 100644 --- a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs +++ b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs @@ -57,6 +57,8 @@ namespace Avalonia.Controls.Presenters set { + var itemsReplaced = (_items != value); + _itemsSubscription?.Dispose(); _itemsSubscription = null; @@ -67,7 +69,7 @@ namespace Avalonia.Controls.Presenters SetAndRaise(ItemsProperty, ref _items, value); - if (_createdPanel) + if (_createdPanel && itemsReplaced) { ItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } diff --git a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs index 684486cbae..157eefb84a 100644 --- a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs @@ -596,6 +596,98 @@ namespace Avalonia.Controls.UnitTests root.Child = target; } + [Fact] + public void Presenter_Items_Should_Be_In_Sync_When_Replacing_Items() + { + var target = new ItemsControl + { + Template = GetTemplate(), + Items = new[] + { + new Item("Item1") + } + }; + + var root = new TestRoot { Child = target }; + var otherPanel = new StackPanel(); + + target.ApplyTemplate(); + target.Presenter.ApplyTemplate(); + + int dematerializedEventCallCount = 0; + target.ItemContainerGenerator.Dematerialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + dematerializedEventCallCount++; + }; + + int materializedEventCallCount = 0; + target.ItemContainerGenerator.Materialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item2", ((Item)e.Containers[0].Item).Value); + materializedEventCallCount++; + }; + + target.Items = new[] + { + new Item("Item2") + }; + + //Ensure that events are called one time only + Assert.Equal(1, dematerializedEventCallCount); + Assert.Equal(1, materializedEventCallCount); + } + + [Fact] + public void Presenter_Items_Should_Be_In_Sync_When_Replacing_ItemTemplate() + { + var target = new ItemsControl + { + Template = GetTemplate(), + Items = new[] + { + new Item("Item1") + }, + ItemTemplate = new FuncDataTemplate((x, ns) => new TextBlock()) + }; + + var root = new TestRoot { Child = target }; + var otherPanel = new StackPanel(); + + target.ApplyTemplate(); + target.Presenter.ApplyTemplate(); + + int dematerializedEventCallCount = 0; + target.ItemContainerGenerator.Dematerialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + var contentPresenter = ((ContentPresenter)e.Containers[0].ContainerControl); + contentPresenter.UpdateChild(); + Assert.IsType(contentPresenter.Child); + dematerializedEventCallCount++; + }; + + int materializedEventCallCount = 0; + target.ItemContainerGenerator.Materialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + var contentPresenter = ((ContentPresenter)e.Containers[0].ContainerControl); + contentPresenter.UpdateChild(); + Assert.IsType(contentPresenter.Child); + materializedEventCallCount++; + }; + + target.ItemTemplate = + new FuncDataTemplate((x, ns) => new Canvas()); + + Assert.Equal(1, dematerializedEventCallCount); + Assert.Equal(1, materializedEventCallCount); + } + private class Item { public Item(string value) diff --git a/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs b/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs index 145fce4fed..364cb01c65 100644 --- a/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs @@ -454,6 +454,118 @@ namespace Avalonia.Controls.UnitTests } } + + [Fact] + public void ListBox_Presenter_Items_Should_Be_In_Sync_When_Replacing_Items() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var wnd = new Window() { Width = 100, Height = 100, IsVisible = true }; + + var target = new ListBox() + { + VerticalAlignment = Layout.VerticalAlignment.Top, + AutoScrollToSelectedItem = true, + Width = 50, + VirtualizationMode = ItemVirtualizationMode.Simple, + Items = new[] + { + new Item("Item1") + }, + }; + wnd.Content = target; + + var lm = wnd.LayoutManager; + + lm.ExecuteInitialLayoutPass(); + + int dematerializedEventCallCount = 0; + target.ItemContainerGenerator.Dematerialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + dematerializedEventCallCount++; + }; + + int materializedEventCallCount = 0; + target.ItemContainerGenerator.Materialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item2", ((Item)e.Containers[0].Item).Value); + materializedEventCallCount++; + }; + + target.Items = new[] + { + new Item("Item2") + }; + + //assert that materialize/dematerialize events are called exactly one time + Assert.Equal(1, dematerializedEventCallCount); + Assert.Equal(1, materializedEventCallCount); + } + } + + [Fact] + public void ListBox_Items_Should_Be_In_Sync_When_Replacing_ItemTemplate() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var wnd = new Window() { Width = 100, Height = 100, IsVisible = true }; + + var target = new ListBox() + { + VerticalAlignment = Layout.VerticalAlignment.Top, + AutoScrollToSelectedItem = true, + Width = 50, + VirtualizationMode = ItemVirtualizationMode.Simple, + Items = new[] + { + new Item("Item1") + }, + ItemTemplate = + new FuncDataTemplate((x, ns) => new Canvas()) + }; + + wnd.Content = target; + + var lm = wnd.LayoutManager; + + lm.ExecuteInitialLayoutPass(); + + int dematerializedEventCallCount = 0; + target.ItemContainerGenerator.Dematerialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + Assert.IsType(((ListBoxItem)e.Containers[0].ContainerControl).Presenter.Child); + dematerializedEventCallCount++; + }; + + int materializedEventCallCount = 0; + ListBoxItem materializedListBoxItem = null; + target.ItemContainerGenerator.Materialized += (s, e) => + { + Assert.IsType(e.Containers[0].Item); + Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); + materializedListBoxItem = ((ListBoxItem)e.Containers[0].ContainerControl); + materializedEventCallCount++; + }; + + target.ItemTemplate = + new FuncDataTemplate((x, ns) => new TextBlock()); + + //ensure events are called only one time + Assert.Equal(1, dematerializedEventCallCount); + Assert.Equal(1, materializedEventCallCount); + + wnd.LayoutManager.ExecuteLayoutPass(); + + //ensure that new template has been applied + Assert.IsType(materializedListBoxItem.Presenter.Child); + } + } + private FuncControlTemplate ListBoxTemplate() { return new FuncControlTemplate((parent, scope) => From a1d9d5296fb328a3f18f3c3c98bf4cbefb9603bf Mon Sep 17 00:00:00 2001 From: adospace Date: Sat, 7 Nov 2020 00:05:25 +0100 Subject: [PATCH 100/314] Set sdk version back to 3.1.401 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 684d9bed71..b2b2da7c4f 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.301" + "version": "3.1.401" }, "msbuild-sdks": { "Microsoft.Build.Traversal": "1.0.43", From eecc91feaa59e8d2e27b37440ca0fa3e9d5debb4 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 7 Nov 2020 19:51:56 +0000 Subject: [PATCH 101/314] cleaner fix. --- src/Avalonia.Native/WindowImplBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 41009232e4..20b6b8ecc5 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -155,11 +155,10 @@ namespace Avalonia.Native } finally { - _parent._native = null; + + _parent?.Dispose(); n?.Dispose(); } - - _parent._mouse.Dispose(); } void IAvnWindowBaseEvents.Activated() => _parent.Activated?.Invoke(); @@ -337,6 +336,7 @@ namespace Avalonia.Native _nativeControlHost = null; (Screen as ScreenImpl)?.Dispose(); + _mouse.Dispose(); } From 177d18463a5fb35c318f67a8fe74f1efd1167c8f Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 7 Nov 2020 16:17:21 +0100 Subject: [PATCH 102/314] Add support for visualizing layout properties. --- .../ViewModels/ControlDetailsViewModel.cs | 6 + .../ViewModels/ControlLayoutViewModel.cs | 150 ++++++++++++++++++ .../Diagnostics/Views/ControlDetailsView.xaml | 145 +++++++++++++---- .../Diagnostics/Views/ThicknessEditor.cs | 117 ++++++++++++++ 4 files changed, 387 insertions(+), 31 deletions(-) create mode 100644 src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs create mode 100644 src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs index d4b988acd4..fa41eacbeb 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs @@ -32,6 +32,8 @@ namespace Avalonia.Diagnostics.ViewModels view.Filter = FilterProperty; PropertiesView = view; + Layout = new ControlLayoutViewModel(control); + if (control is INotifyPropertyChanged inpc) { inpc.PropertyChanged += ControlPropertyChanged; @@ -52,6 +54,8 @@ namespace Avalonia.Diagnostics.ViewModels get => _selectedProperty; set => RaiseAndSetIfChanged(ref _selectedProperty, value); } + + public ControlLayoutViewModel Layout { get; } public void Dispose() { @@ -112,6 +116,8 @@ namespace Avalonia.Diagnostics.ViewModels property.Update(); } } + + Layout.ControlPropertyChanged(sender, e); } private void ControlPropertyChanged(object sender, PropertyChangedEventArgs e) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs new file mode 100644 index 0000000000..0173f19358 --- /dev/null +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs @@ -0,0 +1,150 @@ +using System.ComponentModel; +using Avalonia.Controls; +using Avalonia.Layout; +using Avalonia.VisualTree; + +namespace Avalonia.Diagnostics.ViewModels +{ + internal class ControlLayoutViewModel : ViewModelBase + { + private readonly IVisual _control; + private Thickness _marginThickness; + private Thickness _borderThickness; + private Thickness _paddingThickness; + private string _sizeText; + + public Thickness MarginThickness + { + get => _marginThickness; + set => RaiseAndSetIfChanged(ref _marginThickness, value); + } + + public Thickness BorderThickness + { + get => _borderThickness; + set => RaiseAndSetIfChanged(ref _borderThickness, value); + } + + public Thickness PaddingThickness + { + get => _paddingThickness; + set => RaiseAndSetIfChanged(ref _paddingThickness, value); + } + + public string SizeText + { + get => _sizeText; + private set => RaiseAndSetIfChanged(ref _sizeText, value); + } + + public bool HasPadding { get; } + + public bool HasBorder { get; } + + public ControlLayoutViewModel(IVisual control) + { + _control = control; + + HasPadding = AvaloniaPropertyRegistry.Instance.IsRegistered(control, Decorator.PaddingProperty); + HasBorder = AvaloniaPropertyRegistry.Instance.IsRegistered(control, Border.BorderThicknessProperty); + + if (control is AvaloniaObject ao) + { + MarginThickness = ao.GetValue(Layoutable.MarginProperty); + + if (HasPadding) + { + PaddingThickness = ao.GetValue(Decorator.PaddingProperty); + } + + if (HasBorder) + { + BorderThickness = ao.GetValue(Border.BorderThicknessProperty); + } + } + + UpdateSize(); + } + + private bool _updatingFromControl; + + protected override void OnPropertyChanged(PropertyChangedEventArgs e) + { + base.OnPropertyChanged(e); + + if (_updatingFromControl) + { + return; + } + + if (_control is AvaloniaObject ao) + { + if (e.PropertyName == nameof(MarginThickness)) + { + ao.SetValue(Layoutable.MarginProperty, MarginThickness); + } + else if (HasPadding && e.PropertyName == nameof(PaddingThickness)) + { + ao.SetValue(Decorator.PaddingProperty, PaddingThickness); + } + else if (HasBorder && e.PropertyName == nameof(BorderThickness)) + { + ao.SetValue(Border.BorderThicknessProperty, BorderThickness); + } + } + } + + public void ControlPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) + { + try + { + _updatingFromControl = true; + + var updateSize = false; + + if (e.Property == Visual.BoundsProperty) + { + updateSize = true; + } + else + { + if (_control is IAvaloniaObject ao) + { + if (e.Property == Layoutable.MarginProperty) + { + MarginThickness = ao.GetValue(Layoutable.MarginProperty); + } + else if (e.Property == Decorator.PaddingProperty) + { + PaddingThickness = ao.GetValue(Decorator.PaddingProperty); + } + else if (e.Property == Border.BorderThicknessProperty) + { + BorderThickness = ao.GetValue(Border.BorderThicknessProperty); + + updateSize = true; + } + } + } + + if (updateSize) + { + UpdateSize(); + } + } + finally + { + _updatingFromControl = false; + } + } + + private void UpdateSize() + { + var size = _control.Bounds; + + size.Deflate(BorderThickness); + + SizeText = $"{size.Width} {size.Height}"; + } + } +} diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml index 8aad5fffd8..1487cb6dde 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml @@ -1,38 +1,121 @@  - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs b/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs new file mode 100644 index 0000000000..58ea91c2fa --- /dev/null +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs @@ -0,0 +1,117 @@ +using Avalonia.Controls; +using Avalonia.Data; + +namespace Avalonia.Diagnostics.Views +{ + internal class ThicknessEditor : ContentControl + { + public static readonly DirectProperty ThicknessProperty = + AvaloniaProperty.RegisterDirect(nameof(Thickness), o => o.Thickness, + (o, v) => o.Thickness = v, defaultBindingMode: BindingMode.TwoWay); + + public static readonly DirectProperty HeaderProperty = + AvaloniaProperty.RegisterDirect(nameof(Header), o => o.Header, + (o, v) => o.Header = v); + + public static readonly DirectProperty IsPresentProperty = + AvaloniaProperty.RegisterDirect(nameof(Header), o => o.IsPresent, + (o, v) => o.IsPresent = v); + + public static readonly DirectProperty LeftProperty = + AvaloniaProperty.RegisterDirect(nameof(Left), o => o.Left, (o, v) => o.Left = v); + + public static readonly DirectProperty TopProperty = + AvaloniaProperty.RegisterDirect(nameof(Top), o => o.Top, (o, v) => o.Top = v); + + public static readonly DirectProperty RightProperty = + AvaloniaProperty.RegisterDirect(nameof(Right), o => o.Right, + (o, v) => o.Right = v); + + public static readonly DirectProperty BottomProperty = + AvaloniaProperty.RegisterDirect(nameof(Bottom), o => o.Bottom, + (o, v) => o.Bottom = v); + + + private Thickness _thickness; + private string _header; + private bool _isPresent = true; + private double _left; + private double _top; + private double _right; + private double _bottom; + + private bool _isUpdatingThickness; + + public Thickness Thickness + { + get => _thickness; + set => SetAndRaise(ThicknessProperty, ref _thickness, value); + } + + public string Header + { + get => _header; + set => SetAndRaise(HeaderProperty, ref _header, value); + } + + public bool IsPresent + { + get => _isPresent; + set => SetAndRaise(IsPresentProperty, ref _isPresent, value); + } + + public double Left + { + get => _left; + set => SetAndRaise(LeftProperty, ref _left, value); + } + + public double Top + { + get => _top; + set => SetAndRaise(TopProperty, ref _top, value); + } + + public double Right + { + get => _right; + set => SetAndRaise(RightProperty, ref _right, value); + } + + public double Bottom + { + get => _bottom; + set => SetAndRaise(BottomProperty, ref _bottom, value); + } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == ThicknessProperty) + { + try + { + _isUpdatingThickness = true; + + var value = change.NewValue.GetValueOrDefault(); + + Left = value.Left; + Top = value.Top; + Right = value.Right; + Bottom = value.Bottom; + } + finally + { + _isUpdatingThickness = false; + } + } + else if (!_isUpdatingThickness && + (change.Property == LeftProperty || change.Property == TopProperty || + change.Property == RightProperty || change.Property == BottomProperty)) + { + Thickness = new Thickness(Left, Top, Right, Bottom); + } + } + } +} From 91fec98a75e247054a93de7dc7d28c1ba6562415 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 7 Nov 2020 16:21:07 +0100 Subject: [PATCH 103/314] Move field. --- .../Diagnostics/ViewModels/ControlLayoutViewModel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs index 0173f19358..2ee8df78ef 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs @@ -12,6 +12,7 @@ namespace Avalonia.Diagnostics.ViewModels private Thickness _borderThickness; private Thickness _paddingThickness; private string _sizeText; + private bool _updatingFromControl; public Thickness MarginThickness { @@ -66,8 +67,6 @@ namespace Avalonia.Diagnostics.ViewModels UpdateSize(); } - private bool _updatingFromControl; - protected override void OnPropertyChanged(PropertyChangedEventArgs e) { base.OnPropertyChanged(e); From 77ecdc0013b89d58ca13624610af165c45a1452e Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 7 Nov 2020 22:51:45 +0100 Subject: [PATCH 104/314] Display control size accurately and add info about sizing constraints. --- .../ViewModels/ControlLayoutViewModel.cs | 75 +++++++++--- .../Diagnostics/Views/ControlDetailsView.xaml | 47 ++++++-- .../Views/ControlDetailsView.xaml.cs | 109 ++++++++++++++++++ .../Diagnostics/Views/ThicknessEditor.cs | 13 +++ 4 files changed, 220 insertions(+), 24 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs index 2ee8df78ef..fd2e4c3355 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlLayoutViewModel.cs @@ -11,7 +11,10 @@ namespace Avalonia.Diagnostics.ViewModels private Thickness _marginThickness; private Thickness _borderThickness; private Thickness _paddingThickness; - private string _sizeText; + private double _width; + private double _height; + private string _widthConstraint; + private string _heightConstraint; private bool _updatingFromControl; public Thickness MarginThickness @@ -32,10 +35,28 @@ namespace Avalonia.Diagnostics.ViewModels set => RaiseAndSetIfChanged(ref _paddingThickness, value); } - public string SizeText + public double Width { - get => _sizeText; - private set => RaiseAndSetIfChanged(ref _sizeText, value); + get => _width; + private set => RaiseAndSetIfChanged(ref _width, value); + } + + public double Height + { + get => _height; + private set => RaiseAndSetIfChanged(ref _height, value); + } + + public string WidthConstraint + { + get => _widthConstraint; + private set => RaiseAndSetIfChanged(ref _widthConstraint, value); + } + + public string HeightConstraint + { + get => _heightConstraint; + private set => RaiseAndSetIfChanged(ref _heightConstraint, value); } public bool HasPadding { get; } @@ -65,6 +86,29 @@ namespace Avalonia.Diagnostics.ViewModels } UpdateSize(); + UpdateSizeConstraints(); + } + + private void UpdateSizeConstraints() + { + if (_control is IAvaloniaObject ao) + { + string CreateConstraintInfo(StyledProperty minProperty, StyledProperty maxProperty) + { + if (ao.IsSet(minProperty) || ao.IsSet(maxProperty)) + { + var minValue = ao.GetValue(minProperty); + var maxValue = ao.GetValue(maxProperty); + + return $"{minValue} < size < {maxValue}"; + } + + return null; + } + + WidthConstraint = CreateConstraintInfo(Layoutable.MinWidthProperty, Layoutable.MaxWidthProperty); + HeightConstraint = CreateConstraintInfo(Layoutable.MinHeightProperty, Layoutable.MaxHeightProperty); + } } protected override void OnPropertyChanged(PropertyChangedEventArgs e) @@ -99,11 +143,9 @@ namespace Avalonia.Diagnostics.ViewModels { _updatingFromControl = true; - var updateSize = false; - if (e.Property == Visual.BoundsProperty) { - updateSize = true; + UpdateSize(); } else { @@ -120,16 +162,16 @@ namespace Avalonia.Diagnostics.ViewModels else if (e.Property == Border.BorderThicknessProperty) { BorderThickness = ao.GetValue(Border.BorderThicknessProperty); - - updateSize = true; + } + else if (e.Property == Layoutable.MinWidthProperty || + e.Property == Layoutable.MaxWidthProperty || + e.Property == Layoutable.MinHeightProperty || + e.Property == Layoutable.MaxHeightProperty) + { + UpdateSizeConstraints(); } } } - - if (updateSize) - { - UpdateSize(); - } } finally { @@ -141,9 +183,8 @@ namespace Avalonia.Diagnostics.ViewModels { var size = _control.Bounds; - size.Deflate(BorderThickness); - - SizeText = $"{size.Width} {size.Height}"; + Width = size.Width; + Height = size.Height; } } } diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml index 1487cb6dde..42e64d59ae 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml @@ -106,15 +106,48 @@ - - - - - - + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml.cs b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml.cs index c6bd5a18aa..c9568509f6 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml.cs @@ -1,10 +1,24 @@ +using System; using Avalonia.Controls; +using Avalonia.Controls.Shapes; using Avalonia.Markup.Xaml; +using Avalonia.VisualTree; namespace Avalonia.Diagnostics.Views { internal class ControlDetailsView : UserControl { + private ThicknessEditor _borderArea; + private ThicknessEditor _paddingArea; + private Rectangle _horizontalSizeBegin; + private Rectangle _horizontalSizeEnd; + private Rectangle _verticalSizeBegin; + private Rectangle _verticalSizeEnd; + private Grid _layoutRoot; + private Border _horizontalSize; + private Border _verticalSize; + private Border _contentArea; + public ControlDetailsView() { InitializeComponent(); @@ -13,6 +27,101 @@ namespace Avalonia.Diagnostics.Views private void InitializeComponent() { AvaloniaXamlLoader.Load(this); + + _borderArea = this.FindControl("BorderArea"); + _paddingArea = this.FindControl("PaddingArea"); + + _horizontalSizeBegin = this.FindControl("HorizontalSizeBegin"); + _horizontalSizeEnd = this.FindControl("HorizontalSizeEnd"); + _verticalSizeBegin = this.FindControl("VerticalSizeBegin"); + _verticalSizeEnd = this.FindControl("VerticalSizeEnd"); + + _horizontalSize = this.FindControl("HorizontalSize"); + _verticalSize = this.FindControl("VerticalSize"); + + _contentArea = this.FindControl("ContentArea"); + + _layoutRoot = this.FindControl("LayoutRoot"); + + void SubscribeToBounds(Visual visual) + { + visual.GetPropertyChangedObservable(TransformedBoundsProperty) + .Subscribe(UpdateSizeGuidelines); + } + + SubscribeToBounds(_borderArea); + SubscribeToBounds(_paddingArea); + SubscribeToBounds(_contentArea); + } + + private void UpdateSizeGuidelines(AvaloniaPropertyChangedEventArgs e) + { + void UpdateGuidelines(Visual area) + { + if (area.TransformedBounds is TransformedBounds bounds) + { + // Horizontal guideline + { + var sizeArea = TranslateToRoot((_horizontalSize.TransformedBounds ?? default).Bounds.BottomLeft, + _horizontalSize); + + var start = TranslateToRoot(bounds.Bounds.BottomLeft, area); + + SetPosition(_horizontalSizeBegin, start); + + var end = TranslateToRoot(bounds.Bounds.BottomRight, area); + + SetPosition(_horizontalSizeEnd, end.WithX(end.X - 1)); + + var height = sizeArea.Y - start.Y + 2; + + _horizontalSizeBegin.Height = height; + _horizontalSizeEnd.Height = height; + } + + // Vertical guideline + { + var sizeArea = TranslateToRoot((_verticalSize.TransformedBounds ?? default).Bounds.TopRight, _verticalSize); + + var start = TranslateToRoot(bounds.Bounds.TopRight, area); + + SetPosition(_verticalSizeBegin, start); + + var end = TranslateToRoot(bounds.Bounds.BottomRight, area); + + SetPosition(_verticalSizeEnd, end.WithY(end.Y - 1)); + + var width = sizeArea.X - start.X + 2; + + _verticalSizeBegin.Width = width; + _verticalSizeEnd.Width = width; + } + } + } + + Point TranslateToRoot(Point point, IVisual from) + { + return from.TranslatePoint(point, _layoutRoot) ?? default; + } + + static void SetPosition(Rectangle rect, Point start) + { + Canvas.SetLeft(rect, start.X); + Canvas.SetTop(rect, start.Y); + } + + if (_borderArea.IsPresent) + { + UpdateGuidelines(_borderArea); + } + else if (_paddingArea.IsPresent) + { + UpdateGuidelines(_paddingArea); + } + else + { + UpdateGuidelines(_contentArea); + } } } } diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs b/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs index 58ea91c2fa..c7611c8c46 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ThicknessEditor.cs @@ -1,8 +1,21 @@ using Avalonia.Controls; using Avalonia.Data; +using Avalonia.Data.Converters; +using Avalonia.Media; namespace Avalonia.Diagnostics.Views { + internal static class Converters + { + public static IValueConverter HasConstraintConverter = + new FuncValueConverter(ConvertToDecoration); + + private static TextDecorationCollection ConvertToDecoration(object arg) + { + return arg != null ? TextDecorations.Underline : null; + } + } + internal class ThicknessEditor : ContentControl { public static readonly DirectProperty ThicknessProperty = From 145d4a3ccb0d16887aebeeb2f7df69ca6ba43b7b Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 8 Nov 2020 17:18:25 +0100 Subject: [PATCH 105/314] Adjust sizing a bit. --- .../Diagnostics/Views/ControlDetailsView.xaml | 5 +++-- src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml index 42e64d59ae..2e0b6813ba 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml @@ -6,6 +6,7 @@ + @@ -62,7 +63,7 @@ - + @@ -137,7 +138,7 @@ diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml index 98de9b611e..86137dfc57 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Avalonia.Diagnostics.ViewModels" x:Class="Avalonia.Diagnostics.Views.TreePageView"> - + Date: Sun, 8 Nov 2020 22:17:11 +0100 Subject: [PATCH 106/314] Add a single argument Parse function for FontFamily. --- src/Avalonia.Visuals/Media/FontFamily.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Media/FontFamily.cs b/src/Avalonia.Visuals/Media/FontFamily.cs index 9db49200cd..f018733235 100644 --- a/src/Avalonia.Visuals/Media/FontFamily.cs +++ b/src/Avalonia.Visuals/Media/FontFamily.cs @@ -133,6 +133,16 @@ namespace Avalonia.Media } } + /// + /// Parses a string. + /// + /// The string. + /// + /// + /// Specified family is not supported. + /// + public static FontFamily Parse(string s) => Parse(s, null); + /// /// Parses a string. /// @@ -142,7 +152,7 @@ namespace Avalonia.Media /// /// Specified family is not supported. /// - public static FontFamily Parse(string s, Uri baseUri = null) + public static FontFamily Parse(string s, Uri baseUri) { if (string.IsNullOrEmpty(s)) { From 59d531b9f310c27ce2c74b46ef96f45f5994dc40 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 10 Nov 2020 13:56:07 +0100 Subject: [PATCH 107/314] Don't use manual FBO for RenderTargetBitmap/VisualBrush. Fixes the first part of #4944. --- src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 12 +++++++----- src/Skia/Avalonia.Skia/PlatformRenderInterface.cs | 3 ++- src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs | 5 ++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index 44e0c82110..2a79a4bb50 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -434,7 +434,7 @@ namespace Avalonia.Skia /// public IDrawingContextLayerImpl CreateLayer(Size size) { - return CreateRenderTarget( size); + return CreateRenderTarget(size, true); } /// @@ -673,7 +673,7 @@ namespace Avalonia.Skia private void ConfigureTileBrush(ref PaintWrapper paintWrapper, Size targetSize, ITileBrush tileBrush, IDrawableBitmapImpl tileBrushImage) { var calc = new TileBrushCalculator(tileBrush, tileBrushImage.PixelSize.ToSizeWithDpi(_dpi), targetSize); - var intermediate = CreateRenderTarget(calc.IntermediateSize); + var intermediate = CreateRenderTarget(calc.IntermediateSize, false); paintWrapper.AddDisposable(intermediate); @@ -748,7 +748,7 @@ namespace Avalonia.Skia if (intermediateSize.Width >= 1 && intermediateSize.Height >= 1) { - var intermediate = CreateRenderTarget(intermediateSize); + var intermediate = CreateRenderTarget(intermediateSize, false); using (var ctx = intermediate.CreateDrawingContext(visualBrushRenderer)) { @@ -978,9 +978,10 @@ namespace Avalonia.Skia /// Create new render target compatible with this drawing context. /// /// The size of the render target in DIPs. + /// Whether the render target is being created for a layer. /// Pixel format. /// - private SurfaceRenderTarget CreateRenderTarget(Size size, PixelFormat? format = null) + private SurfaceRenderTarget CreateRenderTarget(Size size, bool isLayer, PixelFormat? format = null) { var pixelSize = PixelSize.FromSizeWithDpi(size, _dpi); var createInfo = new SurfaceRenderTarget.CreateInfo @@ -992,7 +993,8 @@ namespace Avalonia.Skia DisableTextLcdRendering = !_canTextUseLcdRendering, GrContext = _grContext, Gpu = _gpu, - Session = _session + Session = _session, + DisableManualFbo = !isLayer, }; return new SurfaceRenderTarget(createInfo); diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index d6f76a2c20..72700fb8fd 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -124,7 +124,8 @@ namespace Avalonia.Skia Width = size.Width, Height = size.Height, Dpi = dpi, - DisableTextLcdRendering = false + DisableTextLcdRendering = false, + DisableManualFbo = true, }; return new SurfaceRenderTarget(createInfo); diff --git a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs index 6347c64aed..01b7449b64 100644 --- a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs @@ -51,7 +51,8 @@ namespace Avalonia.Skia _grContext = createInfo.GrContext; _gpu = createInfo.Gpu; - _surface = _gpu?.TryCreateSurface(PixelSize, createInfo.Session); + if (!createInfo.DisableManualFbo) + _surface = _gpu?.TryCreateSurface(PixelSize, createInfo.Session); if (_surface == null) _surface = new SkiaSurfaceWrapper(CreateSurface(createInfo.GrContext, PixelSize.Width, PixelSize.Height, createInfo.Format)); @@ -220,6 +221,8 @@ namespace Avalonia.Skia public ISkiaGpu Gpu; public ISkiaGpuRenderSession Session; + + public bool DisableManualFbo; } } } From f9a6da26da55d5ebae013610b544258fb6f9ad89 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 10 Nov 2020 16:59:41 +0100 Subject: [PATCH 108/314] Don't respect root position when building scene. `VisualBrush` should not respect the root control's `Bounds.Position` and always display the root control at 0,0. Because other top level controls should always have a position of 0,0 anyway this should only affect visual brushes. Fixes the second part of #4944 --- .../Rendering/SceneGraph/SceneBuilder.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs index 872f69c884..7d5d62a091 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs @@ -24,7 +24,8 @@ namespace Avalonia.Rendering.SceneGraph using (var impl = new DeferredDrawingContextImpl(this, scene.Layers)) using (var context = new DrawingContext(impl)) { - Update(context, scene, (VisualNode)scene.Root, scene.Root.Visual.Bounds, true); + var clip = new Rect(scene.Root.Visual.Bounds.Size); + Update(context, scene, (VisualNode)scene.Root, clip, true); } } @@ -77,7 +78,7 @@ namespace Avalonia.Rendering.SceneGraph using (var impl = new DeferredDrawingContextImpl(this, scene.Layers)) using (var context = new DrawingContext(impl)) { - var clip = scene.Root.Visual.Bounds; + var clip = new Rect(scene.Root.Visual.Bounds.Size); if (node.Parent != null) { @@ -174,7 +175,9 @@ namespace Avalonia.Rendering.SceneGraph if (visual.IsVisible) { - var m = Matrix.CreateTranslation(visual.Bounds.Position); + var m = node != scene.Root ? + Matrix.CreateTranslation(visual.Bounds.Position) : + Matrix.Identity; var renderTransform = Matrix.Identity; From e17f18de45ed3b9c1c851dafefeb904f62346329 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 10 Nov 2020 17:10:38 +0100 Subject: [PATCH 109/314] Update SelectionBoxItem on visual tree attach. Fixes initial sizing of `SelectionBoxItem` when it's a control. --- src/Avalonia.Controls/ComboBox.cs | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/ComboBox.cs b/src/Avalonia.Controls/ComboBox.cs index 02a9daee75..7f2acb58fe 100644 --- a/src/Avalonia.Controls/ComboBox.cs +++ b/src/Avalonia.Controls/ComboBox.cs @@ -173,11 +173,10 @@ namespace Avalonia.Controls ComboBoxItem.ContentTemplateProperty); } - /// - protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { - base.OnAttachedToLogicalTree(e); - this.UpdateSelectionBoxItem(this.SelectedItem); + base.OnAttachedToVisualTree(e); + this.UpdateSelectionBoxItem(SelectedItem); } /// @@ -373,19 +372,22 @@ namespace Avalonia.Controls if (control != null) { - control.Measure(Size.Infinity); - - SelectionBoxItem = new Rectangle + if (VisualRoot is object) { - Width = control.DesiredSize.Width, - Height = control.DesiredSize.Height, - Fill = new VisualBrush + control.Measure(Size.Infinity); + + SelectionBoxItem = new Rectangle { - Visual = control, - Stretch = Stretch.None, - AlignmentX = AlignmentX.Left, - } - }; + Width = control.DesiredSize.Width, + Height = control.DesiredSize.Height, + Fill = new VisualBrush + { + Visual = control, + Stretch = Stretch.None, + AlignmentX = AlignmentX.Left, + } + }; + } } else { From c6540c1bf266c619634551d7cfb2b3005bb23555 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 10 Nov 2020 18:09:49 +0100 Subject: [PATCH 110/314] Fix failing test. --- tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs index 783215fb5d..c8a30a42e9 100644 --- a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs @@ -40,6 +40,7 @@ namespace Avalonia.Controls.UnitTests Items = items, SelectedIndex = 0, }; + var root = new TestRoot(target); var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; Assert.NotNull(rectangle); From 380ada052fa656afc18d236d32feeb0ae27b04bf Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Wed, 11 Nov 2020 16:21:16 +0100 Subject: [PATCH 111/314] Fix a few not needed allocations. --- .../Templates/DataTemplateExtensions.cs | 27 ++++++++++--------- .../Parsers/BindingExpressionGrammar.cs | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs b/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs index f6e28483fd..d4e2c25c42 100644 --- a/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs +++ b/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs @@ -1,6 +1,8 @@ using System.Linq; using Avalonia.LogicalTree; +#nullable enable + namespace Avalonia.Controls.Templates { /// @@ -18,21 +20,23 @@ namespace Avalonia.Controls.Templates /// tree are searched. /// /// The data template or null if no matching data template was found. - public static IDataTemplate FindDataTemplate( + public static IDataTemplate? FindDataTemplate( this IControl control, object data, - IDataTemplate primary = null) + IDataTemplate? primary = null) { if (primary?.Match(data) == true) { return primary; } - foreach (var i in control.GetSelfAndLogicalAncestors().OfType()) + var currentTemplateHost = control as ILogical; + + while (currentTemplateHost != null) { - if (i.IsDataTemplatesInitialized) + if (currentTemplateHost is IDataTemplateHost hostCandidate && hostCandidate.IsDataTemplatesInitialized) { - foreach (IDataTemplate dt in i.DataTemplates) + foreach (IDataTemplate dt in hostCandidate.DataTemplates) { if (dt.Match(data)) { @@ -40,20 +44,19 @@ namespace Avalonia.Controls.Templates } } } + + currentTemplateHost = currentTemplateHost.LogicalParent; } IGlobalDataTemplates global = AvaloniaLocator.Current.GetService(); - if (global != null) + if (global != null && global.IsDataTemplatesInitialized) { - if (global.IsDataTemplatesInitialized) + foreach (IDataTemplate dt in global.DataTemplates) { - foreach (IDataTemplate dt in global.DataTemplates) + if (dt.Match(data)) { - if (dt.Match(data)) - { - return dt; - } + return dt; } } } diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs index 8de64e56ff..8e5631e198 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs @@ -16,7 +16,7 @@ namespace Avalonia.Markup.Parsers internal static class BindingExpressionGrammar { - public static (IList Nodes, SourceMode Mode) Parse(ref CharacterReader r) + public static (List Nodes, SourceMode Mode) Parse(ref CharacterReader r) { var nodes = new List(); var state = State.Start; From 75824a0154d62c99049c1653806deb1f16178e13 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Wed, 11 Nov 2020 16:22:59 +0100 Subject: [PATCH 112/314] Remove not needed using. --- src/Avalonia.Controls/Templates/DataTemplateExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs b/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs index d4e2c25c42..2b115aec7e 100644 --- a/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs +++ b/src/Avalonia.Controls/Templates/DataTemplateExtensions.cs @@ -1,4 +1,3 @@ -using System.Linq; using Avalonia.LogicalTree; #nullable enable From 612b1c6c69f142c7d643ee8aaa082e088cb1d3ff Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 12 Nov 2020 20:48:15 +0100 Subject: [PATCH 113/314] Add WS_CLIPCHILDREN to PopupImpl. Needed for embedding chromium, see https://github.com/AvaloniaUI/Avalonia/issues/3281#issuecomment-557615525 --- src/Windows/Avalonia.Win32/PopupImpl.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Win32/PopupImpl.cs b/src/Windows/Avalonia.Win32/PopupImpl.cs index 57da1c4d66..7fb146899b 100644 --- a/src/Windows/Avalonia.Win32/PopupImpl.cs +++ b/src/Windows/Avalonia.Win32/PopupImpl.cs @@ -69,7 +69,8 @@ namespace Avalonia.Win32 { UnmanagedMethods.WindowStyles style = UnmanagedMethods.WindowStyles.WS_POPUP | - UnmanagedMethods.WindowStyles.WS_CLIPSIBLINGS; + UnmanagedMethods.WindowStyles.WS_CLIPSIBLINGS | + UnmanagedMethods.WindowStyles.WS_CLIPCHILDREN; UnmanagedMethods.WindowStyles exStyle = UnmanagedMethods.WindowStyles.WS_EX_TOOLWINDOW | From 1b0ff07133851b32f853d6815a7cc17612475f0e Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 13 Nov 2020 13:21:23 +0100 Subject: [PATCH 114/314] Fixes Issue 4980: Message loop exit when GetMessage < 0 --- src/Avalonia.Base/Logging/LogArea.cs | 5 +++++ .../Avalonia.Win32/Interop/UnmanagedMethods.cs | 4 ++-- src/Windows/Avalonia.Win32/Win32Platform.cs | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/Logging/LogArea.cs b/src/Avalonia.Base/Logging/LogArea.cs index 3c19b47a05..ce330247f3 100644 --- a/src/Avalonia.Base/Logging/LogArea.cs +++ b/src/Avalonia.Base/Logging/LogArea.cs @@ -34,5 +34,10 @@ namespace Avalonia.Logging /// The log event comes from the control system. /// public const string Control = "Control"; + + /// + /// The log evevnt come from Win32Platform + /// + public const string Win32Platform = nameof(Win32Platform); } } diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index f88c57cf59..85938829f6 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -931,8 +931,8 @@ namespace Avalonia.Win32.Interop [DllImport("user32.dll", EntryPoint = "MapVirtualKeyW")] public static extern uint MapVirtualKey(uint uCode, uint uMapType); - [DllImport("user32.dll", EntryPoint = "GetMessageW")] - public static extern sbyte GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax); + [DllImport("user32.dll", EntryPoint = "GetMessageW",SetLastError = true)] + public static extern int GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax); [DllImport("user32.dll")] public static extern int GetMessageTime(); diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 5b16cae26e..209cb63603 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -137,13 +137,18 @@ namespace Avalonia.Win32 public void RunLoop(CancellationToken cancellationToken) { - while (!cancellationToken.IsCancellationRequested) + var result = 0; + while (!cancellationToken.IsCancellationRequested + && (result = UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0)) > 0) { - UnmanagedMethods.MSG msg; - UnmanagedMethods.GetMessage(out msg, IntPtr.Zero, 0, 0); UnmanagedMethods.TranslateMessage(ref msg); UnmanagedMethods.DispatchMessage(ref msg); } + if (result < 0) + { + Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) + ?.Log(this, "Unmanaged error in message loop. Error Code: {0}", Marshal.GetLastWin32Error()); + } } public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action callback) From b31b6d68c9791085766550cdc29bcde12b1608a0 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Fri, 13 Nov 2020 16:17:03 +0100 Subject: [PATCH 115/314] Fixes ProcessMessage --- src/Windows/Avalonia.Win32/Win32Platform.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 209cb63603..1ed4d8dc9c 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -129,10 +129,18 @@ namespace Avalonia.Win32 public void ProcessMessage() { - UnmanagedMethods.MSG msg; - UnmanagedMethods.GetMessage(out msg, IntPtr.Zero, 0, 0); - UnmanagedMethods.TranslateMessage(ref msg); - UnmanagedMethods.DispatchMessage(ref msg); + + if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) > 0) + { + UnmanagedMethods.TranslateMessage(ref msg); + UnmanagedMethods.DispatchMessage(ref msg); + } + else + { + Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) + ?.Log(this, "Unmanaged error in {0}. Error Code: {1}", nameof(ProcessMessage), Marshal.GetLastWin32Error()); + + } } public void RunLoop(CancellationToken cancellationToken) @@ -147,7 +155,7 @@ namespace Avalonia.Win32 if (result < 0) { Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) - ?.Log(this, "Unmanaged error in message loop. Error Code: {0}", Marshal.GetLastWin32Error()); + ?.Log(this, "Unmanaged error in {0}. Error Code: {1}" ,nameof(RunLoop), Marshal.GetLastWin32Error()); } } From 604a8b635f25add5f9309ca359f09eab6fe6d87a Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:12:24 +0200 Subject: [PATCH 116/314] add some tests for cast in path expression --- .../CompiledBindingExtensionTests.cs | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 8a82ad048b..c651aabe0a 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -616,23 +616,105 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } + + [Fact] + public void SupportCastToTypeInExpressionWithProperty() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = new TestDataContext + { + StringProperty = "foobar" + }; + + window.DataContext = dataContext; + + Assert.Equal(dataContext.StringProperty, contentControl.Content); + } + } + + [Fact] + public void SupportCastToTypeInExpressionWithProperty1() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = new TestDataContext + { + StringProperty = "foobar" + }; + + window.DataContext = dataContext; + + Assert.Equal(dataContext.StringProperty, contentControl.Content); + } + } + + [Fact] + public void SupportCastToTypeInExpressionWithProperty_DifferentTypeEvaluatesToNull() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = new TestDataContext + { + StringProperty = "foobar" + }; + + window.DataContext = dataContext; + + Assert.Equal(dataContext.StringProperty, contentControl.Content); + + window.DataContext = "foo"; + + Assert.Equal(null, contentControl.Content); + } + } } public interface INonIntegerIndexer { - string this[string key] {get; set;} + string this[string key] { get; set; } } public interface INonIntegerIndexerDerived : INonIntegerIndexer - {} + { } public interface IHasProperty { - string StringProperty {get; set; } + string StringProperty { get; set; } } public interface IHasPropertyDerived : IHasProperty - {} + { } public class TestDataContext : IHasPropertyDerived { From 5500c2ed8c989f410986ee556e6b59d7aa3fa9c7 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:14:06 +0200 Subject: [PATCH 117/314] support parse cast in binding path expression --- .../Parsers/BindingExpressionGrammar.cs | 36 +++++++++++++++++++ .../Markup/Parsers/ExpressionParser.cs | 19 ++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs index 8e5631e198..7df53f430f 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs @@ -46,6 +46,10 @@ namespace Avalonia.Markup.Parsers state = ParseIndexer(ref r, nodes); break; + case State.TypeCast: + state = ParseTypeCast(ref r, nodes); + break; + case State.ElementName: state = ParseElementName(ref r, nodes); mode = SourceMode.Control; @@ -124,6 +128,10 @@ namespace Avalonia.Markup.Parsers { return State.Indexer; } + else if (ParseOpenBrace(ref r)) + { + return State.TypeCast; + } return State.End; } @@ -186,6 +194,27 @@ namespace Avalonia.Markup.Parsers return State.AfterMember; } + private static State ParseTypeCast(ref CharacterReader r, List nodes) + { + var (ns, typeName) = ParseTypeName(ref r); + + nodes.Add(new TypeCastNode { Namespace = ns, TypeName = typeName }); + + if (ParseMemberAccessor(ref r)) + { + var identifier = r.ParseIdentifier(); + + nodes.Add(new PropertyNameNode { PropertyName = identifier.ToString() }); + } + + if (r.End || !r.TakeIf(')')) + { + throw new ExpressionParseException(r.Position, "Expected ')'."); + } + + return State.AfterMember; + } + private static State ParseElementName(ref CharacterReader r, List nodes) { var name = r.ParseIdentifier(); @@ -322,6 +351,7 @@ namespace Avalonia.Markup.Parsers BeforeMember, AttachedProperty, Indexer, + TypeCast, End, } @@ -383,5 +413,11 @@ namespace Avalonia.Markup.Parsers public string TypeName { get; set; } public int Level { get; set; } } + + public class TypeCastNode : INode + { + public string Namespace { get; set; } + public string TypeName { get; set; } + } } } diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionParser.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionParser.cs index 1048148c1f..558130e23f 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionParser.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionParser.cs @@ -59,6 +59,9 @@ namespace Avalonia.Markup.Parsers case BindingExpressionGrammar.NameNode elementName: nextNode = new ElementNameNode(_nameScope, elementName.Name); break; + case BindingExpressionGrammar.TypeCastNode typeCast: + nextNode = ParseTypeCastNode(typeCast); + break; } if (rootNode is null) { @@ -92,6 +95,22 @@ namespace Avalonia.Markup.Parsers return new FindAncestorNode(ancestorType, ancestorLevel); } + private TypeCastNode ParseTypeCastNode(BindingExpressionGrammar.TypeCastNode node) + { + Type castType = null; + if (!(node.Namespace is null) && !(node.TypeName is null)) + { + if (_typeResolver == null) + { + throw new InvalidOperationException("Cannot parse a binding path with a typed Cast without a type resolver. Maybe you can use a LINQ Expression binding path instead?"); + } + + castType = _typeResolver(node.Namespace, node.TypeName); + } + + return new TypeCastNode(castType); + } + private AvaloniaPropertyAccessorNode ParseAttachedProperty(BindingExpressionGrammar.AttachedPropertyNameNode node) { if (_typeResolver == null) From 4563c6cd241b2de78b7c88d9883f05c0f308d023 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:16:20 +0200 Subject: [PATCH 118/314] Compiled path support for cast --- src/Avalonia.Base/Data/Core/TypeCastNode.cs | 34 +++++++++++++ .../Avalonia.Markup.Xaml.csproj | 1 + .../CompiledBindings/CompiledBindingPath.cs | 51 +++++++++++++++++++ .../CompiledBindings/StrongTypeCastNode.cs | 18 +++++++ 4 files changed, 104 insertions(+) create mode 100644 src/Avalonia.Base/Data/Core/TypeCastNode.cs create mode 100644 src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/StrongTypeCastNode.cs diff --git a/src/Avalonia.Base/Data/Core/TypeCastNode.cs b/src/Avalonia.Base/Data/Core/TypeCastNode.cs new file mode 100644 index 0000000000..476fd5527f --- /dev/null +++ b/src/Avalonia.Base/Data/Core/TypeCastNode.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Avalonia.Data.Core +{ + public class TypeCastNode : ExpressionNode + { + public override string Description => $"as {TargetType.FullName}"; + + public Type TargetType { get; } + + public TypeCastNode(Type type) + { + TargetType = type; + } + + protected virtual object Cast(object value) + { + return TargetType.IsInstanceOfType(value) ? value : null; + } + + protected override void StartListeningCore(WeakReference reference) + { + if (reference.TryGetTarget(out object target)) + { + target = Cast(target); + reference = target == null ? NullReference : new WeakReference(target); + } + + base.StartListeningCore(reference); + } + } +} diff --git a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj index 3e15d2f700..217da2d50d 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj +++ b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj @@ -23,6 +23,7 @@ + diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs index d627fe3cd3..f6636664c1 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/CompiledBindingPath.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Avalonia.Controls; using Avalonia.Data.Core; using Avalonia.Data.Core.Plugins; @@ -53,6 +54,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings case IStronglyTypedStreamElement stream: node = new StreamNode(stream.CreatePlugin()); break; + case ITypeCastElement typeCast: + node = new StrongTypeCastNode(typeCast.Type, typeCast.Cast); + break; default: throw new InvalidOperationException($"Unknown binding path element type {element.GetType().FullName}"); } @@ -66,6 +70,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings internal SourceMode SourceMode => _elements.Count > 0 && _elements[0] is IControlSourceBindingPathElement ? SourceMode.Control : SourceMode.Data; internal object RawSource { get; } + + public override string ToString() + => string.Concat(_elements.Select(e => e.ToString())); } public class CompiledBindingPathBuilder @@ -126,6 +133,12 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings return this; } + public CompiledBindingPathBuilder TypeCast() + { + _elements.Add(new TypeCastPathElement()); + return this; + } + public CompiledBindingPathBuilder SetRawSource(object rawSource) { _rawSource = rawSource; @@ -157,6 +170,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings public IPropertyInfo Property { get; } public Func, IPropertyInfo, IPropertyAccessor> AccessorFactory { get; } + + public override string ToString() + => $".{Property.Name}"; } internal interface IStronglyTypedStreamElement : ICompiledBindingPathElement @@ -164,6 +180,13 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings IStreamPlugin CreatePlugin(); } + internal interface ITypeCastElement : ICompiledBindingPathElement + { + Type Type { get; } + + Func Cast { get; } + } + internal class TaskStreamPathElement : IStronglyTypedStreamElement { public static readonly TaskStreamPathElement Instance = new TaskStreamPathElement(); @@ -181,6 +204,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings internal class SelfPathElement : ICompiledBindingPathElement, IControlSourceBindingPathElement { public static readonly SelfPathElement Instance = new SelfPathElement(); + + public override string ToString() + => "$self"; } internal class AncestorPathElement : ICompiledBindingPathElement, IControlSourceBindingPathElement @@ -193,6 +219,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings public Type AncestorType { get; } public int Level { get; } + + public override string ToString() + => $"$parent[{AncestorType?.Name},{Level}]"; } internal class VisualAncestorPathElement : ICompiledBindingPathElement, IControlSourceBindingPathElement @@ -217,6 +246,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings public INameScope NameScope { get; } public string Name { get; } + + public override string ToString() + => $"#{Name}"; } internal class ArrayElementPathElement : ICompiledBindingPathElement @@ -229,5 +261,24 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings public int[] Indices { get; } public Type ElementType { get; } + public override string ToString() + => $"[{string.Join(",", Indices)}]"; + } + + internal class TypeCastPathElement : ITypeCastElement + { + private static object TryCast(object obj) + { + if (obj is T result) + return result; + return null; + } + + public Type Type => typeof(T); + + public Func Cast => TryCast; + + public override string ToString() + => $"({Type.FullName})"; } } diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/StrongTypeCastNode.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/StrongTypeCastNode.cs new file mode 100644 index 0000000000..1252ec7eca --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindings/StrongTypeCastNode.cs @@ -0,0 +1,18 @@ +using System; +using Avalonia.Data.Core; + +namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings +{ + public class StrongTypeCastNode : TypeCastNode + { + private Func _cast; + + public StrongTypeCastNode(Type type, Func cast) : base(type) + { + _cast = cast; + } + + protected override object Cast(object value) + => _cast(value); + } +} From 74bbdc193b97cf597c1104c892fbb30b7103b24e Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:21:58 +0200 Subject: [PATCH 119/314] actually compile cast in compiled binding --- .../XamlIlBindingPathHelper.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs index 03ec32b9cf..414ecc760a 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs @@ -242,6 +242,16 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions case RawSourceBindingExpressionNode rawSource: nodes.Add(new RawSourcePathElementNode(rawSource.RawSource)); break; + case BindingExpressionGrammar.TypeCastNode typeCastNode: + var castType = GetType(typeCastNode.Namespace, typeCastNode.TypeName); + + if (castType is null) + { + throw new XamlX.XamlParseException($"Unable to resolve cast to type {typeCastNode.Namespace}:{typeCastNode.TypeName} based on XAML tree.", lineInfo); + } + + nodes.Add(new TypeCastPathElementNode(castType)); + break; } } @@ -625,6 +635,21 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions } } + class TypeCastPathElementNode : IXamlIlBindingPathElementNode + { + public TypeCastPathElementNode(IXamlType ancestorType) + { + Type = ancestorType; + } + + public IXamlType Type { get; } + + public void Emit(XamlIlEmitContext context, IXamlILEmitter codeGen) + { + codeGen.EmitCall(context.GetAvaloniaTypes().CompiledBindingPathBuilder.FindMethod(m => m.Name == "TypeCast").MakeGenericMethod(new[] { Type })); + } + } + class XamlIlBindingPathNode : XamlAstNode, IXamlIlBindingPathNode, IXamlAstEmitableNode { private readonly List _transformElements; From 0036bf22c4b4e5aac1874c12989a7270b5f3c018 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:25:06 +0200 Subject: [PATCH 120/314] add tests for reflection binding for casting in path --- .../MarkupExtensions/BindingExtensionTests.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs index 9ea2cd643a..bbb68e7cdf 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs @@ -84,6 +84,54 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void SupportCastToTypeInExpression() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = new TestDataContext + { + StringProperty = "foobar" + }; + + window.DataContext = dataContext; + + Assert.Equal(dataContext.StringProperty, contentControl.Content); + } + } + + [Fact] + public void SupportCastToTypeInExpression_DifferentTypeEvaluatesToNull() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = "foo"; + + window.DataContext = dataContext; + + Assert.Equal(null, contentControl.Content); + } + } private class FooBar { public object Foo { get; } = null; From df95ba630dc92d6b32cb0ea7fb1992f2314f0318 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:28:01 +0200 Subject: [PATCH 121/314] add test for $parent as it look like not working for compiled binding --- .../CompiledBindingExtensionTests.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index c651aabe0a..a244f33384 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -601,6 +601,26 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void SupportParentInPath() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + Assert.Equal("foo", contentControl.Content); + } + } + [Fact] public void ThrowsOnInvalidCompileBindingsDirective() { From ffc82bf7e441d058ca76f2a49a81c9a2a8ae11f6 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:30:55 +0200 Subject: [PATCH 122/314] try make $parent work with compiled binding --- .../XamlIlBindingPathHelper.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs index 414ecc760a..59ddfe2ef0 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs @@ -198,20 +198,24 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions case BindingExpressionGrammar.AncestorNode ancestor: if (ancestor.Namespace is null && ancestor.TypeName is null) { - var styledElementType = context.GetAvaloniaTypes().StyledElement; - var ancestorType = context - .ParentNodes() - .OfType() - .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) - .ElementAtOrDefault(ancestor.Level) - ?.Type.GetClrType(); - - if (ancestorType is null) + if (ancestor.Namespace is null && ancestor.TypeName is null) { - throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); - } + var styledElementType = context.GetAvaloniaTypes().StyledElement; + var ancestorType = context + .ParentNodes() + .OfType() + .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) + .Skip(1) + .ElementAtOrDefault(ancestor.Level) + ?.Type.GetClrType(); + + if (ancestorType is null) + { + throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); + } - nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); + nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); + } } else { From 8535ee690e81809eb69c737affebfb6a0e22b060 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:32:11 +0200 Subject: [PATCH 123/314] second attempt make $parent work in compiled binding --- .../CompilerExtensions/XamlIlBindingPathHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs index 59ddfe2ef0..3bea580da0 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs @@ -436,7 +436,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { codeGen.Ldtype(Type) .Ldc_I4(_level) - .EmitCall(context.GetAvaloniaTypes().CompiledBindingPathBuilder.FindMethod(m => m.Name == "FindAncestor")); + .EmitCall(context.GetAvaloniaTypes().CompiledBindingPathBuilder.FindMethod(m => m.Name == "Ancestor")); } } From 9633300e5d10a188b3edeb6945a572a1e65d50da Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 18:33:57 +0200 Subject: [PATCH 124/314] add few more tests for cast in binding path --- .../CompiledBindingExtensionTests.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index a244f33384..dd89274517 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -637,6 +637,52 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void SupportCastToTypeInExpression() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = new TestDataContext(); + + window.DataContext = dataContext; + + Assert.Equal(dataContext, contentControl.Content); + } + } + + [Fact] + public void SupportCastToTypeInExpression_DifferentTypeEvaluatesToNull() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var dataContext = "foo"; + + window.DataContext = dataContext; + + Assert.Equal(null, contentControl.Content); + } + } + [Fact] public void SupportCastToTypeInExpressionWithProperty() { From fa754bcaa2d62d253403f27f17b398292ee3962a Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 19:01:38 +0200 Subject: [PATCH 125/314] add test for converter with parameter in compiled binding --- .../CompiledBindingExtensionTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index dd89274517..2f42f57434 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.Reactive.Subjects; using System.Text; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Presenters; +using Avalonia.Data.Converters; using Avalonia.Data.Core; using Avalonia.Markup.Data; using Avalonia.UnitTests; @@ -621,6 +623,28 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void SupportConverterWithParameter() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var textBlock = window.FindControl("textBlock"); + + window.DataContext = new TestDataContext() { StringProperty = "Foo" }; + + Assert.Equal("Foo+Bar", textBlock.Text); + } + } + [Fact] public void ThrowsOnInvalidCompileBindingsDirective() { @@ -782,6 +806,18 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions public interface IHasPropertyDerived : IHasProperty { } + public class AppendConverter : IValueConverter + { + public static IValueConverter Instance { get; } = new AppendConverter(); + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + => string.Format("{0}+{1}", value, parameter); + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + => throw new NotImplementedException(); + + } + public class TestDataContext : IHasPropertyDerived { public string StringProperty { get; set; } From 86492f5a75f8ade00ca03b24849554585c56e77b Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 19:02:01 +0200 Subject: [PATCH 126/314] support converter parameter in compiled binding should fix #5030 --- .../MarkupExtensions/CompiledBindingExtension.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs index aab733cb43..da39920eb3 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs @@ -26,6 +26,8 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions { Path = Path, Converter = Converter, + ConverterParameter = ConverterParameter, + TargetNullValue = TargetNullValue, FallbackValue = FallbackValue, Mode = Mode, Priority = Priority, From 979a659b49794400e513bdd3886640ff2f53d98d Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 21:00:16 +0200 Subject: [PATCH 127/314] remove duplicate condition --- .../XamlIlBindingPathHelper.cs | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs index 3bea580da0..1974dfe3bc 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs @@ -198,24 +198,21 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions case BindingExpressionGrammar.AncestorNode ancestor: if (ancestor.Namespace is null && ancestor.TypeName is null) { - if (ancestor.Namespace is null && ancestor.TypeName is null) + var styledElementType = context.GetAvaloniaTypes().StyledElement; + var ancestorType = context + .ParentNodes() + .OfType() + .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) + .Skip(1) + .ElementAtOrDefault(ancestor.Level) + ?.Type.GetClrType(); + + if (ancestorType is null) { - var styledElementType = context.GetAvaloniaTypes().StyledElement; - var ancestorType = context - .ParentNodes() - .OfType() - .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) - .Skip(1) - .ElementAtOrDefault(ancestor.Level) - ?.Type.GetClrType(); - - if (ancestorType is null) - { - throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); - } - - nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); + throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); } + + nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); } else { @@ -622,10 +619,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions private readonly IXamlAstValueNode _rawSource; public RawSourcePathElementNode(IXamlAstValueNode rawSource) - :base(rawSource) + : base(rawSource) { _rawSource = rawSource; - + } public IXamlType Type => _rawSource.Type.GetClrType(); From cfb81aedcaae7d501017a4224f18ffc8348ae4de Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Sat, 14 Nov 2020 00:44:44 +0100 Subject: [PATCH 128/314] fixes typo. --- src/Avalonia.Base/Logging/LogArea.cs | 2 +- src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs | 2 +- src/Windows/Avalonia.Win32/Win32Platform.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/Logging/LogArea.cs b/src/Avalonia.Base/Logging/LogArea.cs index ce330247f3..2ad220dddd 100644 --- a/src/Avalonia.Base/Logging/LogArea.cs +++ b/src/Avalonia.Base/Logging/LogArea.cs @@ -36,7 +36,7 @@ namespace Avalonia.Logging public const string Control = "Control"; /// - /// The log evevnt come from Win32Platform + /// The log event comes from Win32Platform. /// public const string Win32Platform = nameof(Win32Platform); } diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index 85938829f6..b164bcc611 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -931,7 +931,7 @@ namespace Avalonia.Win32.Interop [DllImport("user32.dll", EntryPoint = "MapVirtualKeyW")] public static extern uint MapVirtualKey(uint uCode, uint uMapType); - [DllImport("user32.dll", EntryPoint = "GetMessageW",SetLastError = true)] + [DllImport("user32.dll", EntryPoint = "GetMessageW", SetLastError = true)] public static extern int GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax); [DllImport("user32.dll")] diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 1ed4d8dc9c..345c825a5d 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -155,7 +155,7 @@ namespace Avalonia.Win32 if (result < 0) { Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) - ?.Log(this, "Unmanaged error in {0}. Error Code: {1}" ,nameof(RunLoop), Marshal.GetLastWin32Error()); + ?.Log(this, "Unmanaged error in {0}. Error Code: {1}", nameof(RunLoop), Marshal.GetLastWin32Error()); } } From ebe1af51a93252c9e313cd56964ff001315883c7 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 14 Nov 2020 03:18:16 +0200 Subject: [PATCH 129/314] modify tests to c# style casting in binding path --- .../MarkupExtensions/BindingExtensionTests.cs | 4 ++-- .../MarkupExtensions/CompiledBindingExtensionTests.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs index bbb68e7cdf..20ed22e84f 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs @@ -94,7 +94,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions;assembly=Avalonia.Markup.Xaml.UnitTests' > - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); @@ -120,7 +120,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions;assembly=Avalonia.Markup.Xaml.UnitTests' > - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 2f42f57434..22edcc5cb4 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -671,7 +671,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='using:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions' x:DataType='local:TestDataContext'> - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); @@ -694,7 +694,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='using:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions' x:DataType='local:TestDataContext'> - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); @@ -717,7 +717,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='using:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions' x:DataType='local:TestDataContext'> - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); @@ -743,7 +743,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='using:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions' x:DataType='local:TestDataContext'> - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); @@ -769,7 +769,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:local='using:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions' x:DataType='local:TestDataContext'> - + "; var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); var contentControl = window.FindControl("contentControl"); From 2c4e23be84530d4265b522411cf72d8c334c79e5 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 14 Nov 2020 03:28:12 +0200 Subject: [PATCH 130/314] add support for c# style casting in binding path --- .../Parsers/BindingExpressionGrammar.cs | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs index 7df53f430f..15db7a96e4 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs @@ -88,6 +88,11 @@ namespace Avalonia.Markup.Parsers } else if (ParseOpenBrace(ref r)) { + if (PeekOpenBrace(ref r)) + { + return State.TypeCast; + } + return State.AttachedProperty; } else if (PeekOpenBracket(ref r)) @@ -140,6 +145,11 @@ namespace Avalonia.Markup.Parsers { if (ParseOpenBrace(ref r)) { + if (PeekOpenBrace(ref r)) + { + return State.TypeCast; + } + return State.AttachedProperty; } else @@ -196,23 +206,30 @@ namespace Avalonia.Markup.Parsers private static State ParseTypeCast(ref CharacterReader r, List nodes) { + bool parseMemberBeforeAddCast = ParseOpenBrace(ref r); + var (ns, typeName) = ParseTypeName(ref r); - nodes.Add(new TypeCastNode { Namespace = ns, TypeName = typeName }); + var result = State.AfterMember; - if (ParseMemberAccessor(ref r)) + if (parseMemberBeforeAddCast) { - var identifier = r.ParseIdentifier(); + if (!ParseCloseBrace(ref r)) + { + throw new ExpressionParseException(r.Position, "Expected ')'."); + } - nodes.Add(new PropertyNameNode { PropertyName = identifier.ToString() }); + result = ParseBeforeMember(ref r, nodes); } + nodes.Add(new TypeCastNode { Namespace = ns, TypeName = typeName }); + if (r.End || !r.TakeIf(')')) { throw new ExpressionParseException(r.Position, "Expected ')'."); } - return State.AfterMember; + return result; } private static State ParseElementName(ref CharacterReader r, List nodes) @@ -317,11 +334,21 @@ namespace Avalonia.Markup.Parsers return !r.End && r.TakeIf('('); } + private static bool ParseCloseBrace(ref CharacterReader r) + { + return !r.End && r.TakeIf(')'); + } + private static bool PeekOpenBracket(ref CharacterReader r) { return !r.End && r.Peek == '['; } + private static bool PeekOpenBrace(ref CharacterReader r) + { + return !r.End && r.Peek == '('; + } + private static bool ParseStreamOperator(ref CharacterReader r) { return !r.End && r.TakeIf('^'); @@ -373,9 +400,9 @@ namespace Avalonia.Markup.Parsers } } - public interface INode {} + public interface INode { } - public interface ITransformNode {} + public interface ITransformNode { } public class EmptyExpressionNode : INode { } @@ -396,11 +423,11 @@ namespace Avalonia.Markup.Parsers public IList Arguments { get; set; } } - public class NotNode : INode, ITransformNode {} + public class NotNode : INode, ITransformNode { } - public class StreamNode : INode {} + public class StreamNode : INode { } - public class SelfNode : INode {} + public class SelfNode : INode { } public class NameNode : INode { From 3b18572dd60cc0222ef7717d9455557ce01b1676 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sat, 14 Nov 2020 10:49:34 +0800 Subject: [PATCH 131/314] add property listening for path segments --- src/Avalonia.Visuals/Media/PathFigure.cs | 32 +++++++++++++++++++++- src/Avalonia.Visuals/Media/PathGeometry.cs | 20 ++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index d0eb67ba39..ff63a6286c 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -1,3 +1,6 @@ +using System; +using System.ComponentModel; +using Avalonia.Collections; using Avalonia.Metadata; namespace Avalonia.Media @@ -25,14 +28,41 @@ namespace Avalonia.Media public static readonly StyledProperty StartPointProperty = AvaloniaProperty.Register(nameof(StartPoint)); + internal event EventHandler SegmentsInvalidated; + + private IDisposable? _segmentsObserver; + + private IDisposable? _segmentsPropertiesObserver; + /// /// Initializes a new instance of the class. /// public PathFigure() { + SegmentsProperty.Changed.AddClassHandler((s, e) => + s.OnSegmentsChanged(e.NewValue as PathSegments)); + Segments = new PathSegments(); } + private void OnSegmentsChanged(PathSegments? arg2NewValue) + { + _segmentsObserver?.Dispose(); + _segmentsPropertiesObserver?.Dispose(); + + _segmentsObserver = _segments?.ForEachItem( + _ => InvalidateSegments(), + _ => InvalidateSegments(), + InvalidateSegments); + + _segmentsPropertiesObserver = _segments?.TrackItemPropertyChanged(_ => InvalidateSegments()); + } + + private void InvalidateSegments() + { + SegmentsInvalidated?.Invoke(this, EventArgs.Empty); + } + /// /// Gets or sets a value indicating whether this instance is closed. /// @@ -99,4 +129,4 @@ namespace Avalonia.Media public override string ToString() => $"M {StartPoint} {string.Join(" ", _segments)}{(IsClosed ? "Z" : "")}"; } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/PathGeometry.cs b/src/Avalonia.Visuals/Media/PathGeometry.cs index fbc29aedc8..819669d86e 100644 --- a/src/Avalonia.Visuals/Media/PathGeometry.cs +++ b/src/Avalonia.Visuals/Media/PathGeometry.cs @@ -104,12 +104,26 @@ namespace Avalonia.Media _figuresPropertiesObserver?.Dispose(); _figuresObserver = figures?.ForEachItem( - _ => InvalidateGeometry(), - _ => InvalidateGeometry(), - () => InvalidateGeometry()); + s => + { + s.SegmentsInvalidated += InvalidateGeometryFromSegments; + InvalidateGeometry(); + }, + s => + { + s.SegmentsInvalidated -= InvalidateGeometryFromSegments; + InvalidateGeometry(); + }, + InvalidateGeometry); + _figuresPropertiesObserver = figures?.TrackItemPropertyChanged(_ => InvalidateGeometry()); + } + public void InvalidateGeometryFromSegments(object _, EventArgs __) + { + InvalidateGeometry(); + } public override string ToString() => $"{(FillRule != FillRule.EvenOdd ? "F1 " : "")}{(string.Join(" ", Figures))}"; From d2339a041df94ca65878140435a351a3932f7ee4 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sat, 14 Nov 2020 11:02:30 +0800 Subject: [PATCH 132/314] try making a unit test --- .../Avalonia.RenderTests/Shapes/PathTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/Avalonia.RenderTests/Shapes/PathTests.cs b/tests/Avalonia.RenderTests/Shapes/PathTests.cs index bac16cca88..24e420d972 100644 --- a/tests/Avalonia.RenderTests/Shapes/PathTests.cs +++ b/tests/Avalonia.RenderTests/Shapes/PathTests.cs @@ -353,7 +353,47 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes await RenderToFile(target); CompareImages(); } + + [Fact] + public async Task PathSegment_Triggers_Invalidation_On_Property_Change() + { + var targetSegment = new ArcSegment() + { + Size = new Size(10,10), + Point = new Point(5,5) + }; + + var targetPath = new Path + { + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Center, + Fill = Brushes.Red, + Data = new PathGeometry + { + Figures = new PathFigures + { + new PathFigure { IsClosed = false, Segments = new PathSegments { targetSegment } } + } + } + }; + + var root = new Border + { + Width = 100, + Height = 100, + Background = Brushes.White, + Child =targetPath + }; + + Assert.Equal(10, targetPath.Bounds.Height); + Assert.Equal(10, targetPath.Bounds.Width); + + targetSegment.Size = new Size(20, 20); + Assert.Equal(20, targetPath.Bounds.Height); + Assert.Equal(20, targetPath.Bounds.Width); + } + [Fact] public async Task Path_With_Rotated_Geometry() { From 7ff860c8ef54c5ce38b2e6c672297e651c1142c2 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Sat, 14 Nov 2020 14:40:21 +0100 Subject: [PATCH 133/314] fix ProcessMessage issue --- src/Windows/Avalonia.Win32/Win32Platform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 345c825a5d..e854ceae0b 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -130,7 +130,7 @@ namespace Avalonia.Win32 public void ProcessMessage() { - if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) > 0) + if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) > -1) { UnmanagedMethods.TranslateMessage(ref msg); UnmanagedMethods.DispatchMessage(ref msg); From bf2dfff8f6ba98f904a384c1441cb4a6886b9869 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 14 Nov 2020 17:42:56 +0200 Subject: [PATCH 134/314] add test for casting after indexer --- .../CompiledBindingExtensionTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 22edcc5cb4..50dfa2c7b0 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -759,6 +759,36 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void SupportCastToTypeInExpressionWithPropertyIndexer() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + var data = new TestData() + { + StringProperty = "Foo" + }; + var dataContext = new TestDataContext + { + ObjectsArrayProperty = new object[] { data } + }; + + window.DataContext = dataContext; + + Assert.Equal(data.StringProperty, contentControl.Content); + } + } + [Fact] public void SupportCastToTypeInExpressionWithProperty_DifferentTypeEvaluatesToNull() { @@ -818,6 +848,11 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } + public class TestData + { + public string StringProperty { get; set; } + } + public class TestDataContext : IHasPropertyDerived { public string StringProperty { get; set; } @@ -830,6 +865,8 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions public string[] ArrayProperty { get; set; } + public object[] ObjectsArrayProperty { get; set; } + public List ListProperty { get; set; } = new List(); public NonIntegerIndexer NonIntegerIndexerProperty { get; set; } = new NonIntegerIndexer(); From c16817aac524fcca112cd422daadc6744064050a Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 14 Nov 2020 17:43:49 +0200 Subject: [PATCH 135/314] add support for casting after indexer in binding path --- .../Markup/Parsers/BindingExpressionGrammar.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs index 15db7a96e4..637802169d 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs @@ -170,6 +170,12 @@ namespace Avalonia.Markup.Parsers { var (ns, owner) = ParseTypeName(ref r); + if(!r.End && r.TakeIf(')')) + { + nodes.Add(new TypeCastNode() { Namespace = ns, TypeName = owner }); + return State.AfterMember; + } + if (r.End || !r.TakeIf('.')) { throw new ExpressionParseException(r.Position, "Invalid attached property name."); @@ -220,6 +226,11 @@ namespace Avalonia.Markup.Parsers } result = ParseBeforeMember(ref r, nodes); + + if(r.Peek == '[') + { + result = ParseIndexer(ref r, nodes); + } } nodes.Add(new TypeCastNode { Namespace = ns, TypeName = typeName }); From ee470af59ae6a1e61095db961c807cdaa59a4a69 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 14 Nov 2020 18:51:42 +0300 Subject: [PATCH 136/314] FontFamily and TimeSpan intrinsics --- .../AvaloniaXamlIlFontFamilyAstNode.cs | 43 ++++++++++++++++ .../AvaloniaXamlIlLanguage.cs | 51 ++++++++++++++----- .../AvaloniaXamlIlWellKnownTypes.cs | 10 ++++ 3 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs new file mode 100644 index 0000000000..793fbf720f --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using XamlX.Ast; +using XamlX.Emit; +using XamlX.IL; +using XamlX.TypeSystem; + +namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes +{ + class AvaloniaXamlIlFontFamilyAstNode: XamlAstNode, IXamlAstValueNode, IXamlAstILEmitableNode + { + private readonly AvaloniaXamlIlWellKnownTypes _types; + private readonly string _text; + + public IXamlAstTypeReference Type { get; } + + public AvaloniaXamlIlFontFamilyAstNode(AvaloniaXamlIlWellKnownTypes types, + string text, + IXamlLineInfo lineInfo) : base(lineInfo) + { + _types = types; + _text = text; + Type = new XamlAstClrTypeReference(lineInfo, types.FontFamily, false); + } + + public XamlILNodeEmitResult Emit(XamlEmitContext context, IXamlILEmitter codeGen) + { + codeGen + .Ldloc(context.ContextLocal) + .Castclass(context.Configuration.TypeMappings.UriContextProvider) + .EmitCall(context.Configuration.TypeMappings.UriContextProvider.FindMethod( + "get_BaseUri", _types.Uri, false)) + .Ldstr(_text) + .Newobj(_types.FontFamilyConstructorUriName); + return XamlILNodeEmitResult.Type(0, _types.FontFamily); + } + + + + + } +} diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 99ec3744bf..15413689f8 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -1,6 +1,8 @@ +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes; using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; using XamlX; using XamlX.Ast; @@ -166,17 +168,41 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions public static bool CustomValueConverter(AstTransformationContext context, IXamlAstValueNode node, IXamlType type, out IXamlAstValueNode result) { - if (type.FullName == "System.TimeSpan" - && node is XamlAstTextNode tn - && !tn.Text.Contains(":")) + if (!(node is XamlAstTextNode textNode)) { - var seconds = double.Parse(tn.Text, CultureInfo.InvariantCulture); - result = new XamlStaticOrTargetedReturnMethodCallNode(tn, - type.FindMethod("FromSeconds", type, false, context.Configuration.WellKnownTypes.Double), - new[] - { - new XamlConstantNode(tn, context.Configuration.WellKnownTypes.Double, seconds) - }); + result = null; + return false; + } + + var text = textNode.Text; + + var types = context.GetAvaloniaTypes(); + + if (type.FullName == "System.TimeSpan") + { + var tsText = text.Trim(); + + if (!TimeSpan.TryParse(tsText, CultureInfo.InvariantCulture, out var timeSpan)) + { + // // shorthand seconds format (ie. "0.25") + if (!tsText.Contains(":") && double.TryParse(tsText, + NumberStyles.Float | NumberStyles.AllowThousands, + CultureInfo.InvariantCulture, out var seconds)) + timeSpan = TimeSpan.FromSeconds(seconds); + else + throw new XamlX.XamlLoadException($"Unable to parse {text} as a time span", node); + } + + + result = new XamlStaticOrTargetedReturnMethodCallNode(node, + type.FindMethod("FromTicks", type, false, types.Long), + new[] { new XamlConstantNode(node, types.Long, timeSpan.Ticks) }); + return true; + } + + if (type.Equals(types.FontFamily)) + { + result = new AvaloniaXamlIlFontFamilyAstNode(types, text, node); return true; } @@ -185,9 +211,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions var scope = context.ParentNodes().OfType().FirstOrDefault(); if (scope == null) throw new XamlX.XamlLoadException("Unable to find the parent scope for AvaloniaProperty lookup", node); - if (!(node is XamlAstTextNode text)) - throw new XamlX.XamlLoadException("Property should be a text node", node); - result = XamlIlAvaloniaPropertyHelper.CreateNode(context, text.Text, scope.TargetType, text); + + result = XamlIlAvaloniaPropertyHelper.CreateNode(context, text, scope.TargetType, node ); return true; } diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 3dec96dc43..58f4ddfe31 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using XamlX.Emit; using XamlX.IL; using XamlX.Transform; @@ -47,6 +48,11 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType ReflectionBindingExtension { get; } public IXamlType RelativeSource { get; } + public IXamlType Long { get; } + public IXamlType Uri { get; } + public IXamlType FontFamily { get; } + public IXamlConstructor FontFamilyConstructorUriName { get; } + public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -104,6 +110,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers ItemsRepeater = cfg.TypeSystem.GetType("Avalonia.Controls.ItemsRepeater"); ReflectionBindingExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension"); RelativeSource = cfg.TypeSystem.GetType("Avalonia.Data.RelativeSource"); + Long = cfg.TypeSystem.GetType("System.Int64"); + Uri = cfg.TypeSystem.GetType("System.Uri"); + FontFamily = cfg.TypeSystem.GetType("Avalonia.Media.FontFamily"); + FontFamilyConstructorUriName = FontFamily.FindConstructor(new List { Uri, XamlIlTypes.String }); } } From c7da4bc8c351343f40feef384d2263999358f306 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 14 Nov 2020 19:00:36 +0300 Subject: [PATCH 137/314] Format --- .../AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs index 793fbf720f..1f50e661d8 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlFontFamilyAstNode.cs @@ -35,9 +35,5 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes .Newobj(_types.FontFamilyConstructorUriName); return XamlILNodeEmitResult.Type(0, _types.FontFamily); } - - - - } } From d1cf6fc9bea043f053aae23e72932ea753ca1b64 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 14 Nov 2020 18:43:23 +0200 Subject: [PATCH 138/314] fix failing test --- .../Markup/Parsers/BindingExpressionGrammar.cs | 5 +++++ .../ExpressionObserverBuilderTests_AttachedProperty.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs index 637802169d..7c362e24cc 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs @@ -183,6 +183,11 @@ namespace Avalonia.Markup.Parsers var name = r.ParseIdentifier(); + if (name.Length == 0) + { + throw new ExpressionParseException(r.Position, "Attached Property name expected after '.'."); + } + if (r.End || !r.TakeIf(')')) { throw new ExpressionParseException(r.Position, "Expected ')'."); diff --git a/tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs b/tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs index 45cf28773f..7c48a975ef 100644 --- a/tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs +++ b/tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs @@ -129,7 +129,7 @@ namespace Avalonia.Markup.UnitTests.Parsers { var data = new Class1(); - Assert.Throws(() => ExpressionObserverBuilder.Build(data, "(Owner)", typeResolver: _typeResolver)); + Assert.Throws(() => ExpressionObserverBuilder.Build(data, "(Owner.)", typeResolver: _typeResolver)); } [Fact] From 0a880921a8dd8044af607556dcf4cacb6dc93241 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 13:01:18 +0300 Subject: [PATCH 139/314] Added render-thread-only mode for DeferredRenderer --- .../Rendering/DeferredRenderer.cs | 73 +++++++++++++++---- .../Rendering/SceneGraph/Scene.cs | 7 ++ src/Avalonia.X11/X11Window.cs | 10 ++- 3 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index 15e14935ca..7a1a2cb4a3 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -99,6 +99,11 @@ namespace Avalonia.Rendering /// public string DebugFramesPath { get; set; } + /// + /// Forces the renderer to only draw frames on the render thread. Makes Paint to wait until frame is rendered + /// + public bool RenderOnlyOnRenderThread { get; set; } = true; + /// public event EventHandler SceneInvalidated; @@ -180,11 +185,38 @@ namespace Avalonia.Rendering /// public void Paint(Rect rect) { - var t = (IRenderLoopTask)this; - if(t.NeedsUpdate) - UpdateScene(); - if(_scene?.Item != null) - Render(true); + if (RenderOnlyOnRenderThread) + { + while (true) + { + Scene scene; + bool? updated; + lock (_sceneLock) + { + updated = UpdateScene(); + scene = _scene?.Item; + } + + // Renderer is in invalid state, skip drawing + if(updated == null) + return; + + // Wait for the scene to be rendered or disposed + scene?.Rendered.Wait(); + + // That was an up-to-date scene, we can return immediately + if (updated == true) + return; + } + } + else + { + var t = (IRenderLoopTask)this; + if (t.NeedsUpdate) + UpdateScene(); + if (_scene?.Item != null) + Render(true); + } } /// @@ -270,13 +302,20 @@ namespace Avalonia.Rendering { if (scene?.Item != null) { - var overlay = DrawDirtyRects || DrawFps; - if (DrawDirtyRects) - _dirtyRectsDisplay.Tick(); - if (overlay) - RenderOverlay(scene.Item, ref context); - if (updated || forceComposite || overlay) - RenderComposite(scene.Item, ref context); + try + { + var overlay = DrawDirtyRects || DrawFps; + if (DrawDirtyRects) + _dirtyRectsDisplay.Tick(); + if (overlay) + RenderOverlay(scene.Item, ref context); + if (updated || forceComposite || overlay) + RenderComposite(scene.Item, ref context); + } + finally + { + scene.Item.MarkAsRendered(); + } } } } @@ -559,15 +598,15 @@ namespace Avalonia.Rendering UpdateScene(); } - private void UpdateScene() + private bool? UpdateScene() { Dispatcher.UIThread.VerifyAccess(); lock (_sceneLock) { if (_disposed) - return; + return null; if (_scene?.Item.Generation > _lastSceneId) - return; + return false; } if (_root.IsVisible) { @@ -619,6 +658,8 @@ namespace Avalonia.Rendering SceneInvalidated(this, new SceneInvalidatedEventArgs((IRenderRoot)_root, rect)); } + + return true; } else { @@ -628,6 +669,8 @@ namespace Avalonia.Rendering _scene = null; oldScene?.Dispose(); } + + return null; } } diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs index 4f5c97cdff..6a4c532d4a 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Avalonia.Collections.Pooled; using Avalonia.VisualTree; @@ -13,6 +14,7 @@ namespace Avalonia.Rendering.SceneGraph public class Scene : IDisposable { private readonly Dictionary _index; + private readonly TaskCompletionSource _rendered = new TaskCompletionSource(); /// /// Initializes a new instance of the class. @@ -41,6 +43,8 @@ namespace Avalonia.Rendering.SceneGraph root.LayerRoot = root.Visual; } + public Task Rendered => _rendered.Task; + /// /// Gets a value identifying the scene's generation. This is incremented each time the scene is cloned. /// @@ -97,6 +101,7 @@ namespace Avalonia.Rendering.SceneGraph public void Dispose() { + _rendered.TrySetResult(false); foreach (var node in _index.Values) { node.Dispose(); @@ -340,5 +345,7 @@ namespace Avalonia.Rendering.SceneGraph } } } + + public void MarkAsRendered() => _rendered.TrySetResult(true); } } diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 2cd3b973d8..41c061613d 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -189,6 +189,11 @@ namespace Avalonia.X11 if (platform.Options.UseDBusMenu) NativeMenuExporter = DBusMenuExporter.TryCreate(_handle); NativeControlHost = new X11NativeControlHost(_platform, this); + DispatcherTimer.Run(() => + { + Paint?.Invoke(default); + return _handle != IntPtr.Zero; + }, TimeSpan.FromMilliseconds(100)); } class SurfaceInfo : EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo @@ -338,7 +343,10 @@ namespace Avalonia.X11 return customRendererFactory.Create(root, loop); return _platform.Options.UseDeferredRendering ? - new DeferredRenderer(root, loop) : + new DeferredRenderer(root, loop) + { + RenderOnlyOnRenderThread = true + } : (IRenderer)new X11ImmediateRendererProxy(root, loop); } From 4efcd7a32654e266fdfc4cd03f4731c81aae035f Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 13:56:39 +0300 Subject: [PATCH 140/314] Use ICompositor5.RequestAsync completion handler as the render timer --- .../Interop/UnmanagedMethods.cs | 3 + src/Windows/Avalonia.Win32/Win32GlManager.cs | 9 +- .../Composition/WinUICompositorConnection.cs | 87 ++++++++++++++----- src/Windows/Avalonia.Win32/WinRT/winrt.idl | 25 ++++++ src/Windows/Avalonia.Win32/WindowImpl.cs | 11 ++- 5 files changed, 104 insertions(+), 31 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index af1692302a..d9f9e7a84e 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -1385,6 +1385,9 @@ namespace Avalonia.Win32.Interop [DllImport("dwmapi.dll")] public static extern int DwmIsCompositionEnabled(out bool enabled); + [DllImport("dwmapi.dll")] + public static extern void DwmFlush(); + [DllImport("dwmapi.dll")] public static extern bool DwmDefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr plResult); diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs index e79d9bbde7..b51f80e397 100644 --- a/src/Windows/Avalonia.Win32/Win32GlManager.cs +++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs @@ -25,13 +25,8 @@ namespace Avalonia.Win32 var egl = EglPlatformOpenGlInterface.TryCreate(() => new AngleWin32EglDisplay()); if (egl is { } && - opts?.UseWindowsUIComposition == true) - { - var compositionConnector = WinUICompositorConnection.TryCreate(egl); - - if (compositionConnector != null) - AvaloniaLocator.CurrentMutable.BindToSelf(compositionConnector); - } + opts?.UseWindowsUIComposition == true) + WinUICompositorConnection.TryCreateAndRegister(egl); return egl; } diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs index 393019b547..7e1f97ab84 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Numerics; using System.Runtime.InteropServices; using System.Threading; @@ -13,12 +14,13 @@ using Avalonia.Win32.Interop; namespace Avalonia.Win32.WinRT.Composition { - class WinUICompositorConnection + class WinUICompositorConnection : IRenderTimer { private readonly EglContext _syncContext; private IntPtr _queue; private ICompositor _compositor; private ICompositor2 _compositor2; + private ICompositor5 _compositor5; private ICompositorInterop _compositorInterop; private AngleWin32EglDisplay _angle; private ICompositionGraphicsDevice _device; @@ -35,22 +37,25 @@ namespace Avalonia.Win32.WinRT.Composition _angle = (AngleWin32EglDisplay)_gl.Display; _compositor = NativeWinRTMethods.CreateInstance("Windows.UI.Composition.Compositor"); _compositor2 = _compositor.QueryInterface(); + _compositor5 = _compositor.QueryInterface(); _compositorInterop = _compositor.QueryInterface(); _compositorDesktopInterop = _compositor.QueryInterface(); using var device = MicroComRuntime.CreateProxyFor(_angle.GetDirect3DDevice(), true); _device = _compositorInterop.CreateGraphicsDevice(device); _blurBrush = CreateBlurBrush(); + } public EglPlatformOpenGlInterface Egl => _gl; - static WinUICompositorConnection TryCreateCore(EglPlatformOpenGlInterface angle) + static bool TryCreateAndRegisterCore(EglPlatformOpenGlInterface angle) { - var tcs = new TaskCompletionSource(); + var tcs = new TaskCompletionSource(); var pumpLock = new object(); var th = new Thread(() => { + WinUICompositorConnection connect; try { NativeWinRTMethods.CreateDispatcherQueueController(new NativeWinRTMethods.DispatcherQueueOptions @@ -59,22 +64,18 @@ namespace Avalonia.Win32.WinRT.Composition dwSize = Marshal.SizeOf(), threadType = NativeWinRTMethods.DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT }); - tcs.SetResult(new WinUICompositorConnection(angle, pumpLock)); - while (true) - { - while (true) - { - if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) == 0) - return; - lock (pumpLock) - UnmanagedMethods.DispatchMessage(ref msg); - } - } + connect = new WinUICompositorConnection(angle, pumpLock); + AvaloniaLocator.CurrentMutable.BindToSelf(connect); + AvaloniaLocator.CurrentMutable.Bind().ToConstant(connect); + tcs.SetResult(true); + } catch (Exception e) { tcs.SetException(e); + return; } + connect.RunLoop(); }) { IsBackground = true @@ -83,8 +84,54 @@ namespace Avalonia.Win32.WinRT.Composition th.Start(); return tcs.Task.Result; } + + class RunLoopHandler : IAsyncActionCompletedHandler, IMicroComShadowContainer + { + private readonly WinUICompositorConnection _parent; + private Stopwatch _st = Stopwatch.StartNew(); + + public RunLoopHandler(WinUICompositorConnection parent) + { + _parent = parent; + } + public void Dispose() + { + + } + + public void Invoke(IAsyncAction asyncInfo, AsyncStatus asyncStatus) + { + _parent.Tick?.Invoke(_st.Elapsed); + using var act = _parent._compositor5.RequestCommitAsync(); + act.SetCompleted(this); + } + + public MicroComShadow Shadow { get; set; } + public void OnReferencedFromNative() + { + } + + public void OnUnreferencedFromNative() + { + } + } - public static WinUICompositorConnection TryCreate(EglPlatformOpenGlInterface angle) + private void RunLoop() + { + { + var st = Stopwatch.StartNew(); + using (var act = _compositor5.RequestCommitAsync()) + act.SetCompleted(new RunLoopHandler(this)); + while (true) + { + UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0); + lock (_pumpLock) + UnmanagedMethods.DispatchMessage(ref msg); + } + } + } + + public static void TryCreateAndRegister(EglPlatformOpenGlInterface angle) { const int majorRequired = 10; const int buildRequired = 16299; @@ -97,14 +144,13 @@ namespace Avalonia.Win32.WinRT.Composition { try { - return TryCreateCore(angle); + TryCreateAndRegisterCore(angle); } catch (Exception e) { Logger.TryGet(LogEventLevel.Error, "WinUIComposition") ?.Log(null, "Unable to initialize WinUI compositor: {0}", e); - return null; } } @@ -113,8 +159,6 @@ namespace Avalonia.Win32.WinRT.Composition Logger.TryGet(LogEventLevel.Warning, "WinUIComposition")?.Log(null, $"Unable to initialize WinUI compositor: {osVersionNotice}"); - - return null; } @@ -187,7 +231,8 @@ namespace Avalonia.Win32.WinRT.Composition return visual.CloneReference(); } - - + + + public event Action Tick; } } diff --git a/src/Windows/Avalonia.Win32/WinRT/winrt.idl b/src/Windows/Avalonia.Win32/WinRT/winrt.idl index bdc757138c..929377999c 100644 --- a/src/Windows/Avalonia.Win32/WinRT/winrt.idl +++ b/src/Windows/Avalonia.Win32/WinRT/winrt.idl @@ -691,3 +691,28 @@ interface ICompositionScopedBatch : IInspectable [eventadd] HRESULT AddCompleted([in] void* handler, [out] [retval] int* token); [eventremove] HRESULT RemoveCompleted([in] int token); } + +[uuid(48EA31AD-7FCD-4076-A79C-90CC4B852C9B)] +interface ICompositor5 : IInspectable +{ + [propget] HRESULT GetComment([out] [retval] HSTRING* value); + [propput] HRESULT SetComment([in] HSTRING value); + [propget] HRESULT GetGlobalPlaybackRate([out] [retval] FLOAT* value); + [propput] HRESULT SetGlobalPlaybackRate([in] FLOAT value); + HRESULT CreateBounceScalarAnimation([out] [retval] void** result); + HRESULT CreateBounceVector2Animation([out] [retval] void** result); + HRESULT CreateBounceVector3Animation([out] [retval] void** result); + HRESULT CreateContainerShape([out] [retval] void** result); + HRESULT CreateEllipseGeometry([out] [retval] void** result); + HRESULT CreateLineGeometry([out] [retval] void** result); + [overload("CreatePathGeometry")] HRESULT CreatePathGeometry([out] [retval] void** result); + [overload("CreatePathGeometry")] HRESULT CreatePathGeometryWithPath([in] void* path, [out] [retval] void** result); + HRESULT CreatePathKeyFrameAnimation([out] [retval] void** result); + HRESULT CreateRectangleGeometry([out] [retval] void** result); + HRESULT CreateRoundedRectangleGeometry([out] [retval] void** result); + HRESULT CreateShapeVisual([out] [retval] void** result); + [overload("CreateSpriteShape")] HRESULT CreateSpriteShape([out] [retval] void** result); + [overload("CreateSpriteShape")] HRESULT CreateSpriteShapeWithGeometry([in] void* geometry, [out] [retval] void** result); + HRESULT CreateViewBox([out] [retval] void** result); + HRESULT RequestCommitAsync([out] [retval] IAsyncAction** operation); +} diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index fcd92acd57..c603128a18 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -454,9 +454,14 @@ namespace Avalonia.Win32 if (customRendererFactory != null) return customRendererFactory.Create(root, loop); - return Win32Platform.UseDeferredRendering ? - (IRenderer)new DeferredRenderer(root, loop, rendererLock: _rendererLock) : - new ImmediateRenderer(root); + return Win32Platform.UseDeferredRendering + ? _isUsingComposition + ? new DeferredRenderer(root, loop) + { + RenderOnlyOnRenderThread = true + } + : (IRenderer)new DeferredRenderer(root, loop, rendererLock: _rendererLock) + : new ImmediateRenderer(root); } public void Resize(Size value) From 5a75154bc76f6c5db3c991b28c836ebc52226e27 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 14:09:04 +0300 Subject: [PATCH 141/314] Don't wait for a frame to be rendered when renderer is stopped --- src/Avalonia.Visuals/Rendering/DeferredRenderer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index 7a1a2cb4a3..a43fd8cc7c 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -187,6 +187,12 @@ namespace Avalonia.Rendering { if (RenderOnlyOnRenderThread) { + // Renderer is stopped and doesn't tick on the render thread + // This indicates a bug somewhere in our code + // (currently happens when a window gets minimized with Show desktop on Windows 10) + if(!_running) + return; + while (true) { Scene scene; From e2c397ebf3b336ec8362bb74787f46d5c3e6528d Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 11:37:59 +0000 Subject: [PATCH 142/314] remove package source. --- NuGet.Config | 1 - 1 file changed, 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 3abd236d42..99d827d465 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -4,6 +4,5 @@ - From 8b5e2f9a010b6cba1400558dcfacd742ccfe688f Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 11:41:33 +0000 Subject: [PATCH 143/314] Revert "remove package source." This reverts commit e2c397ebf3b336ec8362bb74787f46d5c3e6528d. --- NuGet.Config | 1 + 1 file changed, 1 insertion(+) diff --git a/NuGet.Config b/NuGet.Config index 99d827d465..3abd236d42 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -4,5 +4,6 @@ + From 19a8b222a5acdf4c100a055f7e561d6af13109a9 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 11:46:12 +0000 Subject: [PATCH 144/314] force v3 protocol --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 3abd236d42..bd5683b660 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -4,6 +4,6 @@ - + From dbc4acc5c7e65a3900f09603d61803ec64ff80f8 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 11:58:14 +0000 Subject: [PATCH 145/314] use our own nuget feed for stability. --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index bd5683b660..7a1f28bea7 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -4,6 +4,6 @@ - + From b2141717b55724873edf839a18a8ab5362c27b89 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 15:12:03 +0300 Subject: [PATCH 146/314] Use the old DeferredRenderer threading mode by default --- src/Avalonia.Visuals/Rendering/DeferredRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index a43fd8cc7c..1c8a47c4b7 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -102,7 +102,7 @@ namespace Avalonia.Rendering /// /// Forces the renderer to only draw frames on the render thread. Makes Paint to wait until frame is rendered /// - public bool RenderOnlyOnRenderThread { get; set; } = true; + public bool RenderOnlyOnRenderThread { get; set; } /// public event EventHandler SceneInvalidated; From 2fd70994adc8535c8380459a0505aaf43faac77c Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 14 Nov 2020 19:48:45 +0100 Subject: [PATCH 147/314] Remove enumerator allocations and LINQ from children change notifications. --- src/Avalonia.Styling/StyledElement.cs | 48 ++++++++++++++++----------- src/Avalonia.Visuals/Visual.cs | 37 ++++++++++----------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index 65885ddebe..cc8d91462d 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -1,8 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.Linq; using Avalonia.Animation; using Avalonia.Collections; using Avalonia.Controls; @@ -479,16 +479,16 @@ namespace Avalonia switch (e.Action) { case NotifyCollectionChangedAction.Add: - SetLogicalParent(e.NewItems.Cast()); + SetLogicalParent(e.NewItems); break; case NotifyCollectionChangedAction.Remove: - ClearLogicalParent(e.OldItems.Cast()); + ClearLogicalParent(e.OldItems); break; case NotifyCollectionChangedAction.Replace: - ClearLogicalParent(e.OldItems.Cast()); - SetLogicalParent(e.NewItems.Cast()); + ClearLogicalParent(e.OldItems); + SetLogicalParent(e.NewItems); break; case NotifyCollectionChangedAction.Reset: @@ -702,13 +702,32 @@ namespace Avalonia OnDataContextChanged(EventArgs.Empty); } - private void SetLogicalParent(IEnumerable children) + private void SetLogicalParent(IList children) { - foreach (var i in children) + var count = children.Count; + + for (var i = 0; i < count; i++) + { + var logical = (ILogical) children[i]; + + if (logical.LogicalParent is null) + { + ((ISetLogicalParent)logical).SetParent(this); + } + } + } + + private void ClearLogicalParent(IList children) + { + var count = children.Count; + + for (var i = 0; i < count; i++) { - if (i.LogicalParent == null) + var logical = (ILogical) children[i]; + + if (logical.LogicalParent == this) { - ((ISetLogicalParent)i).SetParent(this); + ((ISetLogicalParent)logical).SetParent(null); } } } @@ -784,17 +803,6 @@ namespace Avalonia } } - private void ClearLogicalParent(IEnumerable children) - { - foreach (var i in children) - { - if (i.LogicalParent == this) - { - ((ISetLogicalParent)i).SetParent(null); - } - } - } - private void NotifyResourcesChanged( ResourcesChangedEventArgs? e = null, bool propagate = true) diff --git a/src/Avalonia.Visuals/Visual.cs b/src/Avalonia.Visuals/Visual.cs index 283d9deb52..30073c9966 100644 --- a/src/Avalonia.Visuals/Visual.cs +++ b/src/Avalonia.Visuals/Visual.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Specialized; using Avalonia.Collections; using Avalonia.Data; @@ -619,34 +620,30 @@ namespace Avalonia switch (e.Action) { case NotifyCollectionChangedAction.Add: - foreach (Visual v in e.NewItems) - { - v.SetVisualParent(this); - } - + SetVisualParent(e.NewItems, this); break; case NotifyCollectionChangedAction.Remove: - foreach (Visual v in e.OldItems) - { - v.SetVisualParent(null); - } - + SetVisualParent(e.OldItems, null); break; case NotifyCollectionChangedAction.Replace: - foreach (Visual v in e.OldItems) - { - v.SetVisualParent(null); - } - - foreach (Visual v in e.NewItems) - { - v.SetVisualParent(this); - } - + SetVisualParent(e.OldItems, null); + SetVisualParent(e.NewItems, this); break; } } + + private static void SetVisualParent(IList children, Visual parent) + { + var count = children.Count; + + for (var i = 0; i < count; i++) + { + var visual = (Visual) children[i]; + + visual.SetVisualParent(parent); + } + } } } From a778800d2e706524895426dae254f07d046dd802 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 15 Nov 2020 14:19:07 +0100 Subject: [PATCH 148/314] Remove boxing from TemplatedControl as well. --- src/Avalonia.Controls/Primitives/TemplatedControl.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs index d18cf7da71..9c73ff2411 100644 --- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs +++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs @@ -354,11 +354,14 @@ namespace Avalonia.Controls.Primitives { control.SetValue(TemplatedParentProperty, this); - foreach (var child in control.LogicalChildren) + var children = control.LogicalChildren; + var count = children.Count; + + for (var i = 0; i < count; i++) { - if (child is IControl c) + if (children[i] is IControl child) { - ApplyTemplatedParent(c); + ApplyTemplatedParent(child); } } } From cde8f4cf1aa5ee1ad969a99b8363456c09aa53e7 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 15 Nov 2020 14:27:10 +0100 Subject: [PATCH 149/314] Fix control benchmarks. --- tests/Avalonia.Benchmarks/NullRenderingPlatform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Avalonia.Benchmarks/NullRenderingPlatform.cs b/tests/Avalonia.Benchmarks/NullRenderingPlatform.cs index f632d85c26..1570205456 100644 --- a/tests/Avalonia.Benchmarks/NullRenderingPlatform.cs +++ b/tests/Avalonia.Benchmarks/NullRenderingPlatform.cs @@ -28,7 +28,7 @@ namespace Avalonia.Benchmarks public IGeometryImpl CreateRectangleGeometry(Rect rect) { - throw new NotImplementedException(); + return new MockStreamGeometryImpl(); } public IStreamGeometryImpl CreateStreamGeometry() From 7e4552ffedae697aa94b4766656915d1cfd7be7f Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 18:32:15 +0300 Subject: [PATCH 150/314] Reduce the element of surprise in XAML compiler --- src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs | 4 +++- .../Avalonia.Markup.Xaml.Loader.csproj | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 0b9b50e771..6ef8a98fae 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -46,7 +46,9 @@ namespace Avalonia.Build.Tasks string output, bool verifyIl, MessageImportance logImportance, string strongNameKey, bool patchCom, bool skipXamlCompilation) { - var typeSystem = new CecilTypeSystem(references.Concat(new[] { input }), input); + var typeSystem = new CecilTypeSystem(references + .Where(r => !r.ToLowerInvariant().EndsWith("avalonia.build.tasks.dll")) + .Concat(new[] { input }), input); var asm = typeSystem.TargetAssemblyDefinition; diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/Avalonia.Markup.Xaml.Loader.csproj b/src/Markup/Avalonia.Markup.Xaml.Loader/Avalonia.Markup.Xaml.Loader.csproj index 514556d0b9..db9c414840 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/Avalonia.Markup.Xaml.Loader.csproj +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/Avalonia.Markup.Xaml.Loader.csproj @@ -4,6 +4,7 @@ netstandard2.0 true Avalonia.Markup.Xaml.Loader + $(DefineConstants);XAMLX_INTERNAL From 80a87d7aa31a8b177690207d3d043e90d68f093e Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sun, 15 Nov 2020 17:32:43 +0200 Subject: [PATCH 151/314] add failing tests for CompiledBidning with Source set to StaticResource and x:Static --- .../CompiledBindingExtensionTests.cs | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 50dfa2c7b0..c19640c244 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -10,6 +10,7 @@ using Avalonia.Controls.Presenters; using Avalonia.Data.Converters; using Avalonia.Data.Core; using Avalonia.Markup.Data; +using Avalonia.Media; using Avalonia.UnitTests; using XamlX; using Xunit; @@ -536,7 +537,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } [Fact] - public void ResolvesSourceBindingLongForm() + public void Binds_To_Source() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { @@ -559,6 +560,49 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void Binds_To_Source_StaticResource() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + + + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var textBlock = window.FindControl("textBlock"); + + Assert.Equal("foobar", textBlock.Text); + } + } + + [Fact] + public void Binds_To_Source_xStatic() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var contentControl = window.FindControl("contentControl"); + + Assert.Equal(Brushes.Red.Color, contentControl.Content); + } + } + [Fact] public void CompilesBindingWhenRequested() { From 06d81f6e23cde111166393f441558dc1354247df Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sun, 15 Nov 2020 17:40:34 +0200 Subject: [PATCH 152/314] make CompiledBinding work with x:Static and StaticResource --- .../AvaloniaXamlIlBindingPathTransformer.cs | 33 ++++++++++++++++--- ...ransformSyntheticCompiledBindingMembers.cs | 4 +-- .../CompiledBindingExtension.cs | 10 ++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs index fc32084687..0d54e97bd9 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs @@ -15,14 +15,37 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers { if (node is XamlAstConstructableObjectNode binding && binding.Type.GetClrType().Equals(context.GetAvaloniaTypes().CompiledBindingExtension)) { - IXamlType startType; - var parentDataContextNode = context.ParentNodes().OfType().FirstOrDefault(); - if (parentDataContextNode is null) + IXamlType startType = null; + var sourceProperty = binding.Children.OfType().FirstOrDefault(c => c.Property.Name == "Source"); + if ((sourceProperty?.Values.Count ?? 0) == 1) { - throw new XamlX.XamlParseException("Cannot parse a compiled binding without an explicit x:DataType directive to give a starting data type for bindings.", binding); + var sourceValue = sourceProperty.Values[0]; + switch (sourceValue) + { + case XamlAstTextNode textNode: + startType = textNode.Type?.GetClrType(); + break; + + case XamlMarkupExtensionNode extension: + startType = extension.Type?.GetClrType(); + break; + + case XamlStaticExtensionNode staticExtension: + startType = staticExtension.Type?.GetClrType(); + break; + } } - startType = parentDataContextNode.DataContextType; + if (startType == null) + { + var parentDataContextNode = context.ParentNodes().OfType().FirstOrDefault(); + if (parentDataContextNode is null) + { + throw new XamlX.XamlParseException("Cannot parse a compiled binding without an explicit x:DataType directive to give a starting data type for bindings.", binding); + } + + startType = parentDataContextNode.DataContextType; + } XamlIlBindingPathHelper.UpdateCompiledBindingExtension(context, binding, startType); } diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs index 154c6a235c..6cb6e4e2d1 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs @@ -27,8 +27,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers } else if (prop.Name == "Source") { - return new AvaloniaSyntheticCompiledBindingProperty(node, - SyntheticCompiledBindingPropertyName.Source); + //return new AvaloniaSyntheticCompiledBindingProperty(node, + // SyntheticCompiledBindingPropertyName.Source); } } diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs index da39920eb3..17d2ea7ae9 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/CompiledBindingExtension.cs @@ -32,6 +32,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions Mode = Mode, Priority = Priority, StringFormat = StringFormat, + Source = Source, DefaultAnchor = new WeakReference(GetDefaultAnchor(provider)) }; } @@ -52,6 +53,13 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions protected override ExpressionObserver CreateExpressionObserver(IAvaloniaObject target, AvaloniaProperty targetProperty, object anchor, bool enableDataValidation) { + if (Source != null) + { + return CreateSourceObserver( + Source, + Path.BuildExpression(enableDataValidation)); + } + if (Path.RawSource != null) { return CreateSourceObserver( @@ -77,5 +85,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions [ConstructorArgument("path")] public CompiledBindingPath Path { get; set; } + + public object Source { get; set; } } } From f9de2a9c8236573df5ffe8dd0acc4417f3e43665 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sun, 15 Nov 2020 17:42:05 +0200 Subject: [PATCH 153/314] add more tests for CompiledBinding Source with StaticResource --- .../CompiledBindingExtensionTests.cs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index c19640c244..de9ecc8bb0 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -583,6 +583,81 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions } } + [Fact] + public void Binds_To_Source_StaticResource1() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + + + test + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var textBlock = window.FindControl("textBlock"); + + Assert.Equal("foobar", textBlock.Text); + } + } + + [Fact] + public void Binds_To_Source_StaticResource_In_ResourceDictionary() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + + + + + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var textBlock = window.FindControl("textBlock"); + + Assert.Equal("foobar", textBlock.Text); + } + } + + [Fact] + public void Binds_To_Source_StaticResource_In_ResourceDictionary1() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var xaml = @" + + + + + test + + + +"; + + var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml); + var textBlock = window.FindControl("textBlock"); + + Assert.Equal("foobar", textBlock.Text); + } + } + [Fact] public void Binds_To_Source_xStatic() { From 13c25983f70d2c606eaaa5d83f318413bf65773b Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sun, 15 Nov 2020 17:45:04 +0200 Subject: [PATCH 154/314] try infer StaticResource type in CompiledBinding Soure --- .../AvaloniaXamlIlBindingPathTransformer.cs | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs index 0d54e97bd9..4d8c940bbc 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathTransformer.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using XamlX; using XamlX.Ast; using XamlX.Transform; using XamlX.TypeSystem; @@ -28,6 +26,71 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers case XamlMarkupExtensionNode extension: startType = extension.Type?.GetClrType(); + + //let's try to infer StaticResource type from parent resources in xaml + if (extension.Value.Type.GetClrType().FullName == "Avalonia.Markup.Xaml.MarkupExtensions.StaticResourceExtension" && + extension.Value is XamlAstConstructableObjectNode cn && + cn.Arguments.Count == 1 && cn.Arguments[0] is XamlAstTextNode keyNode) + { + bool matchProperty(IXamlAstNode node, IXamlType styledElementType, string propertyName) + { + return (node is XamlPropertyAssignmentNode p && + p.Property.DeclaringType == styledElementType && p.Property.Name == propertyName) + || + (node is XamlManipulationGroupNode m && m.Children.Count > 0 && + m.Children[0] is XamlPropertyAssignmentNode pm && + pm.Property.DeclaringType == styledElementType && pm.Property.Name == propertyName); + } + + string getResourceValue_xKey(XamlPropertyAssignmentNode node) + => node.Values.Count == 2 && node.Values[0] is XamlAstTextNode t ? t.Text : ""; + + IXamlType getResourceValue_Type(XamlPropertyAssignmentNode node, IXamlType xamlType) + => node.Values.Count == 2 ? node.Values[1].Type.GetClrType() : xamlType; + + IEnumerable getResourceValues(IXamlAstNode node) + { + if (node is XamlPropertyAssignmentNode propertyNode) + { + if (propertyNode.Values.Count == 1 && + propertyNode.Values[0] is XamlAstConstructableObjectNode obj && + obj.Type.GetClrType().FullName == "Avalonia.Controls.ResourceDictionary") + { + foreach (var r in obj.Children.SelectMany(c => getResourceValues(c))) + { + yield return r; + } + } + else + { + yield return propertyNode; + } + } + else if (node is XamlManipulationGroupNode m) + { + foreach (var r in m.Children.OfType()) + { + yield return r; + } + } + } + + string key = keyNode.Text; + + var styledElement = context.GetAvaloniaTypes().StyledElement; + var resource = context.ParentNodes() + .OfType() + .Where(o => styledElement.IsAssignableFrom(o.Type.GetClrType())) + .Select(o => o.Children.FirstOrDefault(p => matchProperty(p, styledElement, "Resources"))) + .Where(r => r != null) + .SelectMany(r => getResourceValues(r)) + .FirstOrDefault(r => getResourceValue_xKey(r) == key); + + if (resource != null) + { + startType = getResourceValue_Type(resource, startType); + } + } break; case XamlStaticExtensionNode staticExtension: From bc39305fd0a088a306e8c13358fa8fc426fe9fc0 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sun, 15 Nov 2020 18:16:58 +0200 Subject: [PATCH 155/314] clean up --- .../AvaloniaXamlIlBindingPathParser.cs | 23 ++++++------------- ...ransformSyntheticCompiledBindingMembers.cs | 8 +------ 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs index 7944d8b569..24cded1d22 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlBindingPathParser.cs @@ -72,16 +72,16 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers v.Property is AvaloniaSyntheticCompiledBindingProperty prop && prop.Name == SyntheticCompiledBindingPropertyName.ElementName); - var sourceProperty = syntheticCompiledBindingProperties - .FirstOrDefault(v => - v.Property is AvaloniaSyntheticCompiledBindingProperty prop - && prop.Name == SyntheticCompiledBindingPropertyName.Source); - var relativeSourceProperty = syntheticCompiledBindingProperties .FirstOrDefault(v => v.Property is AvaloniaSyntheticCompiledBindingProperty prop && prop.Name == SyntheticCompiledBindingPropertyName.RelativeSource); + var sourceProperty = binding.Children.OfType() + .FirstOrDefault(v => + v.Property is XamlAstClrProperty prop + && prop.Name == "Source"); + if (elementNameProperty?.Values[0] is XamlAstTextNode elementName) { convertedNode = new BindingExpressionGrammar.NameNode { Name = elementName.Text }; @@ -91,14 +91,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers throw new XamlParseException($"Invalid ElementName '{elementNameProperty.Values[0]}'.", elementNameProperty.Values[0]); } - if (sourceProperty?.Values[0] != null) + if (sourceProperty != null && convertedNode != null) { - if (convertedNode != null) - { - throw new XamlParseException("Only one of ElementName, Source, or RelativeSource specified as a binding source. Only one property is allowed.", binding); - } - - convertedNode = new RawSourceBindingExpressionNode(sourceProperty?.Values[0]); + throw new XamlParseException("Only one of ElementName, Source, or RelativeSource specified as a binding source. Only one property is allowed.", binding); } if (GetRelativeSourceObjectFromAssignment( @@ -223,10 +218,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers { binding.Children.Remove(elementNameProperty); } - if (sourceProperty != null) - { - binding.Children.Remove(sourceProperty); - } if (relativeSourceProperty != null) { binding.Children.Remove(relativeSourceProperty); diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs index 6cb6e4e2d1..ba05347a52 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformSyntheticCompiledBindingMembers.cs @@ -25,11 +25,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers return new AvaloniaSyntheticCompiledBindingProperty(node, SyntheticCompiledBindingPropertyName.RelativeSource); } - else if (prop.Name == "Source") - { - //return new AvaloniaSyntheticCompiledBindingProperty(node, - // SyntheticCompiledBindingPropertyName.Source); - } } return node; @@ -39,8 +34,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers enum SyntheticCompiledBindingPropertyName { ElementName, - RelativeSource, - Source + RelativeSource } class AvaloniaSyntheticCompiledBindingProperty : XamlAstNode, IXamlAstPropertyReference From b229acf8dca90955d44eb255f5d11c4991b42427 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 15 Nov 2020 20:19:32 +0300 Subject: [PATCH 156/314] Don't use the concrete type in tests --- .../CompiledBindingExtensionTests.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 50dfa2c7b0..1cf9e0877d 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -374,7 +374,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions "; - Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); + ThrowsXamlTransformException(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } @@ -392,7 +392,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions "; - Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); + ThrowsXamlTransformException(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } @@ -449,7 +449,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions "; - Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); + ThrowsXamlTransformException(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } @@ -599,7 +599,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions x:CompileBindings='true'> "; - Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); + ThrowsXamlParseException(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } @@ -657,7 +657,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions x:DataType='local:TestDataContext' x:CompileBindings='notabool'> "; - Assert.Throws(() => AvaloniaRuntimeXamlLoader.Load(xaml)); + ThrowsXamlParseException(() => AvaloniaRuntimeXamlLoader.Load(xaml)); } } @@ -818,8 +818,25 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions Assert.Equal(null, contentControl.Content); } } - } + void Throws(string type, Action cb) + { + try + { + cb(); + } + catch (Exception e) when (e.GetType().Name == type) + { + return; + } + + throw new Exception("Expected " + type); + } + + void ThrowsXamlParseException(Action cb) => Throws("XamlParseException", cb); + void ThrowsXamlTransformException(Action cb) => Throws("XamlTransformException", cb); + } + public interface INonIntegerIndexer { string this[string key] { get; set; } From da1f3968ef5e1180527c9f8fc71ea0545074a1a5 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 15 Nov 2020 18:48:40 +0100 Subject: [PATCH 157/314] Parse most of the vector-like types during XAML compilation. --- src/Avalonia.Base/Utilities/MathUtilities.cs | 5 +- .../Utilities/StringTokenizer.cs | 5 +- .../Avalonia.Build.Tasks.csproj | 24 ++++++++ src/Avalonia.Visuals/CornerRadius.cs | 9 ++- src/Avalonia.Visuals/Matrix.cs | 5 +- src/Avalonia.Visuals/Point.cs | 9 ++- src/Avalonia.Visuals/Size.cs | 9 ++- src/Avalonia.Visuals/Thickness.cs | 9 ++- src/Avalonia.Visuals/Vector.cs | 9 ++- ...AvaloniaXamlIlVectorLikeConstantAstNode.cs | 35 +++++++++++ .../AvaloniaXamlIlLanguage.cs | 60 +++++++++++++++++++ .../AvaloniaXamlIlWellKnownTypes.cs | 31 +++++++++- .../Avalonia.Markup.Xaml.Loader/xamlil.github | 2 +- 13 files changed, 201 insertions(+), 11 deletions(-) create mode 100644 src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs diff --git a/src/Avalonia.Base/Utilities/MathUtilities.cs b/src/Avalonia.Base/Utilities/MathUtilities.cs index 2a92e75f58..446b366dc8 100644 --- a/src/Avalonia.Base/Utilities/MathUtilities.cs +++ b/src/Avalonia.Base/Utilities/MathUtilities.cs @@ -5,7 +5,10 @@ namespace Avalonia.Utilities /// /// Provides math utilities not provided in System.Math. /// - public static class MathUtilities +#if !BUILDTASK + public +#endif + static class MathUtilities { // smallest such that 1.0+DoubleEpsilon != 1.0 internal static readonly double DoubleEpsilon = 2.2204460492503131e-016; diff --git a/src/Avalonia.Base/Utilities/StringTokenizer.cs b/src/Avalonia.Base/Utilities/StringTokenizer.cs index a159bfb72e..24e99febb9 100644 --- a/src/Avalonia.Base/Utilities/StringTokenizer.cs +++ b/src/Avalonia.Base/Utilities/StringTokenizer.cs @@ -4,7 +4,10 @@ using static System.Char; namespace Avalonia.Utilities { - public struct StringTokenizer : IDisposable +#if !BUILDTASK + public +#endif + struct StringTokenizer : IDisposable { private const char DefaultSeparatorChar = ','; diff --git a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj index 94ad4adb7d..bfac1ac1e1 100644 --- a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj +++ b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj @@ -45,6 +45,12 @@ Markup/%(RecursiveDir)%(FileName)%(Extension) + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + Markup/%(RecursiveDir)%(FileName)%(Extension) @@ -57,6 +63,24 @@ Markup/%(RecursiveDir)%(FileName)%(Extension) + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + diff --git a/src/Avalonia.Visuals/CornerRadius.cs b/src/Avalonia.Visuals/CornerRadius.cs index c02aacfb4d..037bb16e31 100644 --- a/src/Avalonia.Visuals/CornerRadius.cs +++ b/src/Avalonia.Visuals/CornerRadius.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif using Avalonia.Utilities; namespace Avalonia @@ -8,11 +10,16 @@ namespace Avalonia /// /// Represents the radii of a rectangle's corners. /// - public readonly struct CornerRadius : IEquatable +#if !BUILDTASK + public +#endif + readonly struct CornerRadius : IEquatable { static CornerRadius() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(CornerRadius).IsAssignableFrom(prop.PropertyType)); +#endif } public CornerRadius(double uniformRadius) diff --git a/src/Avalonia.Visuals/Matrix.cs b/src/Avalonia.Visuals/Matrix.cs index 206b842220..2ccfd43f03 100644 --- a/src/Avalonia.Visuals/Matrix.cs +++ b/src/Avalonia.Visuals/Matrix.cs @@ -7,7 +7,10 @@ namespace Avalonia /// /// A 2x3 matrix. /// - public readonly struct Matrix : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Matrix : IEquatable { private readonly double _m11; private readonly double _m12; diff --git a/src/Avalonia.Visuals/Point.cs b/src/Avalonia.Visuals/Point.cs index 7324f5fbd0..6febe9c802 100644 --- a/src/Avalonia.Visuals/Point.cs +++ b/src/Avalonia.Visuals/Point.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif using Avalonia.Utilities; namespace Avalonia @@ -8,11 +10,16 @@ namespace Avalonia /// /// Defines a point. /// - public readonly struct Point : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Point : IEquatable { static Point() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(Point).IsAssignableFrom(prop.PropertyType)); +#endif } /// diff --git a/src/Avalonia.Visuals/Size.cs b/src/Avalonia.Visuals/Size.cs index d87d2c5fc2..8a805dc6c5 100644 --- a/src/Avalonia.Visuals/Size.cs +++ b/src/Avalonia.Visuals/Size.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif using Avalonia.Utilities; namespace Avalonia @@ -8,11 +10,16 @@ namespace Avalonia /// /// Defines a size. /// - public readonly struct Size : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Size : IEquatable { static Size() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(Size).IsAssignableFrom(prop.PropertyType)); +#endif } /// diff --git a/src/Avalonia.Visuals/Thickness.cs b/src/Avalonia.Visuals/Thickness.cs index 6d69c4d9a9..06ebc9bfe7 100644 --- a/src/Avalonia.Visuals/Thickness.cs +++ b/src/Avalonia.Visuals/Thickness.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif using Avalonia.Utilities; namespace Avalonia @@ -8,11 +10,16 @@ namespace Avalonia /// /// Describes the thickness of a frame around a rectangle. /// - public readonly struct Thickness : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Thickness : IEquatable { static Thickness() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(Thickness).IsAssignableFrom(prop.PropertyType)); +#endif } /// diff --git a/src/Avalonia.Visuals/Vector.cs b/src/Avalonia.Visuals/Vector.cs index 2fcf804f14..1b9f5c67d5 100644 --- a/src/Avalonia.Visuals/Vector.cs +++ b/src/Avalonia.Visuals/Vector.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif using Avalonia.Utilities; #nullable enable @@ -10,11 +12,16 @@ namespace Avalonia /// /// Defines a vector. /// - public readonly struct Vector : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Vector : IEquatable { static Vector() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(Vector).IsAssignableFrom(prop.PropertyType)); +#endif } /// diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs new file mode 100644 index 0000000000..db23856900 --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs @@ -0,0 +1,35 @@ +using XamlX.Ast; +using XamlX.Emit; +using XamlX.IL; +using XamlX.TypeSystem; + +namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes +{ + class AvaloniaXamlIlVectorLikeConstantAstNode : XamlAstNode, IXamlAstValueNode, IXamlAstILEmitableNode + { + private readonly IXamlConstructor _constructor; + private readonly double[] _values; + + public AvaloniaXamlIlVectorLikeConstantAstNode(IXamlLineInfo lineInfo, IXamlType type, IXamlConstructor constructor, double[] values) : base(lineInfo) + { + _constructor = constructor; + _values = values; + + Type = new XamlAstClrTypeReference(lineInfo, type, false); + } + + public IXamlAstTypeReference Type { get; } + + public XamlILNodeEmitResult Emit(XamlEmitContext context, IXamlILEmitter codeGen) + { + foreach (var value in _values) + { + codeGen.Ldc_R8(value); + } + + codeGen.Newobj(_constructor); + + return XamlILNodeEmitResult.Type(0, Type.GetClrType()); + } + } +} diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 15413689f8..5dc6682129 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -205,6 +205,66 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions result = new AvaloniaXamlIlFontFamilyAstNode(types, text, node); return true; } + + if (type.Equals(types.Thickness)) + { + var thickness = Thickness.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Thickness, types.ThicknessFullConstructorName, + new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); + + return true; + } + + if (type.Equals(types.Point)) + { + var point = Point.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Point, types.PointFullConstructorName, + new[] { point.X, point.Y }); + + return true; + } + + if (type.Equals(types.Vector)) + { + var vector = Vector.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Vector, types.VectorFullConstructorName, + new[] { vector.X, vector.Y }); + + return true; + } + + if (type.Equals(types.Size)) + { + var size = Size.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Size, types.SizeFullConstructorName, + new[] { size.Width, size.Height }); + + return true; + } + + if (type.Equals(types.Matrix)) + { + var matrix = Matrix.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Matrix, types.MatrixFullConstructorName, + new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); + + return true; + } + + if (type.Equals(types.CornerRadius)) + { + var cornerRadius = CornerRadius.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.CornerRadius, types.CornerRadiusFullConstructorName, + new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); + + return true; + } if (type.FullName == "Avalonia.AvaloniaProperty") { diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 58f4ddfe31..8ac2daa707 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using XamlX.Emit; using XamlX.IL; using XamlX.Transform; @@ -52,7 +53,18 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType Uri { get; } public IXamlType FontFamily { get; } public IXamlConstructor FontFamilyConstructorUriName { get; } - + public IXamlType Thickness { get; } + public IXamlConstructor ThicknessFullConstructorName { get; } + public IXamlType Point { get; } + public IXamlConstructor PointFullConstructorName { get; } + public IXamlType Vector { get; } + public IXamlConstructor VectorFullConstructorName { get; } + public IXamlType Size { get; } + public IXamlConstructor SizeFullConstructorName { get; } + public IXamlType Matrix { get; } + public IXamlConstructor MatrixFullConstructorName { get; } + public IXamlType CornerRadius { get; } + public IXamlConstructor CornerRadiusFullConstructorName { get; } public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -113,7 +125,22 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers Long = cfg.TypeSystem.GetType("System.Int64"); Uri = cfg.TypeSystem.GetType("System.Uri"); FontFamily = cfg.TypeSystem.GetType("Avalonia.Media.FontFamily"); - FontFamilyConstructorUriName = FontFamily.FindConstructor(new List { Uri, XamlIlTypes.String }); + FontFamilyConstructorUriName = FontFamily.GetConstructor(new List { Uri, XamlIlTypes.String }); + + (IXamlType, IXamlConstructor) GetNumericTypeInfo(string name, IXamlType componentType, int componentCount) + { + var type = cfg.TypeSystem.GetType(name); + var ctor = type.GetConstructor(Enumerable.Range(0, componentCount).Select(_ => componentType).ToList()); + + return (type, ctor); + } + + (Thickness, ThicknessFullConstructorName) = GetNumericTypeInfo("Avalonia.Thickness", XamlIlTypes.Double, 4); + (Point, PointFullConstructorName) = GetNumericTypeInfo("Avalonia.Point", XamlIlTypes.Double, 2); + (Vector, VectorFullConstructorName) = GetNumericTypeInfo("Avalonia.Vector", XamlIlTypes.Double, 2); + (Size, SizeFullConstructorName) = GetNumericTypeInfo("Avalonia.Size", XamlIlTypes.Double, 2); + (Matrix, MatrixFullConstructorName) = GetNumericTypeInfo("Avalonia.Matrix", XamlIlTypes.Double, 6); + (CornerRadius, CornerRadiusFullConstructorName) = GetNumericTypeInfo("Avalonia.CornerRadius", XamlIlTypes.Double, 4); } } diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github b/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github index 5420df861c..8d2b6e6ee5 160000 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github @@ -1 +1 @@ -Subproject commit 5420df861ce6f2be5ead9efa078fe7242ce88f18 +Subproject commit 8d2b6e6ee5099d6a0271e743d2808f44e3241945 From 346687423c7e7be1dc56aad5d99971842789fe59 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 15 Nov 2020 19:12:45 +0100 Subject: [PATCH 158/314] Bump compiler version. --- src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github b/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github index 8d2b6e6ee5..ea80a607c5 160000 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github @@ -1 +1 @@ -Subproject commit 8d2b6e6ee5099d6a0271e743d2808f44e3241945 +Subproject commit ea80a607c5e9d8f000160dbbb48c27ed4cfafbc9 From 78dde1f2dacfa1eb12d0811bbc818f4555da3863 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 15 Nov 2020 19:36:46 +0100 Subject: [PATCH 159/314] Review fixes. --- ...AvaloniaXamlIlVectorLikeConstantAstNode.cs | 23 ++++++++++++++++-- .../AvaloniaXamlIlLanguage.cs | 12 +++++----- .../AvaloniaXamlIlWellKnownTypes.cs | 24 +++++++++---------- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs index db23856900..35cc9b3cf2 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlVectorLikeConstantAstNode.cs @@ -1,4 +1,6 @@ -using XamlX.Ast; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using XamlX; +using XamlX.Ast; using XamlX.Emit; using XamlX.IL; using XamlX.TypeSystem; @@ -10,8 +12,25 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes private readonly IXamlConstructor _constructor; private readonly double[] _values; - public AvaloniaXamlIlVectorLikeConstantAstNode(IXamlLineInfo lineInfo, IXamlType type, IXamlConstructor constructor, double[] values) : base(lineInfo) + public AvaloniaXamlIlVectorLikeConstantAstNode(IXamlLineInfo lineInfo, AvaloniaXamlIlWellKnownTypes types, IXamlType type, IXamlConstructor constructor, double[] values) : base(lineInfo) { + var parameters = constructor.Parameters; + + if (parameters.Count != values.Length) + { + throw new XamlTypeSystemException($"Constructor that takes {values.Length} parameters is expected, got {parameters.Count} instead."); + } + + var elementType = types.XamlIlTypes.Double; + + foreach (var parameter in parameters) + { + if (parameter != elementType) + { + throw new XamlTypeSystemException($"Expected parameter of type {elementType}, got {parameter} instead."); + } + } + _constructor = constructor; _values = values; diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 5dc6682129..c3d9534828 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -210,7 +210,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var thickness = Thickness.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Thickness, types.ThicknessFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Thickness, types.ThicknessFullConstructor, new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); return true; @@ -220,7 +220,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var point = Point.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Point, types.PointFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Point, types.PointFullConstructor, new[] { point.X, point.Y }); return true; @@ -230,7 +230,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var vector = Vector.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Vector, types.VectorFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Vector, types.VectorFullConstructor, new[] { vector.X, vector.Y }); return true; @@ -240,7 +240,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var size = Size.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Size, types.SizeFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Size, types.SizeFullConstructor, new[] { size.Width, size.Height }); return true; @@ -250,7 +250,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var matrix = Matrix.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.Matrix, types.MatrixFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Matrix, types.MatrixFullConstructor, new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); return true; @@ -260,7 +260,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions { var cornerRadius = CornerRadius.Parse(text); - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types.CornerRadius, types.CornerRadiusFullConstructorName, + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.CornerRadius, types.CornerRadiusFullConstructor, new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); return true; diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 8ac2daa707..05b13b61d3 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -54,17 +54,17 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType FontFamily { get; } public IXamlConstructor FontFamilyConstructorUriName { get; } public IXamlType Thickness { get; } - public IXamlConstructor ThicknessFullConstructorName { get; } + public IXamlConstructor ThicknessFullConstructor { get; } public IXamlType Point { get; } - public IXamlConstructor PointFullConstructorName { get; } + public IXamlConstructor PointFullConstructor { get; } public IXamlType Vector { get; } - public IXamlConstructor VectorFullConstructorName { get; } + public IXamlConstructor VectorFullConstructor { get; } public IXamlType Size { get; } - public IXamlConstructor SizeFullConstructorName { get; } + public IXamlConstructor SizeFullConstructor { get; } public IXamlType Matrix { get; } - public IXamlConstructor MatrixFullConstructorName { get; } + public IXamlConstructor MatrixFullConstructor { get; } public IXamlType CornerRadius { get; } - public IXamlConstructor CornerRadiusFullConstructorName { get; } + public IXamlConstructor CornerRadiusFullConstructor { get; } public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -135,12 +135,12 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers return (type, ctor); } - (Thickness, ThicknessFullConstructorName) = GetNumericTypeInfo("Avalonia.Thickness", XamlIlTypes.Double, 4); - (Point, PointFullConstructorName) = GetNumericTypeInfo("Avalonia.Point", XamlIlTypes.Double, 2); - (Vector, VectorFullConstructorName) = GetNumericTypeInfo("Avalonia.Vector", XamlIlTypes.Double, 2); - (Size, SizeFullConstructorName) = GetNumericTypeInfo("Avalonia.Size", XamlIlTypes.Double, 2); - (Matrix, MatrixFullConstructorName) = GetNumericTypeInfo("Avalonia.Matrix", XamlIlTypes.Double, 6); - (CornerRadius, CornerRadiusFullConstructorName) = GetNumericTypeInfo("Avalonia.CornerRadius", XamlIlTypes.Double, 4); + (Thickness, ThicknessFullConstructor) = GetNumericTypeInfo("Avalonia.Thickness", XamlIlTypes.Double, 4); + (Point, PointFullConstructor) = GetNumericTypeInfo("Avalonia.Point", XamlIlTypes.Double, 2); + (Vector, VectorFullConstructor) = GetNumericTypeInfo("Avalonia.Vector", XamlIlTypes.Double, 2); + (Size, SizeFullConstructor) = GetNumericTypeInfo("Avalonia.Size", XamlIlTypes.Double, 2); + (Matrix, MatrixFullConstructor) = GetNumericTypeInfo("Avalonia.Matrix", XamlIlTypes.Double, 6); + (CornerRadius, CornerRadiusFullConstructor) = GetNumericTypeInfo("Avalonia.CornerRadius", XamlIlTypes.Double, 4); } } From 32be146090772f6bcc4978d51074ba730769fd32 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 12:42:36 +0000 Subject: [PATCH 160/314] lock api diff to preview6. --- build/ApiDiff.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ApiDiff.props b/build/ApiDiff.props index 3d322f56d5..fb65ef6e87 100644 --- a/build/ApiDiff.props +++ b/build/ApiDiff.props @@ -1,6 +1,6 @@  - 0.10.0-preview3 + 0.10.0-preview6 $(PackageId) Avalonia From 8c7540ddf15137d96f77cf386dde5eebd49c44df Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 12:42:50 +0000 Subject: [PATCH 161/314] update System.Reactive to .net5 --- build/Rx.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Rx.props b/build/Rx.props index 8a15ccd6a9..fde1f80ea1 100644 --- a/build/Rx.props +++ b/build/Rx.props @@ -1,5 +1,5 @@  - + From ae982fcfa15041409645c52156041d51151fdaf3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 18:32:03 +0000 Subject: [PATCH 162/314] try updating nuke. --- nukebuild/_build.csproj | 2 +- samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nukebuild/_build.csproj b/nukebuild/_build.csproj index 745c727be2..b0380cc92b 100644 --- a/nukebuild/_build.csproj +++ b/nukebuild/_build.csproj @@ -10,7 +10,7 @@ - + diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index d5aedf7783..11e340e647 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5 true From 3d98acbed9624109baa60e66fb06c4c55d8b0a9c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 18:54:13 +0000 Subject: [PATCH 163/314] fix nuke --- nukebuild/Build.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index 97647a1c59..8e331edab4 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -107,7 +107,7 @@ partial class Build : NukeBuild .AddProperty("JavaSdkDirectory", GetVariable("JAVA_HOME_8_X64"))) .AddProperty("PackageVersion", Parameters.Version) .AddProperty("iOSRoslynPathHackRequired", true) - .SetToolPath(MsBuildExe.Value) + .SetProcessToolPath(MsBuildExe.Value) .SetConfiguration(Parameters.Configuration) .SetVerbosity(MSBuildVerbosity.Minimal) .Apply(configurator)); @@ -132,10 +132,10 @@ partial class Build : NukeBuild var webappDir = RootDirectory / "src" / "Avalonia.DesignerSupport" / "Remote" / "HtmlTransport" / "webapp"; NpmTasks.NpmInstall(c => c - .SetWorkingDirectory(webappDir) - .SetArgumentConfigurator(a => a.Add("--silent"))); + .SetProcessWorkingDirectory(webappDir) + .SetProcessArgumentConfigurator(a => a.Add("--silent"))); NpmTasks.NpmRun(c => c - .SetWorkingDirectory(webappDir) + .SetProcessWorkingDirectory(webappDir) .SetCommand("dist")); }); @@ -157,7 +157,7 @@ partial class Build : NukeBuild { if (Parameters.IsRunningOnWindows) MsBuildCommon(Parameters.MSBuildSolution, c => c - .SetArgumentConfigurator(a => a.Add("/r")) + .SetProcessArgumentConfigurator(a => a.Add("/r")) .AddTargets("Build") ); @@ -194,7 +194,7 @@ partial class Build : NukeBuild var eventsProject = Path.Combine(eventsDirectory, "Avalonia.ReactiveUI.Events.csproj"); if (Parameters.IsRunningOnWindows) MsBuildCommon(eventsProject, c => c - .SetArgumentConfigurator(a => a.Add("/r")) + .SetProcessArgumentConfigurator(a => a.Add("/r")) .AddTargets("Build") ); else @@ -242,10 +242,10 @@ partial class Build : NukeBuild var webappTestDir = RootDirectory / "tests" / "Avalonia.DesignerSupport.Tests" / "Remote" / "HtmlTransport" / "webapp"; NpmTasks.NpmInstall(c => c - .SetWorkingDirectory(webappTestDir) - .SetArgumentConfigurator(a => a.Add("--silent"))); + .SetProcessWorkingDirectory(webappTestDir) + .SetProcessArgumentConfigurator(a => a.Add("--silent"))); NpmTasks.NpmRun(c => c - .SetWorkingDirectory(webappTestDir) + .SetProcessWorkingDirectory(webappTestDir) .SetCommand("test")); }); From d3e304048c955149285864da6a0032cd24a57b84 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 15 Nov 2020 19:06:13 +0000 Subject: [PATCH 164/314] revert controlcatalog target. --- samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index 11e340e647..d5aedf7783 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -2,7 +2,7 @@ Exe - net5 + netcoreapp3.1 true From 3518f19b2aa5d688781a06217e7090bb2efb575c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 16 Nov 2020 11:22:05 +0100 Subject: [PATCH 165/314] Revert "ItemsControl+ItemVirtualizerSimple don not recreate containers when Items or ItemTemplate are replaced" --- src/Avalonia.Controls/ItemsControl.cs | 6 +- .../Presenters/ItemVirtualizerSimple.cs | 4 - .../Presenters/ItemsPresenterBase.cs | 4 +- .../ItemsControlTests.cs | 92 -------------- .../ListBoxTests.cs | 112 ------------------ 5 files changed, 2 insertions(+), 216 deletions(-) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index f955df5f21..4dc8aec6f3 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -449,11 +449,7 @@ namespace Avalonia.Controls if (_itemContainerGenerator != null) { _itemContainerGenerator.ItemTemplate = (IDataTemplate)e.NewValue; - - if (e.OldValue != null && Presenter != null) - { - Presenter.ItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - } + // TODO: Rebuild the item containers. } } diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs index 51dbc969a8..7d50ef7d33 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs @@ -200,10 +200,6 @@ namespace Avalonia.Controls.Presenters break; case NotifyCollectionChangedAction.Reset: - Owner.ItemContainerGenerator.Clear(); - VirtualizingPanel.Children.Clear(); - FirstIndex = NextIndex = 0; - RecycleContainersOnRemove(); CreateAndRemoveContainers(); panel.ForceInvalidateMeasure(); diff --git a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs index 6c408bbed9..52f173fc71 100644 --- a/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs +++ b/src/Avalonia.Controls/Presenters/ItemsPresenterBase.cs @@ -57,8 +57,6 @@ namespace Avalonia.Controls.Presenters set { - var itemsReplaced = (_items != value); - _itemsSubscription?.Dispose(); _itemsSubscription = null; @@ -69,7 +67,7 @@ namespace Avalonia.Controls.Presenters SetAndRaise(ItemsProperty, ref _items, value); - if (_createdPanel && itemsReplaced) + if (_createdPanel) { ItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } diff --git a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs index 157eefb84a..684486cbae 100644 --- a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs @@ -596,98 +596,6 @@ namespace Avalonia.Controls.UnitTests root.Child = target; } - [Fact] - public void Presenter_Items_Should_Be_In_Sync_When_Replacing_Items() - { - var target = new ItemsControl - { - Template = GetTemplate(), - Items = new[] - { - new Item("Item1") - } - }; - - var root = new TestRoot { Child = target }; - var otherPanel = new StackPanel(); - - target.ApplyTemplate(); - target.Presenter.ApplyTemplate(); - - int dematerializedEventCallCount = 0; - target.ItemContainerGenerator.Dematerialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - dematerializedEventCallCount++; - }; - - int materializedEventCallCount = 0; - target.ItemContainerGenerator.Materialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item2", ((Item)e.Containers[0].Item).Value); - materializedEventCallCount++; - }; - - target.Items = new[] - { - new Item("Item2") - }; - - //Ensure that events are called one time only - Assert.Equal(1, dematerializedEventCallCount); - Assert.Equal(1, materializedEventCallCount); - } - - [Fact] - public void Presenter_Items_Should_Be_In_Sync_When_Replacing_ItemTemplate() - { - var target = new ItemsControl - { - Template = GetTemplate(), - Items = new[] - { - new Item("Item1") - }, - ItemTemplate = new FuncDataTemplate((x, ns) => new TextBlock()) - }; - - var root = new TestRoot { Child = target }; - var otherPanel = new StackPanel(); - - target.ApplyTemplate(); - target.Presenter.ApplyTemplate(); - - int dematerializedEventCallCount = 0; - target.ItemContainerGenerator.Dematerialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - var contentPresenter = ((ContentPresenter)e.Containers[0].ContainerControl); - contentPresenter.UpdateChild(); - Assert.IsType(contentPresenter.Child); - dematerializedEventCallCount++; - }; - - int materializedEventCallCount = 0; - target.ItemContainerGenerator.Materialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - var contentPresenter = ((ContentPresenter)e.Containers[0].ContainerControl); - contentPresenter.UpdateChild(); - Assert.IsType(contentPresenter.Child); - materializedEventCallCount++; - }; - - target.ItemTemplate = - new FuncDataTemplate((x, ns) => new Canvas()); - - Assert.Equal(1, dematerializedEventCallCount); - Assert.Equal(1, materializedEventCallCount); - } - private class Item { public Item(string value) diff --git a/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs b/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs index 364cb01c65..145fce4fed 100644 --- a/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ListBoxTests.cs @@ -454,118 +454,6 @@ namespace Avalonia.Controls.UnitTests } } - - [Fact] - public void ListBox_Presenter_Items_Should_Be_In_Sync_When_Replacing_Items() - { - using (UnitTestApplication.Start(TestServices.StyledWindow)) - { - var wnd = new Window() { Width = 100, Height = 100, IsVisible = true }; - - var target = new ListBox() - { - VerticalAlignment = Layout.VerticalAlignment.Top, - AutoScrollToSelectedItem = true, - Width = 50, - VirtualizationMode = ItemVirtualizationMode.Simple, - Items = new[] - { - new Item("Item1") - }, - }; - wnd.Content = target; - - var lm = wnd.LayoutManager; - - lm.ExecuteInitialLayoutPass(); - - int dematerializedEventCallCount = 0; - target.ItemContainerGenerator.Dematerialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - dematerializedEventCallCount++; - }; - - int materializedEventCallCount = 0; - target.ItemContainerGenerator.Materialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item2", ((Item)e.Containers[0].Item).Value); - materializedEventCallCount++; - }; - - target.Items = new[] - { - new Item("Item2") - }; - - //assert that materialize/dematerialize events are called exactly one time - Assert.Equal(1, dematerializedEventCallCount); - Assert.Equal(1, materializedEventCallCount); - } - } - - [Fact] - public void ListBox_Items_Should_Be_In_Sync_When_Replacing_ItemTemplate() - { - using (UnitTestApplication.Start(TestServices.StyledWindow)) - { - var wnd = new Window() { Width = 100, Height = 100, IsVisible = true }; - - var target = new ListBox() - { - VerticalAlignment = Layout.VerticalAlignment.Top, - AutoScrollToSelectedItem = true, - Width = 50, - VirtualizationMode = ItemVirtualizationMode.Simple, - Items = new[] - { - new Item("Item1") - }, - ItemTemplate = - new FuncDataTemplate((x, ns) => new Canvas()) - }; - - wnd.Content = target; - - var lm = wnd.LayoutManager; - - lm.ExecuteInitialLayoutPass(); - - int dematerializedEventCallCount = 0; - target.ItemContainerGenerator.Dematerialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - Assert.IsType(((ListBoxItem)e.Containers[0].ContainerControl).Presenter.Child); - dematerializedEventCallCount++; - }; - - int materializedEventCallCount = 0; - ListBoxItem materializedListBoxItem = null; - target.ItemContainerGenerator.Materialized += (s, e) => - { - Assert.IsType(e.Containers[0].Item); - Assert.Equal("Item1", ((Item)e.Containers[0].Item).Value); - materializedListBoxItem = ((ListBoxItem)e.Containers[0].ContainerControl); - materializedEventCallCount++; - }; - - target.ItemTemplate = - new FuncDataTemplate((x, ns) => new TextBlock()); - - //ensure events are called only one time - Assert.Equal(1, dematerializedEventCallCount); - Assert.Equal(1, materializedEventCallCount); - - wnd.LayoutManager.ExecuteLayoutPass(); - - //ensure that new template has been applied - Assert.IsType(materializedListBoxItem.Presenter.Child); - } - } - private FuncControlTemplate ListBoxTemplate() { return new FuncControlTemplate((parent, scope) => From cc1051efa35342ba4ef095b987b3f583cfe550d8 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Mon, 16 Nov 2020 14:03:13 +0200 Subject: [PATCH 166/314] add failing test for set of base class property --- .../Xaml/XamlIlTests.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs index 67e46d25c3..77a4932ccc 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/XamlIlTests.cs @@ -295,8 +295,27 @@ namespace Avalonia.Markup.Xaml.UnitTests Assert.Equal("Test", templated.Text); } } + + [Fact] + public void Should_Work_With_Base_Property() + { + var parsed = (ListBox)AvaloniaRuntimeXamlLoader.Load(@" + + + + + + +"); + + Assert.NotNull(parsed.ItemTemplate); + } } - + public class XamlIlBugTestsEventHandlerCodeBehind : Window { public object SavedContext; From db96b4d39ee3733dcd55ead409c6df9a7314342f Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Mon, 16 Nov 2020 14:04:09 +0200 Subject: [PATCH 167/314] fix set of base class property in xaml fixes #1926 --- .../AvaloniaXamlIlTransformInstanceAttachedProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformInstanceAttachedProperties.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformInstanceAttachedProperties.cs index d78ceeb918..f87e73a783 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformInstanceAttachedProperties.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlTransformInstanceAttachedProperties.cs @@ -22,7 +22,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers var avaloniaObject = context.Configuration.TypeSystem.FindType("Avalonia.AvaloniaObject"); if (avaloniaObject.IsAssignableFrom(targetRef.Type) && avaloniaObject.IsAssignableFrom(declaringRef.Type) - && !targetRef.Type.IsAssignableFrom(declaringRef.Type)) + && !declaringRef.Type.IsAssignableFrom(targetRef.Type)) { // Instance property var clrProp = declaringRef.Type.GetAllProperties().FirstOrDefault(p => p.Name == prop.Name); From 1dfb76d993fed57ac3ac64da4bcc1af475639983 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 16 Nov 2020 19:43:24 +0300 Subject: [PATCH 168/314] Fixed COM calling convention for 32 bit windows --- src/Avalonia.MicroCom/MicroComVtblBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.MicroCom/MicroComVtblBase.cs b/src/Avalonia.MicroCom/MicroComVtblBase.cs index e06e2d4934..2f0607c0a8 100644 --- a/src/Avalonia.MicroCom/MicroComVtblBase.cs +++ b/src/Avalonia.MicroCom/MicroComVtblBase.cs @@ -7,10 +7,10 @@ namespace Avalonia.MicroCom public unsafe class MicroComVtblBase { private List _methods = new List(); - [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] private delegate int AddRefDelegate(Ccw* ccw); - [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall)] + [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)] private delegate int QueryInterfaceDelegate(Ccw* ccw, Guid* guid, void** ppv); public static IntPtr Vtable { get; } = new MicroComVtblBase().CreateVTable(); From 303b6c15866fb61ae2e17093ddf5e85acc670ffb Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 16 Nov 2020 23:25:13 +0300 Subject: [PATCH 169/314] Remove ReactiveUI usage from sample apps --- Avalonia.sln | 27 +++++ samples/BindingDemo/App.xaml.cs | 2 - samples/BindingDemo/BindingDemo.csproj | 3 +- .../ViewModels/ExceptionErrorViewModel.cs | 4 +- .../ViewModels/IndeiErrorViewModel.cs | 4 +- .../ViewModels/MainWindowViewModel.cs | 12 +- .../ViewModels/NestedCommandViewModel.cs | 8 +- samples/BindingDemo/ViewModels/TestItem.cs | 4 +- samples/ControlCatalog.Desktop/Program.cs | 4 +- samples/ControlCatalog.NetCore/Program.cs | 2 - samples/ControlCatalog/ControlCatalog.csproj | 2 +- .../ControlCatalog/Pages/LabelsPage.axaml.cs | 1 - samples/ControlCatalog/Pages/ListBoxPage.xaml | 2 +- samples/ControlCatalog/Pages/MenuPage.xaml.cs | 1 - .../Pages/NumericUpDownPage.xaml.cs | 4 +- .../Pages/ScrollViewerPage.xaml.cs | 4 +- .../Pages/TabControlPage.xaml.cs | 4 +- .../ViewModels/ContextMenuPageViewModel.cs | 14 +-- .../ViewModels/ItemsRepeaterPageViewModel.cs | 6 +- .../ViewModels/ListBoxPageViewModel.cs | 27 +++-- .../ViewModels/MainWindowViewModel.cs | 28 ++--- .../ViewModels/MenuPageViewModel.cs | 14 +-- .../ViewModels/NotificationViewModel.cs | 10 +- .../ViewModels/SplitViewPageViewModel.cs | 4 +- .../ViewModels/TreeViewPageViewModel.cs | 16 +-- samples/MiniMvvm/MiniCommand.cs | 66 +++++++++++ samples/MiniMvvm/MiniMvvm.csproj | 6 + samples/MiniMvvm/PropertyChangedExtensions.cs | 108 ++++++++++++++++++ samples/MiniMvvm/ViewModelBase.cs | 26 +++++ samples/Previewer/Previewer.csproj | 1 - samples/RenderDemo/App.xaml.cs | 2 - samples/RenderDemo/MainWindow.xaml.cs | 2 +- samples/RenderDemo/RenderDemo.csproj | 3 +- .../ViewModels/AnimationsPageViewModel.cs | 4 +- .../ViewModels/MainWindowViewModel.cs | 17 ++- samples/Sandbox/Program.cs | 2 - samples/Sandbox/Sandbox.csproj | 1 - samples/VirtualizationDemo/Program.cs | 2 - .../ViewModels/ItemViewModel.cs | 4 +- .../ViewModels/MainWindowViewModel.cs | 24 ++-- .../VirtualizationDemo.csproj | 3 +- .../Direct3DInteropSample.csproj | 2 +- .../MainWindowViewModel.cs | 4 +- .../WindowsInteropTest.csproj | 6 +- .../Avalonia.AndroidTestApplication.csproj | 4 - 45 files changed, 349 insertions(+), 145 deletions(-) create mode 100644 samples/MiniMvvm/MiniCommand.cs create mode 100644 samples/MiniMvvm/MiniMvvm.csproj create mode 100644 samples/MiniMvvm/PropertyChangedExtensions.cs create mode 100644 samples/MiniMvvm/ViewModelBase.cs diff --git a/Avalonia.sln b/Avalonia.sln index 74a2dbb94b..75f1dd8407 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -230,6 +230,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroComGenerator", "src\to EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.MicroCom", "src\Avalonia.MicroCom\Avalonia.MicroCom.csproj", "{FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniMvvm", "samples\MiniMvvm\MiniMvvm.csproj", "{BC594FD5-4AF2-409E-A1E6-04123F54D7C5}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 @@ -2116,6 +2118,30 @@ Global {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhone.Build.0 = Release|Any CPU {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {FE2F3E5E-1E34-4972-8DC1-5C2C588E5ECE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|iPhone.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|iPhone.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|Any CPU.Build.0 = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|iPhone.ActiveCfg = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|iPhone.Build.0 = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2176,6 +2202,7 @@ Global {909A8CBD-7D0E-42FD-B841-022AD8925820} = {8B6A8209-894F-4BA1-B880-965FD453982C} {11BE52AF-E2DD-4CF0-B19A-05285ACAF571} = {9B9E3891-2366-4253-A952-D08BCEB71098} {AEC9031E-06EA-4A9E-9E7F-7D7C719404DD} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} + {BC594FD5-4AF2-409E-A1E6-04123F54D7C5} = {9B9E3891-2366-4253-A952-D08BCEB71098} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/samples/BindingDemo/App.xaml.cs b/samples/BindingDemo/App.xaml.cs index eb2da03a7e..8a5364c70b 100644 --- a/samples/BindingDemo/App.xaml.cs +++ b/samples/BindingDemo/App.xaml.cs @@ -1,7 +1,6 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; -using Avalonia.ReactiveUI; namespace BindingDemo { @@ -25,7 +24,6 @@ namespace BindingDemo public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() - .UseReactiveUI() .LogToTrace(); } } diff --git a/samples/BindingDemo/BindingDemo.csproj b/samples/BindingDemo/BindingDemo.csproj index 817023fd71..d898b737a9 100644 --- a/samples/BindingDemo/BindingDemo.csproj +++ b/samples/BindingDemo/BindingDemo.csproj @@ -6,12 +6,11 @@ - + - diff --git a/samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs b/samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs index 0fe12a8ef7..7de083351e 100644 --- a/samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs +++ b/samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs @@ -1,9 +1,9 @@ -using ReactiveUI; +using MiniMvvm; using System; namespace BindingDemo.ViewModels { - public class ExceptionErrorViewModel : ReactiveObject + public class ExceptionErrorViewModel : ViewModelBase { private int _lessThan10; diff --git a/samples/BindingDemo/ViewModels/IndeiErrorViewModel.cs b/samples/BindingDemo/ViewModels/IndeiErrorViewModel.cs index caf75c846c..9ae8d9558f 100644 --- a/samples/BindingDemo/ViewModels/IndeiErrorViewModel.cs +++ b/samples/BindingDemo/ViewModels/IndeiErrorViewModel.cs @@ -1,11 +1,11 @@ -using ReactiveUI; +using MiniMvvm; using System; using System.ComponentModel; using System.Collections; namespace BindingDemo.ViewModels { - public class IndeiErrorViewModel : ReactiveObject, INotifyDataErrorInfo + public class IndeiErrorViewModel : ViewModelBase, INotifyDataErrorInfo { private int _maximum = 10; private int _value; diff --git a/samples/BindingDemo/ViewModels/MainWindowViewModel.cs b/samples/BindingDemo/ViewModels/MainWindowViewModel.cs index f0241cad48..18a7a01a69 100644 --- a/samples/BindingDemo/ViewModels/MainWindowViewModel.cs +++ b/samples/BindingDemo/ViewModels/MainWindowViewModel.cs @@ -5,14 +5,14 @@ using System.Reactive; using System.Reactive.Linq; using System.Threading.Tasks; using System.Threading; -using ReactiveUI; +using MiniMvvm; using Avalonia.Controls; using Avalonia.Metadata; using Avalonia.Controls.Selection; namespace BindingDemo.ViewModels { - public class MainWindowViewModel : ReactiveObject + public class MainWindowViewModel : ViewModelBase { private string _booleanString = "True"; private double _doubleValue = 5.0; @@ -32,13 +32,13 @@ namespace BindingDemo.ViewModels Selection = new SelectionModel { SingleSelect = false }; - ShuffleItems = ReactiveCommand.Create(() => + ShuffleItems = MiniCommand.Create(() => { var r = new Random(); Items.Move(r.Next(Items.Count), 1); }); - StringValueCommand = ReactiveCommand.Create(param => + StringValueCommand = MiniCommand.Create(param => { BooleanFlag = !BooleanFlag; StringValue = param.ToString(); @@ -60,7 +60,7 @@ namespace BindingDemo.ViewModels public ObservableCollection Items { get; } public SelectionModel Selection { get; } - public ReactiveCommand ShuffleItems { get; } + public MiniCommand ShuffleItems { get; } public string BooleanString { @@ -93,7 +93,7 @@ namespace BindingDemo.ViewModels } public IObservable CurrentTimeObservable { get; } - public ReactiveCommand StringValueCommand { get; } + public MiniCommand StringValueCommand { get; } public DataAnnotationsErrorViewModel DataAnnotationsValidation { get; } = new DataAnnotationsErrorViewModel(); public ExceptionErrorViewModel ExceptionDataValidation { get; } = new ExceptionErrorViewModel(); diff --git a/samples/BindingDemo/ViewModels/NestedCommandViewModel.cs b/samples/BindingDemo/ViewModels/NestedCommandViewModel.cs index 0e9139ab98..1c2222b0b0 100644 --- a/samples/BindingDemo/ViewModels/NestedCommandViewModel.cs +++ b/samples/BindingDemo/ViewModels/NestedCommandViewModel.cs @@ -1,18 +1,18 @@ -using ReactiveUI; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; +using MiniMvvm; namespace BindingDemo.ViewModels { - public class NestedCommandViewModel : ReactiveObject + public class NestedCommandViewModel : ViewModelBase { public NestedCommandViewModel() { - Command = ReactiveCommand.Create(() => { }); + Command = MiniCommand.Create(() => { }); } public ICommand Command { get; } diff --git a/samples/BindingDemo/ViewModels/TestItem.cs b/samples/BindingDemo/ViewModels/TestItem.cs index 5a9f192f58..2f49a3c99f 100644 --- a/samples/BindingDemo/ViewModels/TestItem.cs +++ b/samples/BindingDemo/ViewModels/TestItem.cs @@ -1,8 +1,8 @@ -using ReactiveUI; +using MiniMvvm; namespace BindingDemo.ViewModels { - public class TestItem : ReactiveObject + public class TestItem : ViewModelBase { private string _stringValue = "String Value"; private string _detail; diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index 5af646b180..7b8b27fff7 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -3,7 +3,6 @@ using System.Linq; using Avalonia; using Avalonia.Controls; using Avalonia.Platform; -using Avalonia.ReactiveUI; namespace ControlCatalog { @@ -19,8 +18,7 @@ namespace ControlCatalog public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .LogToTrace() - .UsePlatformDetect() - .UseReactiveUI(); + .UsePlatformDetect(); private static void ConfigureAssetAssembly(AppBuilder builder) { diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index 675ea2e10f..1dc8c09c0e 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -10,7 +10,6 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Dialogs; using Avalonia.Headless; using Avalonia.LogicalTree; -using Avalonia.ReactiveUI; using Avalonia.Threading; namespace ControlCatalog.NetCore @@ -118,7 +117,6 @@ namespace ControlCatalog.NetCore AllowEglInitialization = true }) .UseSkia() - .UseReactiveUI() .UseManagedSystemDialogs() .LogToTrace(); diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 8a88b89b48..1aa926a2a6 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -24,8 +24,8 @@ - + diff --git a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs index b8503d6ae6..a14978fd2c 100644 --- a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs +++ b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs @@ -2,7 +2,6 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; using ControlCatalog.Models; -using ReactiveUI; namespace ControlCatalog.Pages { diff --git a/samples/ControlCatalog/Pages/ListBoxPage.xaml b/samples/ControlCatalog/Pages/ListBoxPage.xaml index 3521ad71a9..f515db84d4 100644 --- a/samples/ControlCatalog/Pages/ListBoxPage.xaml +++ b/samples/ControlCatalog/Pages/ListBoxPage.xaml @@ -20,6 +20,6 @@ + SelectionMode="{Binding SelectionMode^}"/> diff --git a/samples/ControlCatalog/Pages/MenuPage.xaml.cs b/samples/ControlCatalog/Pages/MenuPage.xaml.cs index 46dbe3dcad..5999510b6c 100644 --- a/samples/ControlCatalog/Pages/MenuPage.xaml.cs +++ b/samples/ControlCatalog/Pages/MenuPage.xaml.cs @@ -6,7 +6,6 @@ using System.Windows.Input; using Avalonia.Controls; using Avalonia.Markup.Xaml; using ControlCatalog.ViewModels; -using ReactiveUI; namespace ControlCatalog.Pages { diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs index 92da64d87e..31749edf08 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs @@ -6,7 +6,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Markup.Xaml; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.Pages { @@ -26,7 +26,7 @@ namespace ControlCatalog.Pages } - public class NumbersPageViewModel : ReactiveObject + public class NumbersPageViewModel : ViewModelBase { private IList _formats; private FormatObject _selectedFormat; diff --git a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs index 36d3768b13..dcd7a88a56 100644 --- a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Markup.Xaml; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.Pages { - public class ScrollViewerPageViewModel : ReactiveObject + public class ScrollViewerPageViewModel : ViewModelBase { private bool _allowAutoHide; private ScrollBarVisibility _horizontalScrollVisibility; diff --git a/samples/ControlCatalog/Pages/TabControlPage.xaml.cs b/samples/ControlCatalog/Pages/TabControlPage.xaml.cs index a38a3ab4cb..f49b13091b 100644 --- a/samples/ControlCatalog/Pages/TabControlPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TabControlPage.xaml.cs @@ -6,7 +6,7 @@ using Avalonia.Markup.Xaml; using Avalonia.Media.Imaging; using Avalonia.Platform; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.Pages { @@ -56,7 +56,7 @@ namespace ControlCatalog.Pages return new Bitmap(assets.Open(new Uri(uri))); } - private class PageViewModel : ReactiveObject + private class PageViewModel : ViewModelBase { private Dock _tabPlacement; diff --git a/samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs b/samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs index 5c2f74d2d5..3f5d0cd93c 100644 --- a/samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs @@ -3,7 +3,7 @@ using System.Reactive; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.VisualTree; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { @@ -12,9 +12,9 @@ namespace ControlCatalog.ViewModels public Control View { get; set; } public ContextMenuPageViewModel() { - OpenCommand = ReactiveCommand.CreateFromTask(Open); - SaveCommand = ReactiveCommand.Create(Save); - OpenRecentCommand = ReactiveCommand.Create(OpenRecent); + OpenCommand = MiniCommand.CreateFromTask(Open); + SaveCommand = MiniCommand.Create(Save); + OpenRecentCommand = MiniCommand.Create(OpenRecent); MenuItems = new[] { @@ -44,9 +44,9 @@ namespace ControlCatalog.ViewModels } public IReadOnlyList MenuItems { get; set; } - public ReactiveCommand OpenCommand { get; } - public ReactiveCommand SaveCommand { get; } - public ReactiveCommand OpenRecentCommand { get; } + public MiniCommand OpenCommand { get; } + public MiniCommand SaveCommand { get; } + public MiniCommand OpenRecentCommand { get; } public async Task Open() { diff --git a/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs b/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs index f893a6e28e..ee1fa6ae77 100644 --- a/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs @@ -2,11 +2,11 @@ using System.Collections.ObjectModel; using System.Linq; using Avalonia.Media; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { - public class ItemsRepeaterPageViewModel : ReactiveObject + public class ItemsRepeaterPageViewModel : ViewModelBase { private int _newItemIndex = 1; private int _newGenerationIndex = 0; @@ -59,7 +59,7 @@ namespace ControlCatalog.ViewModels })); } - public class Item : ReactiveObject + public class Item : ViewModelBase { private double _height = double.NaN; diff --git a/samples/ControlCatalog/ViewModels/ListBoxPageViewModel.cs b/samples/ControlCatalog/ViewModels/ListBoxPageViewModel.cs index f75bc32105..7f2d6e9572 100644 --- a/samples/ControlCatalog/ViewModels/ListBoxPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/ListBoxPageViewModel.cs @@ -4,18 +4,18 @@ using System.Linq; using System.Reactive; using Avalonia.Controls; using Avalonia.Controls.Selection; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { - public class ListBoxPageViewModel : ReactiveObject + public class ListBoxPageViewModel : ViewModelBase { private bool _multiple; private bool _toggle; private bool _alwaysSelected; private bool _autoScrollToSelectedItem = true; private int _counter; - private ObservableAsPropertyHelper _selectionMode; + private IObservable _selectionMode; public ListBoxPageViewModel() { @@ -29,14 +29,13 @@ namespace ControlCatalog.ViewModels x => x.Toggle, x => x.AlwaysSelected, (m, t, a) => - (m ? SelectionMode.Multiple : 0) | - (t ? SelectionMode.Toggle : 0) | - (a ? SelectionMode.AlwaysSelected : 0)) - .ToProperty(this, x => x.SelectionMode); + (m ? Avalonia.Controls.SelectionMode.Multiple : 0) | + (t ? Avalonia.Controls.SelectionMode.Toggle : 0) | + (a ? Avalonia.Controls.SelectionMode.AlwaysSelected : 0)); - AddItemCommand = ReactiveCommand.Create(() => Items.Add(GenerateItem())); + AddItemCommand = MiniCommand.Create(() => Items.Add(GenerateItem())); - RemoveItemCommand = ReactiveCommand.Create(() => + RemoveItemCommand = MiniCommand.Create(() => { var items = Selection.SelectedItems.ToList(); @@ -46,7 +45,7 @@ namespace ControlCatalog.ViewModels } }); - SelectRandomItemCommand = ReactiveCommand.Create(() => + SelectRandomItemCommand = MiniCommand.Create(() => { var random = new Random(); @@ -60,7 +59,7 @@ namespace ControlCatalog.ViewModels public ObservableCollection Items { get; } public SelectionModel Selection { get; } - public SelectionMode SelectionMode => _selectionMode.Value; + public IObservable SelectionMode => _selectionMode; public bool Multiple { @@ -86,9 +85,9 @@ namespace ControlCatalog.ViewModels set => this.RaiseAndSetIfChanged(ref _autoScrollToSelectedItem, value); } - public ReactiveCommand AddItemCommand { get; } - public ReactiveCommand RemoveItemCommand { get; } - public ReactiveCommand SelectRandomItemCommand { get; } + public MiniCommand AddItemCommand { get; } + public MiniCommand RemoveItemCommand { get; } + public MiniCommand SelectRandomItemCommand { get; } private string GenerateItem() => $"Item {_counter++.ToString()}"; } diff --git a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs index 4356a032fa..4b3cfa9c9d 100644 --- a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs @@ -5,11 +5,11 @@ using Avalonia.Controls.Notifications; using Avalonia.Dialogs; using Avalonia.Platform; using System; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { - class MainWindowViewModel : ReactiveObject + class MainWindowViewModel : ViewModelBase { private IManagedNotificationManager _notificationManager; @@ -27,22 +27,22 @@ namespace ControlCatalog.ViewModels { _notificationManager = notificationManager; - ShowCustomManagedNotificationCommand = ReactiveCommand.Create(() => + ShowCustomManagedNotificationCommand = MiniCommand.Create(() => { NotificationManager.Show(new NotificationViewModel(NotificationManager) { Title = "Hey There!", Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" }); }); - ShowManagedNotificationCommand = ReactiveCommand.Create(() => + ShowManagedNotificationCommand = MiniCommand.Create(() => { NotificationManager.Show(new Avalonia.Controls.Notifications.Notification("Welcome", "Avalonia now supports Notifications.", NotificationType.Information)); }); - ShowNativeNotificationCommand = ReactiveCommand.Create(() => + ShowNativeNotificationCommand = MiniCommand.Create(() => { NotificationManager.Show(new Avalonia.Controls.Notifications.Notification("Error", "Native Notifications are not quite ready. Coming soon.", NotificationType.Error)); }); - AboutCommand = ReactiveCommand.CreateFromTask(async () => + AboutCommand = MiniCommand.CreateFromTask(async () => { var dialog = new AboutAvaloniaDialog(); @@ -51,12 +51,12 @@ namespace ControlCatalog.ViewModels await dialog.ShowDialog(mainWindow); }); - ExitCommand = ReactiveCommand.Create(() => + ExitCommand = MiniCommand.Create(() => { (App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).Shutdown(); }); - ToggleMenuItemCheckedCommand = ReactiveCommand.Create(() => + ToggleMenuItemCheckedCommand = MiniCommand.Create(() => { IsMenuItemChecked = !IsMenuItemChecked; }); @@ -153,16 +153,16 @@ namespace ControlCatalog.ViewModels set { this.RaiseAndSetIfChanged(ref _isMenuItemChecked, value); } } - public ReactiveCommand ShowCustomManagedNotificationCommand { get; } + public MiniCommand ShowCustomManagedNotificationCommand { get; } - public ReactiveCommand ShowManagedNotificationCommand { get; } + public MiniCommand ShowManagedNotificationCommand { get; } - public ReactiveCommand ShowNativeNotificationCommand { get; } + public MiniCommand ShowNativeNotificationCommand { get; } - public ReactiveCommand AboutCommand { get; } + public MiniCommand AboutCommand { get; } - public ReactiveCommand ExitCommand { get; } + public MiniCommand ExitCommand { get; } - public ReactiveCommand ToggleMenuItemCheckedCommand { get; } + public MiniCommand ToggleMenuItemCheckedCommand { get; } } } diff --git a/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs b/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs index 9e7ae8b716..ecbd59c5d7 100644 --- a/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs @@ -4,7 +4,7 @@ using System.Reactive.Linq; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.VisualTree; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { @@ -13,9 +13,9 @@ namespace ControlCatalog.ViewModels public Control View { get; set; } public MenuPageViewModel() { - OpenCommand = ReactiveCommand.CreateFromTask(Open); - SaveCommand = ReactiveCommand.Create(Save, Observable.Return(false)); - OpenRecentCommand = ReactiveCommand.Create(OpenRecent); + OpenCommand = MiniCommand.CreateFromTask(Open); + SaveCommand = MiniCommand.Create(Save); + OpenRecentCommand = MiniCommand.Create(OpenRecent); var recentItems = new[] { @@ -65,9 +65,9 @@ namespace ControlCatalog.ViewModels public IReadOnlyList MenuItems { get; set; } public IReadOnlyList RecentItems { get; set; } - public ReactiveCommand OpenCommand { get; } - public ReactiveCommand SaveCommand { get; } - public ReactiveCommand OpenRecentCommand { get; } + public MiniCommand OpenCommand { get; } + public MiniCommand SaveCommand { get; } + public MiniCommand OpenRecentCommand { get; } public async Task Open() { diff --git a/samples/ControlCatalog/ViewModels/NotificationViewModel.cs b/samples/ControlCatalog/ViewModels/NotificationViewModel.cs index 8724ba344b..2052481015 100644 --- a/samples/ControlCatalog/ViewModels/NotificationViewModel.cs +++ b/samples/ControlCatalog/ViewModels/NotificationViewModel.cs @@ -1,6 +1,6 @@ using System.Reactive; using Avalonia.Controls.Notifications; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { @@ -8,12 +8,12 @@ namespace ControlCatalog.ViewModels { public NotificationViewModel(INotificationManager manager) { - YesCommand = ReactiveCommand.Create(() => + YesCommand = MiniCommand.Create(() => { manager.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today.")); }); - NoCommand = ReactiveCommand.Create(() => + NoCommand = MiniCommand.Create(() => { manager.Show(new Avalonia.Controls.Notifications.Notification("Avalonia Notifications", "Start adding notifications to your app today. To find out more visit...")); }); @@ -22,9 +22,9 @@ namespace ControlCatalog.ViewModels public string Title { get; set; } public string Message { get; set; } - public ReactiveCommand YesCommand { get; } + public MiniCommand YesCommand { get; } - public ReactiveCommand NoCommand { get; } + public MiniCommand NoCommand { get; } } } diff --git a/samples/ControlCatalog/ViewModels/SplitViewPageViewModel.cs b/samples/ControlCatalog/ViewModels/SplitViewPageViewModel.cs index f27f605a8b..9e6932bb76 100644 --- a/samples/ControlCatalog/ViewModels/SplitViewPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/SplitViewPageViewModel.cs @@ -1,10 +1,10 @@ using System; using Avalonia.Controls; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { - public class SplitViewPageViewModel : ReactiveObject + public class SplitViewPageViewModel : ViewModelBase { private bool _isLeft = true; private int _displayMode = 3; //CompactOverlay diff --git a/samples/ControlCatalog/ViewModels/TreeViewPageViewModel.cs b/samples/ControlCatalog/ViewModels/TreeViewPageViewModel.cs index 210e281ed6..c03379330f 100644 --- a/samples/ControlCatalog/ViewModels/TreeViewPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/TreeViewPageViewModel.cs @@ -3,11 +3,11 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reactive; using Avalonia.Controls; -using ReactiveUI; +using MiniMvvm; namespace ControlCatalog.ViewModels { - public class TreeViewPageViewModel : ReactiveObject + public class TreeViewPageViewModel : ViewModelBase { private readonly Node _root; private SelectionMode _selectionMode; @@ -19,16 +19,16 @@ namespace ControlCatalog.ViewModels Items = _root.Children; SelectedItems = new ObservableCollection(); - AddItemCommand = ReactiveCommand.Create(AddItem); - RemoveItemCommand = ReactiveCommand.Create(RemoveItem); - SelectRandomItemCommand = ReactiveCommand.Create(SelectRandomItem); + AddItemCommand = MiniCommand.Create(AddItem); + RemoveItemCommand = MiniCommand.Create(RemoveItem); + SelectRandomItemCommand = MiniCommand.Create(SelectRandomItem); } public ObservableCollection Items { get; } public ObservableCollection SelectedItems { get; } - public ReactiveCommand AddItemCommand { get; } - public ReactiveCommand RemoveItemCommand { get; } - public ReactiveCommand SelectRandomItemCommand { get; } + public MiniCommand AddItemCommand { get; } + public MiniCommand RemoveItemCommand { get; } + public MiniCommand SelectRandomItemCommand { get; } public SelectionMode SelectionMode { diff --git a/samples/MiniMvvm/MiniCommand.cs b/samples/MiniMvvm/MiniCommand.cs new file mode 100644 index 0000000000..c6a9273c20 --- /dev/null +++ b/samples/MiniMvvm/MiniCommand.cs @@ -0,0 +1,66 @@ +using System; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace MiniMvvm +{ + public sealed class MiniCommand : MiniCommand, ICommand + { + private readonly Action _cb; + private bool _busy; + private Func _acb; + + public MiniCommand(Action cb) + { + _cb = cb; + } + + public MiniCommand(Func cb) + { + _acb = cb; + } + + private bool Busy + { + get => _busy; + set + { + _busy = value; + CanExecuteChanged?.Invoke(this, EventArgs.Empty); + } + } + + + public override event EventHandler CanExecuteChanged; + public override bool CanExecute(object parameter) => !_busy; + + public override async void Execute(object parameter) + { + if(Busy) + return; + try + { + Busy = true; + if (_cb != null) + _cb((T)parameter); + else + await _acb((T)parameter); + } + finally + { + Busy = false; + } + } + } + + public abstract class MiniCommand : ICommand + { + public static MiniCommand Create(Action cb) => new MiniCommand(_ => cb()); + public static MiniCommand Create(Action cb) => new MiniCommand(cb); + public static MiniCommand CreateFromTask(Func cb) => new MiniCommand(_ => cb()); + + public abstract bool CanExecute(object parameter); + public abstract void Execute(object parameter); + public abstract event EventHandler CanExecuteChanged; + } +} diff --git a/samples/MiniMvvm/MiniMvvm.csproj b/samples/MiniMvvm/MiniMvvm.csproj new file mode 100644 index 0000000000..6535b2bdbd --- /dev/null +++ b/samples/MiniMvvm/MiniMvvm.csproj @@ -0,0 +1,6 @@ + + + netstandard2.0 + + + diff --git a/samples/MiniMvvm/PropertyChangedExtensions.cs b/samples/MiniMvvm/PropertyChangedExtensions.cs new file mode 100644 index 0000000000..f1065c7530 --- /dev/null +++ b/samples/MiniMvvm/PropertyChangedExtensions.cs @@ -0,0 +1,108 @@ +using System; +using System.ComponentModel; +using System.Linq.Expressions; +using System.Reactive.Linq; +using System.Reflection; + +namespace MiniMvvm +{ + public static class PropertyChangedExtensions + { + class PropertyObservable : IObservable + { + private readonly INotifyPropertyChanged _target; + private readonly PropertyInfo _info; + + public PropertyObservable(INotifyPropertyChanged target, PropertyInfo info) + { + _target = target; + _info = info; + } + + class Subscription : IDisposable + { + private readonly INotifyPropertyChanged _target; + private readonly PropertyInfo _info; + private readonly IObserver _observer; + + public Subscription(INotifyPropertyChanged target, PropertyInfo info, IObserver observer) + { + _target = target; + _info = info; + _observer = observer; + _target.PropertyChanged += OnPropertyChanged; + _observer.OnNext((T)_info.GetValue(_target)); + } + + private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == _info.Name) + _observer.OnNext((T)_info.GetValue(_target)); + } + + public void Dispose() + { + _target.PropertyChanged -= OnPropertyChanged; + _observer.OnCompleted(); + } + } + + public IDisposable Subscribe(IObserver observer) + { + return new Subscription(_target, _info, observer); + } + } + + public static IObservable WhenAnyValue(this TModel model, + Expression> expr) where TModel : INotifyPropertyChanged + { + var l = (LambdaExpression)expr; + var ma = (MemberExpression)l.Body; + var prop = (PropertyInfo)ma.Member; + return new PropertyObservable(model, prop); + } + + public static IObservable WhenAnyValue(this TModel model, + Expression> v1, + Func cb + ) where TModel : INotifyPropertyChanged + { + return model.WhenAnyValue(v1).Select(cb); + } + + public static IObservable WhenAnyValue(this TModel model, + Expression> v1, + Expression> v2, + Func cb + ) where TModel : INotifyPropertyChanged => + Observable.CombineLatest( + model.WhenAnyValue(v1), + model.WhenAnyValue(v2), + cb); + + public static IObservable> WhenAnyValue(this TModel model, + Expression> v1, + Expression> v2 + ) where TModel : INotifyPropertyChanged => + model.WhenAnyValue(v1, v2, (a1, a2) => (a1, a2)); + + public static IObservable WhenAnyValue(this TModel model, + Expression> v1, + Expression> v2, + Expression> v3, + Func cb + ) where TModel : INotifyPropertyChanged => + Observable.CombineLatest( + model.WhenAnyValue(v1), + model.WhenAnyValue(v2), + model.WhenAnyValue(v3), + cb); + + public static IObservable> WhenAnyValue(this TModel model, + Expression> v1, + Expression> v2, + Expression> v3 + ) where TModel : INotifyPropertyChanged => + model.WhenAnyValue(v1, v2, v3, (a1, a2, a3) => (a1, a2, a3)); + } +} diff --git a/samples/MiniMvvm/ViewModelBase.cs b/samples/MiniMvvm/ViewModelBase.cs new file mode 100644 index 0000000000..7256b05cef --- /dev/null +++ b/samples/MiniMvvm/ViewModelBase.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.ComponentModel; +using System.Reactive.Joins; +using System.Runtime.CompilerServices; + +namespace MiniMvvm +{ + public class ViewModelBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected bool RaiseAndSetIfChanged(ref T field, T value, [CallerMemberName] string propertyName = null) + { + if (!EqualityComparer.Default.Equals(field, value)) + { + field = value; + RaisePropertyChanged(propertyName); + return true; + } + return false; + } + + + protected void RaisePropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} diff --git a/samples/Previewer/Previewer.csproj b/samples/Previewer/Previewer.csproj index cd3daf61e1..cfedb7ad9e 100644 --- a/samples/Previewer/Previewer.csproj +++ b/samples/Previewer/Previewer.csproj @@ -8,7 +8,6 @@ %(Filename) - diff --git a/samples/RenderDemo/App.xaml.cs b/samples/RenderDemo/App.xaml.cs index e6ec963d75..8054b06964 100644 --- a/samples/RenderDemo/App.xaml.cs +++ b/samples/RenderDemo/App.xaml.cs @@ -1,7 +1,6 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; -using Avalonia.ReactiveUI; namespace RenderDemo { @@ -32,7 +31,6 @@ namespace RenderDemo OverlayPopups = true, }) .UsePlatformDetect() - .UseReactiveUI() .LogToTrace(); } } diff --git a/samples/RenderDemo/MainWindow.xaml.cs b/samples/RenderDemo/MainWindow.xaml.cs index b45a605e04..877eb8016a 100644 --- a/samples/RenderDemo/MainWindow.xaml.cs +++ b/samples/RenderDemo/MainWindow.xaml.cs @@ -3,7 +3,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; using RenderDemo.ViewModels; -using ReactiveUI; +using MiniMvvm; namespace RenderDemo { diff --git a/samples/RenderDemo/RenderDemo.csproj b/samples/RenderDemo/RenderDemo.csproj index d1654f4b54..0d33b4c111 100644 --- a/samples/RenderDemo/RenderDemo.csproj +++ b/samples/RenderDemo/RenderDemo.csproj @@ -9,12 +9,11 @@ - + - diff --git a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs index 7b89b7944c..f8ba01f3d1 100644 --- a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs +++ b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs @@ -1,10 +1,10 @@ using System; -using ReactiveUI; +using MiniMvvm; using Avalonia.Animation; namespace RenderDemo.ViewModels { - public class AnimationsPageViewModel : ReactiveObject + public class AnimationsPageViewModel : ViewModelBase { private bool _isPlaying = true; diff --git a/samples/RenderDemo/ViewModels/MainWindowViewModel.cs b/samples/RenderDemo/ViewModels/MainWindowViewModel.cs index eda5e80530..19917c20df 100644 --- a/samples/RenderDemo/ViewModels/MainWindowViewModel.cs +++ b/samples/RenderDemo/ViewModels/MainWindowViewModel.cs @@ -1,11 +1,10 @@ using System.Reactive; using System.Threading.Tasks; - -using ReactiveUI; +using MiniMvvm; namespace RenderDemo.ViewModels { - public class MainWindowViewModel : ReactiveObject + public class MainWindowViewModel : ViewModelBase { private bool drawDirtyRects = false; private bool drawFps = true; @@ -14,9 +13,9 @@ namespace RenderDemo.ViewModels public MainWindowViewModel() { - ToggleDrawDirtyRects = ReactiveCommand.Create(() => DrawDirtyRects = !DrawDirtyRects); - ToggleDrawFps = ReactiveCommand.Create(() => DrawFps = !DrawFps); - ResizeWindow = ReactiveCommand.CreateFromTask(ResizeWindowAsync); + ToggleDrawDirtyRects = MiniCommand.Create(() => DrawDirtyRects = !DrawDirtyRects); + ToggleDrawFps = MiniCommand.Create(() => DrawFps = !DrawFps); + ResizeWindow = MiniCommand.CreateFromTask(ResizeWindowAsync); } public bool DrawDirtyRects @@ -43,9 +42,9 @@ namespace RenderDemo.ViewModels set => this.RaiseAndSetIfChanged(ref height, value); } - public ReactiveCommand ToggleDrawDirtyRects { get; } - public ReactiveCommand ToggleDrawFps { get; } - public ReactiveCommand ResizeWindow { get; } + public MiniCommand ToggleDrawDirtyRects { get; } + public MiniCommand ToggleDrawFps { get; } + public MiniCommand ResizeWindow { get; } private async Task ResizeWindowAsync() { diff --git a/samples/Sandbox/Program.cs b/samples/Sandbox/Program.cs index 7d41a8b8c0..1e74105196 100644 --- a/samples/Sandbox/Program.cs +++ b/samples/Sandbox/Program.cs @@ -1,5 +1,4 @@ using Avalonia; -using Avalonia.ReactiveUI; namespace Sandbox { @@ -9,7 +8,6 @@ namespace Sandbox { AppBuilder.Configure() .UsePlatformDetect() - .UseReactiveUI() .LogToTrace() .StartWithClassicDesktopLifetime(args); } diff --git a/samples/Sandbox/Sandbox.csproj b/samples/Sandbox/Sandbox.csproj index 1a0a8a7ce5..0c19440a1e 100644 --- a/samples/Sandbox/Sandbox.csproj +++ b/samples/Sandbox/Sandbox.csproj @@ -8,7 +8,6 @@ - diff --git a/samples/VirtualizationDemo/Program.cs b/samples/VirtualizationDemo/Program.cs index 46c05f74b2..febda46450 100644 --- a/samples/VirtualizationDemo/Program.cs +++ b/samples/VirtualizationDemo/Program.cs @@ -1,5 +1,4 @@ using Avalonia; -using Avalonia.ReactiveUI; namespace VirtualizationDemo { @@ -8,7 +7,6 @@ namespace VirtualizationDemo public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() - .UseReactiveUI() .LogToTrace(); public static int Main(string[] args) diff --git a/samples/VirtualizationDemo/ViewModels/ItemViewModel.cs b/samples/VirtualizationDemo/ViewModels/ItemViewModel.cs index cf34980b40..9ba505ffe5 100644 --- a/samples/VirtualizationDemo/ViewModels/ItemViewModel.cs +++ b/samples/VirtualizationDemo/ViewModels/ItemViewModel.cs @@ -1,9 +1,9 @@ using System; -using ReactiveUI; +using MiniMvvm; namespace VirtualizationDemo.ViewModels { - internal class ItemViewModel : ReactiveObject + internal class ItemViewModel : ViewModelBase { private string _prefix; private int _index; diff --git a/samples/VirtualizationDemo/ViewModels/MainWindowViewModel.cs b/samples/VirtualizationDemo/ViewModels/MainWindowViewModel.cs index 852c01399f..514df691ae 100644 --- a/samples/VirtualizationDemo/ViewModels/MainWindowViewModel.cs +++ b/samples/VirtualizationDemo/ViewModels/MainWindowViewModel.cs @@ -5,13 +5,13 @@ using System.Reactive; using Avalonia.Collections; using Avalonia.Controls; using Avalonia.Controls.Primitives; -using ReactiveUI; using Avalonia.Layout; using Avalonia.Controls.Selection; +using MiniMvvm; namespace VirtualizationDemo.ViewModels { - internal class MainWindowViewModel : ReactiveObject + internal class MainWindowViewModel : ViewModelBase { private int _itemCount = 200; private string _newItemString = "New Item"; @@ -26,15 +26,15 @@ namespace VirtualizationDemo.ViewModels public MainWindowViewModel() { this.WhenAnyValue(x => x.ItemCount).Subscribe(ResizeItems); - RecreateCommand = ReactiveCommand.Create(() => Recreate()); + RecreateCommand = MiniCommand.Create(() => Recreate()); - AddItemCommand = ReactiveCommand.Create(() => AddItem()); + AddItemCommand = MiniCommand.Create(() => AddItem()); - RemoveItemCommand = ReactiveCommand.Create(() => Remove()); + RemoveItemCommand = MiniCommand.Create(() => Remove()); - SelectFirstCommand = ReactiveCommand.Create(() => SelectItem(0)); + SelectFirstCommand = MiniCommand.Create(() => SelectItem(0)); - SelectLastCommand = ReactiveCommand.Create(() => SelectItem(Items.Count - 1)); + SelectLastCommand = MiniCommand.Create(() => SelectItem(Items.Count - 1)); } public string NewItemString @@ -90,11 +90,11 @@ namespace VirtualizationDemo.ViewModels public IEnumerable VirtualizationModes => Enum.GetValues(typeof(ItemVirtualizationMode)).Cast(); - public ReactiveCommand AddItemCommand { get; private set; } - public ReactiveCommand RecreateCommand { get; private set; } - public ReactiveCommand RemoveItemCommand { get; private set; } - public ReactiveCommand SelectFirstCommand { get; private set; } - public ReactiveCommand SelectLastCommand { get; private set; } + public MiniCommand AddItemCommand { get; private set; } + public MiniCommand RecreateCommand { get; private set; } + public MiniCommand RemoveItemCommand { get; private set; } + public MiniCommand SelectFirstCommand { get; private set; } + public MiniCommand SelectLastCommand { get; private set; } public void RandomizeSize() { diff --git a/samples/VirtualizationDemo/VirtualizationDemo.csproj b/samples/VirtualizationDemo/VirtualizationDemo.csproj index 817023fd71..d898b737a9 100644 --- a/samples/VirtualizationDemo/VirtualizationDemo.csproj +++ b/samples/VirtualizationDemo/VirtualizationDemo.csproj @@ -6,12 +6,11 @@ - + - diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj index bd6b6f170f..cd9963a2e5 100644 --- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj +++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj @@ -22,9 +22,9 @@ - + diff --git a/samples/interop/Direct3DInteropSample/MainWindowViewModel.cs b/samples/interop/Direct3DInteropSample/MainWindowViewModel.cs index d39a21cd07..21679a99c5 100644 --- a/samples/interop/Direct3DInteropSample/MainWindowViewModel.cs +++ b/samples/interop/Direct3DInteropSample/MainWindowViewModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using ReactiveUI; +using MiniMvvm; namespace Direct3DInteropSample { - public class MainWindowViewModel : ReactiveObject + public class MainWindowViewModel : ViewModelBase { private double _rotationX; diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj index c067d38595..8394d7cb13 100644 --- a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -136,10 +136,6 @@ {42472427-4774-4c81-8aff-9f27b8e31721} Avalonia.Layout - - {6417b24e-49c2-4985-8db2-3ab9d898ec91} - Avalonia.ReactiveUI - {eb582467-6abb-43a1-b052-e981ba910e3a} Avalonia.Visuals @@ -190,4 +186,4 @@ - \ No newline at end of file + diff --git a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj index b8697e0ca2..f880e48282 100644 --- a/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj +++ b/src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj @@ -127,10 +127,6 @@ {42472427-4774-4c81-8aff-9f27b8e31721} Avalonia.Layout - - {6417b24e-49c2-4985-8db2-3ab9d898ec91} - Avalonia.ReactiveUI - {eb582467-6abb-43a1-b052-e981ba910e3a} Avalonia.Visuals From be8a3e83fa9fd50c29e12c33af4951c05105f231 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 16 Nov 2020 21:12:46 +0000 Subject: [PATCH 170/314] fix OSX NRE. --- src/Avalonia.Native/WindowImplBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 20b6b8ecc5..150ab2703e 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -174,7 +174,7 @@ namespace Avalonia.Native void IAvnWindowBaseEvents.Resized(AvnSize* size) { - if (_parent._native != null) + if (_parent?._native != null) { var s = new Size(size->Width, size->Height); _parent._savedLogicalSize = s; From c24f65a5f78cbe0dd11d926d28ea8d8a198d90a0 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 16 Nov 2020 22:51:18 +0100 Subject: [PATCH 171/314] Fix even more broken cases for closing child/dialog windows on win32. --- .../ControlCatalog/Pages/DialogsPage.xaml.cs | 29 +++++++++++++--- .../Avalonia.Win32/WindowImpl.AppWndProc.cs | 19 ++--------- src/Windows/Avalonia.Win32/WindowImpl.cs | 34 +++++++++++++++++++ 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs index cf6c771e34..49921fb7f6 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using Avalonia.Controls; using Avalonia.Dialogs; +using Avalonia.Layout; using Avalonia.Markup.Xaml; #pragma warning disable 4014 @@ -112,11 +113,29 @@ namespace ControlCatalog.Pages private Window CreateSampleWindow() { - var window = new Window(); - window.Height = 200; - window.Width = 200; - window.Content = new TextBlock { Text = "Hello world!" }; - window.WindowStartupLocation = WindowStartupLocation.CenterOwner; + Button button; + + var window = new Window + { + Height = 200, + Width = 200, + Content = new StackPanel + { + Spacing = 4, + Children = + { + new TextBlock { Text = "Hello world!" }, + (button = new Button + { + HorizontalAlignment = HorizontalAlignment.Center, + Content = "Click to close" + }) + } + }, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; + + button.Click += (_, __) => window.Close(); return window; } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs index d770f4b211..78de681403 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs @@ -65,23 +65,10 @@ namespace Avalonia.Win32 return IntPtr.Zero; } - // Based on https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs#L4270-L4337 - // We need to enable parent window before destroying child window to prevent OS from activating a random window behind us. - // This is described here: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enablewindow#remarks - // Our window closed callback will set enabled state to a correct value after child window gets destroyed. - // We need to verify if parent is still alive (perhaps it got destroyed somehow). - if (_parent != null && IsWindow(_parent._hwnd)) - { - var wasActive = GetActiveWindow() == _hwnd; - - _parent.SetEnabled(true); + BeforeCloseCleanup(false); - // We also need to activate our parent window since again OS might try to activate a window behind if it is not set. - if (wasActive) - { - SetActiveWindow(_parent._hwnd); - } - } + // Used to distinguish between programmatic and regular close requests. + _isCloseRequested = true; break; } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index c603128a18..2483356e9a 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -83,6 +83,7 @@ namespace Avalonia.Win32 private POINT _maxTrackSize; private WindowImpl _parent; private ExtendClientAreaChromeHints _extendChromeHints = ExtendClientAreaChromeHints.Default; + private bool _isCloseRequested; public WindowImpl() { @@ -506,6 +507,13 @@ namespace Avalonia.Win32 if (_hwnd != IntPtr.Zero) { + // Detect if we are being closed programmatically - this would mean that WM_CLOSE was not called + // and we didn't prepare this window for destruction. + if (!_isCloseRequested) + { + BeforeCloseCleanup(true); + } + DestroyWindow(_hwnd); _hwnd = IntPtr.Zero; } @@ -948,6 +956,32 @@ namespace Avalonia.Win32 SetFocus(_hwnd); } } + + private void BeforeCloseCleanup(bool isDisposing) + { + // Based on https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs#L4270-L4337 + // We need to enable parent window before destroying child window to prevent OS from activating a random window behind us (or last active window). + // This is described here: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enablewindow#remarks + // We need to verify if parent is still alive (perhaps it got destroyed somehow). + if (_parent != null && IsWindow(_parent._hwnd)) + { + var wasActive = GetActiveWindow() == _hwnd; + + // We can only set enabled state if we are not disposing - generally Dispose happens after enabled state has been set. + // Ignoring this would cause us to enable a window that might be disabled. + if (!isDisposing) + { + // Our window closed callback will set enabled state to a correct value after child window gets destroyed. + _parent.SetEnabled(true); + } + + // We also need to activate our parent window since again OS might try to activate a window behind if it is not set. + if (wasActive) + { + SetActiveWindow(_parent._hwnd); + } + } + } private void MaximizeWithoutCoveringTaskbar() { From 1428badc6b17c1922151d31af42d34d9d875ae97 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 17 Nov 2020 01:46:22 +0300 Subject: [PATCH 172/314] Fixed CPP header codegen --- src/tools/MicroComGenerator/CppGen.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/MicroComGenerator/CppGen.cs b/src/tools/MicroComGenerator/CppGen.cs index 68192ebffe..b053088ca9 100644 --- a/src/tools/MicroComGenerator/CppGen.cs +++ b/src/tools/MicroComGenerator/CppGen.cs @@ -14,7 +14,10 @@ namespace MicroComGenerator name = "unsigned char"; else if(name == "uint") name = "unsigned int"; - return name + new string('*', type.PointerLevel); + + type = type.Clone(); + type.Name = name; + return type.Format(); } public static string GenerateCpp(AstIdlNode idl) From 91791c7d15db039be527936375cef79278d59732 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 17 Nov 2020 07:54:16 +0800 Subject: [PATCH 173/314] Implement RadiusX/Y and center, just like in WPF. --- src/Avalonia.Visuals/Media/EllipseGeometry.cs | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Visuals/Media/EllipseGeometry.cs b/src/Avalonia.Visuals/Media/EllipseGeometry.cs index fd73eee69a..bae6dc3d8c 100644 --- a/src/Avalonia.Visuals/Media/EllipseGeometry.cs +++ b/src/Avalonia.Visuals/Media/EllipseGeometry.cs @@ -12,10 +12,28 @@ namespace Avalonia.Media /// public static readonly StyledProperty RectProperty = AvaloniaProperty.Register(nameof(Rect)); + + /// + /// Defines the property. + /// + public static readonly StyledProperty RadiusXProperty = + AvaloniaProperty.Register(nameof(RadiusX)); + + /// + /// Defines the property. + /// + public static readonly StyledProperty RadiusYProperty = + AvaloniaProperty.Register(nameof(RadiusY)); + + /// + /// Defines the property. + /// + public static readonly StyledProperty CenterProperty = + AvaloniaProperty.Register(nameof(Center)); static EllipseGeometry() { - AffectsGeometry(RectProperty); + AffectsGeometry(RectProperty, RadiusXProperty, RadiusYProperty, CenterProperty); } /// @@ -43,6 +61,33 @@ namespace Avalonia.Media set => SetValue(RectProperty, value); } + /// + /// Gets or sets a double that defines the radius in the X-axis of the ellipse. + /// + public double RadiusX + { + get => GetValue(RadiusXProperty); + set => SetValue(RadiusXProperty, value); + } + + /// + /// Gets or sets a double that defines the radius in the Y-axis of the ellipse. + /// + public double RadiusY + { + get => GetValue(RadiusYProperty); + set => SetValue(RadiusYProperty, value); + } + + /// + /// Gets or sets a point that defines the center of the ellipse. + /// + public Point Center + { + get => GetValue(CenterProperty); + set => SetValue(CenterProperty, value); + } + /// public override Geometry Clone() { @@ -54,7 +99,14 @@ namespace Avalonia.Media { var factory = AvaloniaLocator.Current.GetService(); - return factory.CreateEllipseGeometry(Rect); + if (Rect != default) return factory.CreateEllipseGeometry(Rect); + + var originX = Center.X - RadiusX; + var originY = Center.Y - RadiusY; + var width = RadiusX * 2; + var height = RadiusY * 2; + + return factory.CreateEllipseGeometry(new Rect(originX, originY, width, height)); } } } From e90a5d285c7bebf478a97b4c357681a049702250 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 17 Nov 2020 16:54:08 +0800 Subject: [PATCH 174/314] add change listener on static ctor --- src/Avalonia.Visuals/Media/PathFigure.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index ff63a6286c..a9e3c6d628 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -38,11 +38,14 @@ namespace Avalonia.Media /// Initializes a new instance of the class. /// public PathFigure() + { + Segments = new PathSegments(); + } + + static PathFigure() { SegmentsProperty.Changed.AddClassHandler((s, e) => s.OnSegmentsChanged(e.NewValue as PathSegments)); - - Segments = new PathSegments(); } private void OnSegmentsChanged(PathSegments? arg2NewValue) From 7df1d2ad4d07f30fe41aaf8e477c1be8832f7de4 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 17 Nov 2020 16:58:53 +0800 Subject: [PATCH 175/314] add test, thanks @donandren ! :D --- .../Media/PathSegmentTests.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/Avalonia.Visuals.UnitTests/Media/PathSegmentTests.cs diff --git a/tests/Avalonia.Visuals.UnitTests/Media/PathSegmentTests.cs b/tests/Avalonia.Visuals.UnitTests/Media/PathSegmentTests.cs new file mode 100644 index 0000000000..0737b4dc88 --- /dev/null +++ b/tests/Avalonia.Visuals.UnitTests/Media/PathSegmentTests.cs @@ -0,0 +1,34 @@ +using Avalonia.Media; +using Xunit; + +namespace Avalonia.Visuals.UnitTests.Media +{ + public class PathSegmentTests + { + [Fact] + public void PathSegment_Triggers_Invalidation_On_Property_Change() + { + var targetSegment = new ArcSegment() + { + Size = new Size(10, 10), + Point = new Point(5, 5) + }; + + var target = new PathGeometry + { + Figures = new PathFigures + { + new PathFigure { IsClosed = false, Segments = new PathSegments { targetSegment } } + } + }; + + var changed = false; + + target.Changed += (s, e) => changed = true; + + targetSegment.Size = new Size(20, 20); + + Assert.True(changed); + } + } +} From 4e180c88cdb5f4e22e177f41a83010165e7836fb Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 17 Nov 2020 16:59:43 +0800 Subject: [PATCH 176/314] remove old test --- .../Avalonia.RenderTests/Shapes/PathTests.cs | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/tests/Avalonia.RenderTests/Shapes/PathTests.cs b/tests/Avalonia.RenderTests/Shapes/PathTests.cs index 24e420d972..bac16cca88 100644 --- a/tests/Avalonia.RenderTests/Shapes/PathTests.cs +++ b/tests/Avalonia.RenderTests/Shapes/PathTests.cs @@ -353,47 +353,7 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes await RenderToFile(target); CompareImages(); } - - [Fact] - public async Task PathSegment_Triggers_Invalidation_On_Property_Change() - { - var targetSegment = new ArcSegment() - { - Size = new Size(10,10), - Point = new Point(5,5) - }; - - var targetPath = new Path - { - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Center, - Fill = Brushes.Red, - Data = new PathGeometry - { - Figures = new PathFigures - { - new PathFigure { IsClosed = false, Segments = new PathSegments { targetSegment } } - } - } - }; - - var root = new Border - { - Width = 100, - Height = 100, - Background = Brushes.White, - Child =targetPath - }; - - Assert.Equal(10, targetPath.Bounds.Height); - Assert.Equal(10, targetPath.Bounds.Width); - - targetSegment.Size = new Size(20, 20); - Assert.Equal(20, targetPath.Bounds.Height); - Assert.Equal(20, targetPath.Bounds.Width); - } - [Fact] public async Task Path_With_Rotated_Geometry() { From ea90f05f83bea42dd47892f76d5de5012ff6afba Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 17 Nov 2020 14:34:44 +0100 Subject: [PATCH 177/314] Added Window.ShowActive for win32. --- .../Platform/IWindowBaseImpl.cs | 4 ++-- src/Avalonia.Controls/Window.cs | 20 ++++++++++++++++--- src/Avalonia.Controls/WindowBase.cs | 2 +- .../Remote/PreviewerWindowImpl.cs | 2 +- src/Avalonia.DesignerSupport/Remote/Stubs.cs | 2 +- src/Avalonia.Headless/HeadlessWindowImpl.cs | 7 ++++--- src/Avalonia.X11/X11Window.cs | 2 +- src/Windows/Avalonia.Win32/PopupImpl.cs | 3 ++- src/Windows/Avalonia.Win32/Win32Platform.cs | 2 +- src/Windows/Avalonia.Win32/WindowImpl.cs | 14 +++++++------ .../ContextMenuTests.cs | 16 +++++++-------- .../WindowBaseTests.cs | 2 +- .../MockWindowingPlatform.cs | 2 +- 13 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/Avalonia.Controls/Platform/IWindowBaseImpl.cs b/src/Avalonia.Controls/Platform/IWindowBaseImpl.cs index ecaf87d1ed..0d303a6666 100644 --- a/src/Avalonia.Controls/Platform/IWindowBaseImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowBaseImpl.cs @@ -5,9 +5,9 @@ namespace Avalonia.Platform public interface IWindowBaseImpl : ITopLevelImpl { /// - /// Shows the top level. + /// Shows the window. /// - void Show(); + void Show(bool activate); /// /// Hides the window. diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 54574a7e1c..ab99cfad17 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -129,6 +129,12 @@ namespace Avalonia.Controls public static readonly StyledProperty SystemDecorationsProperty = AvaloniaProperty.Register(nameof(SystemDecorations), SystemDecorations.Full); + /// + /// Defines the property. + /// + public static readonly StyledProperty ShowActivatedProperty = + AvaloniaProperty.Register(nameof(ShowActivated), true); + /// /// Enables or disables the taskbar icon /// @@ -352,13 +358,21 @@ namespace Avalonia.Controls /// /// Sets the system decorations (title bar, border, etc) /// - /// public SystemDecorations SystemDecorations { get { return GetValue(SystemDecorationsProperty); } set { SetValue(SystemDecorationsProperty, value); } } + /// + /// Gets or sets a value that indicates whether a window is activated when first shown. + /// + public bool ShowActivated + { + get { return GetValue(ShowActivatedProperty); } + set { SetValue(ShowActivatedProperty, value); } + } + /// /// Enables or disables the taskbar icon /// @@ -650,7 +664,7 @@ namespace Avalonia.Controls Owner = parent; parent?.AddChild(this, false); - PlatformImpl?.Show(); + PlatformImpl?.Show(ShowActivated); Renderer?.Start(); SetWindowStartupLocation(Owner?.PlatformImpl); } @@ -720,7 +734,7 @@ namespace Avalonia.Controls PlatformImpl?.SetParent(owner.PlatformImpl); Owner = owner; owner.AddChild(this, true); - PlatformImpl?.Show(); + PlatformImpl?.Show(ShowActivated); Renderer?.Start(); diff --git a/src/Avalonia.Controls/WindowBase.cs b/src/Avalonia.Controls/WindowBase.cs index 1efd6c8c1d..cdcb499e98 100644 --- a/src/Avalonia.Controls/WindowBase.cs +++ b/src/Avalonia.Controls/WindowBase.cs @@ -162,7 +162,7 @@ namespace Avalonia.Controls LayoutManager.ExecuteInitialLayoutPass(); _hasExecutedInitialLayoutPass = true; } - PlatformImpl?.Show(); + PlatformImpl?.Show(true); Renderer?.Start(); OnOpened(EventArgs.Empty); } diff --git a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs index 25c26be91e..787f44887f 100644 --- a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs +++ b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs @@ -20,7 +20,7 @@ namespace Avalonia.DesignerSupport.Remote ClientSize = new Size(1, 1); } - public void Show() + public void Show(bool activate) { } diff --git a/src/Avalonia.DesignerSupport/Remote/Stubs.cs b/src/Avalonia.DesignerSupport/Remote/Stubs.cs index f377b1bcd1..f6783dc0b7 100644 --- a/src/Avalonia.DesignerSupport/Remote/Stubs.cs +++ b/src/Avalonia.DesignerSupport/Remote/Stubs.cs @@ -77,7 +77,7 @@ namespace Avalonia.DesignerSupport.Remote { } - public void Show() + public void Show(bool activate) { } diff --git a/src/Avalonia.Headless/HeadlessWindowImpl.cs b/src/Avalonia.Headless/HeadlessWindowImpl.cs index 8f4fa5e304..3a1f3bdaf7 100644 --- a/src/Avalonia.Headless/HeadlessWindowImpl.cs +++ b/src/Avalonia.Headless/HeadlessWindowImpl.cs @@ -75,9 +75,10 @@ namespace Avalonia.Headless public Action Closed { get; set; } public IMouseDevice MouseDevice { get; } - public void Show() + public void Show(bool activate) { - Dispatcher.UIThread.Post(() => Activated?.Invoke(), DispatcherPriority.Input); + if (activate) + Dispatcher.UIThread.Post(() => Activated?.Invoke(), DispatcherPriority.Input); } public void Hide() @@ -148,7 +149,7 @@ namespace Avalonia.Headless public void ShowDialog(IWindowImpl parent) { - Show(); + Show(true); } public void SetSystemDecorations(bool enabled) diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 2cd3b973d8..d62e3bed23 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -815,7 +815,7 @@ namespace Avalonia.X11 XSetTransientForHint(_x11.Display, _handle, parent.Handle.Handle); } - public void Show() + public void Show(bool activate) { _wasMappedAtLeastOnce = true; XMapWindow(_x11.Display, _handle); diff --git a/src/Windows/Avalonia.Win32/PopupImpl.cs b/src/Windows/Avalonia.Win32/PopupImpl.cs index 7fb146899b..dd3fd1342c 100644 --- a/src/Windows/Avalonia.Win32/PopupImpl.cs +++ b/src/Windows/Avalonia.Win32/PopupImpl.cs @@ -17,8 +17,9 @@ namespace Avalonia.Win32 [ThreadStatic] private static IntPtr s_parentHandle; - public override void Show() + public override void Show(bool activate) { + // Popups are always shown non-activated. UnmanagedMethods.ShowWindow(Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate); // We need to steal focus if it's held by a child window of our toplevel window diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 5b16cae26e..af9531400e 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -229,7 +229,7 @@ namespace Avalonia.Win32 public IWindowImpl CreateEmbeddableWindow() { var embedded = new EmbeddedWindowImpl(); - embedded.Show(); + embedded.Show(true); return embedded; } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 715c8fc01d..f594763413 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -240,7 +240,7 @@ namespace Avalonia.Win32 { if (IsWindowVisible(_hwnd)) { - ShowWindow(value); + ShowWindow(value, true); } else { @@ -550,10 +550,11 @@ namespace Avalonia.Win32 UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide); } - public virtual void Show() + public virtual void Show(bool activate) { SetWindowLongPtr(_hwnd, (int)WindowLongParam.GWL_HWNDPARENT, _parent != null ? _parent._hwnd : IntPtr.Zero); - ShowWindow(_showWindowState); + + ShowWindow(_showWindowState, activate); } public Action GotInputWhenDisabled { get; set; } @@ -891,7 +892,7 @@ namespace Avalonia.Win32 ExtendClientAreaToDecorationsChanged?.Invoke(_isClientAreaExtended); } - private void ShowWindow(WindowState state) + private void ShowWindow(WindowState state, bool activate) { ShowWindowCommand? command; @@ -901,7 +902,7 @@ namespace Avalonia.Win32 { case WindowState.Minimized: newWindowProperties.IsFullScreen = false; - command = ShowWindowCommand.Minimize; + command = activate ? ShowWindowCommand.Minimize : ShowWindowCommand.ShowMinNoActive; break; case WindowState.Maximized: newWindowProperties.IsFullScreen = false; @@ -910,7 +911,8 @@ namespace Avalonia.Win32 case WindowState.Normal: newWindowProperties.IsFullScreen = false; - command = ShowWindowCommand.Restore; + command = IsWindowVisible(_hwnd) ? ShowWindowCommand.Restore : + activate ? ShowWindowCommand.Normal : ShowWindowCommand.ShowNoActivate; break; case WindowState.FullScreen: diff --git a/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs b/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs index c179aef9ac..39a3250686 100644 --- a/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs @@ -79,7 +79,7 @@ namespace Avalonia.Controls.UnitTests { using (Application()) { - popupImpl.Setup(x => x.Show()).Verifiable(); + popupImpl.Setup(x => x.Show(true)).Verifiable(); popupImpl.Setup(x => x.Hide()).Verifiable(); var sut = new ContextMenu(); @@ -99,7 +99,7 @@ namespace Avalonia.Controls.UnitTests _mouse.Click(target); Assert.False(sut.IsOpen); - popupImpl.Verify(x => x.Show(), Times.Once); + popupImpl.Verify(x => x.Show(true), Times.Once); popupImpl.Verify(x => x.Hide(), Times.Once); } } @@ -109,7 +109,7 @@ namespace Avalonia.Controls.UnitTests { using (Application()) { - popupImpl.Setup(x => x.Show()).Verifiable(); + popupImpl.Setup(x => x.Show(true)).Verifiable(); popupImpl.Setup(x => x.Hide()).Verifiable(); var sut = new ContextMenu(); @@ -130,7 +130,7 @@ namespace Avalonia.Controls.UnitTests Assert.True(sut.IsOpen); popupImpl.Verify(x => x.Hide(), Times.Once); - popupImpl.Verify(x => x.Show(), Times.Exactly(2)); + popupImpl.Verify(x => x.Show(true), Times.Exactly(2)); } } @@ -177,7 +177,7 @@ namespace Avalonia.Controls.UnitTests { using (Application()) { - popupImpl.Setup(x => x.Show()).Verifiable(); + popupImpl.Setup(x => x.Show(true)).Verifiable(); bool eventCalled = false; var sut = new ContextMenu(); @@ -193,7 +193,7 @@ namespace Avalonia.Controls.UnitTests Assert.True(eventCalled); Assert.False(sut.IsOpen); - popupImpl.Verify(x => x.Show(), Times.Never); + popupImpl.Verify(x => x.Show(true), Times.Never); } } @@ -297,7 +297,7 @@ namespace Avalonia.Controls.UnitTests { using (Application()) { - popupImpl.Setup(x => x.Show()).Verifiable(); + popupImpl.Setup(x => x.Show(true)).Verifiable(); popupImpl.Setup(x => x.Hide()).Verifiable(); bool eventCalled = false; @@ -321,7 +321,7 @@ namespace Avalonia.Controls.UnitTests Assert.True(eventCalled); Assert.True(sut.IsOpen); - popupImpl.Verify(x => x.Show(), Times.Once()); + popupImpl.Verify(x => x.Show(true), Times.Once()); popupImpl.Verify(x => x.Hide(), Times.Never); } } diff --git a/tests/Avalonia.Controls.UnitTests/WindowBaseTests.cs b/tests/Avalonia.Controls.UnitTests/WindowBaseTests.cs index 84f212d1b3..8109b037c5 100644 --- a/tests/Avalonia.Controls.UnitTests/WindowBaseTests.cs +++ b/tests/Avalonia.Controls.UnitTests/WindowBaseTests.cs @@ -137,7 +137,7 @@ namespace Avalonia.Controls.UnitTests var target = new TestWindowBase(windowImpl.Object); target.IsVisible = true; - windowImpl.Verify(x => x.Show()); + windowImpl.Verify(x => x.Show(true)); } } diff --git a/tests/Avalonia.UnitTests/MockWindowingPlatform.cs b/tests/Avalonia.UnitTests/MockWindowingPlatform.cs index 9ec8ca2d36..8a24a8366f 100644 --- a/tests/Avalonia.UnitTests/MockWindowingPlatform.cs +++ b/tests/Avalonia.UnitTests/MockWindowingPlatform.cs @@ -58,7 +58,7 @@ namespace Avalonia.UnitTests windowImpl.Object.Resized?.Invoke(clientSize); }); - windowImpl.Setup(x => x.Show()).Callback(() => + windowImpl.Setup(x => x.Show(true)).Callback(() => { windowImpl.Object.Activated?.Invoke(); }); From 2b9e092b32757f32b028288aac2934027b5ce924 Mon Sep 17 00:00:00 2001 From: capdj <42602325+capdj@users.noreply.github.com> Date: Tue, 17 Nov 2020 15:33:45 +0000 Subject: [PATCH 178/314] Fix X11 dropping modifier keys Fixes #4988 --- src/Avalonia.X11/XI2Manager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.X11/XI2Manager.cs b/src/Avalonia.X11/XI2Manager.cs index b3a24e6c37..8cdf24cc7b 100644 --- a/src/Avalonia.X11/XI2Manager.cs +++ b/src/Avalonia.X11/XI2Manager.cs @@ -351,7 +351,7 @@ namespace Avalonia.X11 if (state.HasFlag(XModifierMask.Mod4Mask)) Modifiers |= RawInputModifiers.Meta; - Modifiers = ParseButtonState(ev->buttons.MaskLen, ev->buttons.Mask); + Modifiers |= ParseButtonState(ev->buttons.MaskLen, ev->buttons.Mask); Valuators = new Dictionary(); Position = new Point(ev->event_x, ev->event_y); From 053537721a65632346ccd55441fdabdcb2e30ef1 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Tue, 17 Nov 2020 16:49:55 +0100 Subject: [PATCH 179/314] Parse Color and GridLength during compilation. Improve error handling for failed parsing. --- .../Avalonia.Build.Tasks.csproj | 11 +- src/Avalonia.Build.Tasks/SpanCompat.cs | 4 + src/Avalonia.Controls/GridLength.cs | 10 +- src/Avalonia.Visuals/Media/Color.cs | 14 +- src/Avalonia.Visuals/Media/KnownColors.cs | 9 ++ .../AvaloniaXamlIlGridLengthAstNode.cs | 34 +++++ .../AvaloniaXamlIlLanguage.cs | 135 ++++++++++++++---- .../AvaloniaXamlIlWellKnownTypes.cs | 9 ++ 8 files changed, 192 insertions(+), 34 deletions(-) create mode 100644 src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlGridLengthAstNode.cs diff --git a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj index bfac1ac1e1..90f6abc873 100644 --- a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj +++ b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj @@ -1,7 +1,7 @@  netstandard2.0 - netstandard2.0;netcoreapp2.0 + netstandard2.0;netcoreapp3.1 exe false tools @@ -81,6 +81,15 @@ Markup/%(RecursiveDir)%(FileName)%(Extension) + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + + + Markup/%(RecursiveDir)%(FileName)%(Extension) + diff --git a/src/Avalonia.Build.Tasks/SpanCompat.cs b/src/Avalonia.Build.Tasks/SpanCompat.cs index d5c406293e..f8960f56ec 100644 --- a/src/Avalonia.Build.Tasks/SpanCompat.cs +++ b/src/Avalonia.Build.Tasks/SpanCompat.cs @@ -1,3 +1,4 @@ +#if !NETCOREAPP3_1 namespace System { // This is a hack to enable our span code to work inside MSBuild task without referencing System.Memory @@ -63,6 +64,8 @@ namespace System } public override string ToString() => _length == 0 ? string.Empty : _s.Substring(_start, _length); + + public static implicit operator ReadOnlySpan(char[] arr) => new ReadOnlySpan(new string(arr)); } static class SpanCompatExtensions @@ -71,3 +74,4 @@ namespace System } } +#endif diff --git a/src/Avalonia.Controls/GridLength.cs b/src/Avalonia.Controls/GridLength.cs index 57f308d59f..b8418949d9 100644 --- a/src/Avalonia.Controls/GridLength.cs +++ b/src/Avalonia.Controls/GridLength.cs @@ -8,7 +8,10 @@ namespace Avalonia.Controls /// /// Defines the valid units for a . /// - public enum GridUnitType +#if !BUILDTASK + public +#endif + enum GridUnitType { /// /// The row or column is auto-sized to fit its content. @@ -29,7 +32,10 @@ namespace Avalonia.Controls /// /// Holds the width or height of a 's column and row definitions. /// - public struct GridLength : IEquatable +#if !BUILDTASK + public +#endif + struct GridLength : IEquatable { private readonly GridUnitType _type; diff --git a/src/Avalonia.Visuals/Media/Color.cs b/src/Avalonia.Visuals/Media/Color.cs index 16b4f90d57..a57a962db4 100644 --- a/src/Avalonia.Visuals/Media/Color.cs +++ b/src/Avalonia.Visuals/Media/Color.cs @@ -1,17 +1,24 @@ using System; using System.Globalization; +#if !BUILDTASK using Avalonia.Animation.Animators; +#endif namespace Avalonia.Media { /// /// An ARGB color. /// - public readonly struct Color : IEquatable +#if !BUILDTASK + public +#endif + readonly struct Color : IEquatable { static Color() { +#if !BUILDTASK Animation.Animation.RegisterAnimator(prop => typeof(Color).IsAssignableFrom(prop.PropertyType)); +#endif } /// @@ -223,7 +230,12 @@ namespace Avalonia.Media if (input.Length == 3 || input.Length == 4) { var extendedLength = 2 * input.Length; + +#if !BUILDTASK Span extended = stackalloc char[extendedLength]; +#else + char[] extended = new char[extendedLength]; +#endif for (int i = 0; i < input.Length; i++) { diff --git a/src/Avalonia.Visuals/Media/KnownColors.cs b/src/Avalonia.Visuals/Media/KnownColors.cs index 0887d2c913..fe09f5f538 100644 --- a/src/Avalonia.Visuals/Media/KnownColors.cs +++ b/src/Avalonia.Visuals/Media/KnownColors.cs @@ -8,7 +8,9 @@ namespace Avalonia.Media { private static readonly IReadOnlyDictionary _knownColorNames; private static readonly IReadOnlyDictionary _knownColors; +#if !BUILDTASK private static readonly Dictionary _knownBrushes; +#endif static KnownColors() { @@ -32,14 +34,19 @@ namespace Avalonia.Media _knownColorNames = knownColorNames; _knownColors = knownColors; + +#if !BUILDTASK _knownBrushes = new Dictionary(); +#endif } +#if !BUILDTASK public static ISolidColorBrush GetKnownBrush(string s) { var color = GetKnownColor(s); return color != KnownColor.None ? color.ToBrush() : null; } +#endif public static KnownColor GetKnownColor(string s) { @@ -61,6 +68,7 @@ namespace Avalonia.Media return Color.FromUInt32((uint)color); } +#if !BUILDTASK public static ISolidColorBrush ToBrush(this KnownColor color) { lock (_knownBrushes) @@ -74,6 +82,7 @@ namespace Avalonia.Media return brush; } } +#endif } internal enum KnownColor : uint diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlGridLengthAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlGridLengthAstNode.cs new file mode 100644 index 0000000000..218c49512c --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlGridLengthAstNode.cs @@ -0,0 +1,34 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using XamlX.Ast; +using XamlX.Emit; +using XamlX.IL; + +namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes +{ + class AvaloniaXamlIlGridLengthAstNode : XamlAstNode, IXamlAstValueNode, IXamlAstILEmitableNode + { + private readonly AvaloniaXamlIlWellKnownTypes _types; + private readonly GridLength _gridLength; + + public AvaloniaXamlIlGridLengthAstNode(IXamlLineInfo lineInfo, AvaloniaXamlIlWellKnownTypes types, GridLength gridLength) : base(lineInfo) + { + _types = types; + _gridLength = gridLength; + + Type = new XamlAstClrTypeReference(lineInfo, types.GridLength, false); + } + + public IXamlAstTypeReference Type { get; } + + public XamlILNodeEmitResult Emit(XamlEmitContext context, IXamlILEmitter codeGen) + { + codeGen + .Ldc_R8(_gridLength.Value) + .Ldc_I4((int)_gridLength.GridUnitType) + .Newobj(_types.GridLengthConstructorValueType); + + return XamlILNodeEmitResult.Type(0, Type.GetClrType()); + } + } +} diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index c3d9534828..87b82c112e 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using Avalonia.Controls; using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes; using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using Avalonia.Media; using XamlX; using XamlX.Ast; using XamlX.Emit; @@ -205,67 +207,140 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions result = new AvaloniaXamlIlFontFamilyAstNode(types, text, node); return true; } - + if (type.Equals(types.Thickness)) { - var thickness = Thickness.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Thickness, types.ThicknessFullConstructor, - new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); + try + { + var thickness = Thickness.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Thickness, types.ThicknessFullConstructor, + new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); - return true; + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a thickness", node); + } } if (type.Equals(types.Point)) { - var point = Point.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Point, types.PointFullConstructor, - new[] { point.X, point.Y }); + try + { + var point = Point.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Point, types.PointFullConstructor, + new[] { point.X, point.Y }); - return true; + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a point", node); + } } if (type.Equals(types.Vector)) { - var vector = Vector.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Vector, types.VectorFullConstructor, - new[] { vector.X, vector.Y }); + try + { + var vector = Vector.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Vector, types.VectorFullConstructor, + new[] { vector.X, vector.Y }); - return true; + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a vector", node); + } } if (type.Equals(types.Size)) { - var size = Size.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Size, types.SizeFullConstructor, - new[] { size.Width, size.Height }); + try + { + var size = Size.Parse(text); - return true; + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Size, types.SizeFullConstructor, + new[] { size.Width, size.Height }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a size", node); + } } if (type.Equals(types.Matrix)) { - var matrix = Matrix.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Matrix, types.MatrixFullConstructor, - new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); + try + { + var matrix = Matrix.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Matrix, types.MatrixFullConstructor, + new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); - return true; + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a matrix", node); + } } if (type.Equals(types.CornerRadius)) { - var cornerRadius = CornerRadius.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.CornerRadius, types.CornerRadiusFullConstructor, - new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); + try + { + var cornerRadius = CornerRadius.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.CornerRadius, types.CornerRadiusFullConstructor, + new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a corner radius", node); + } + } + + if (type.Equals(types.Color)) + { + if (!Color.TryParse(text, out Color color)) + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a color", node); + } + + result = new XamlStaticOrTargetedReturnMethodCallNode(node, + type.GetMethod( + new FindMethodMethodSignature("FromUInt32", type, types.UInt) { IsStatic = true }), + new[] { new XamlConstantNode(node, types.UInt, color.ToUint32()) }); + return true; } + if (type.Equals(types.GridLength)) + { + try + { + var gridLength = GridLength.Parse(text); + + result = new AvaloniaXamlIlGridLengthAstNode(node, types, gridLength); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a grid length", node); + } + } + if (type.FullName == "Avalonia.AvaloniaProperty") { var scope = context.ParentNodes().OfType().FirstOrDefault(); diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 05b13b61d3..2a7e10d42e 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -49,6 +49,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType ReflectionBindingExtension { get; } public IXamlType RelativeSource { get; } + public IXamlType UInt { get; } public IXamlType Long { get; } public IXamlType Uri { get; } public IXamlType FontFamily { get; } @@ -65,6 +66,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlConstructor MatrixFullConstructor { get; } public IXamlType CornerRadius { get; } public IXamlConstructor CornerRadiusFullConstructor { get; } + public IXamlType GridLength { get; } + public IXamlConstructor GridLengthConstructorValueType { get; } + public IXamlType Color { get; } public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -122,6 +126,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers ItemsRepeater = cfg.TypeSystem.GetType("Avalonia.Controls.ItemsRepeater"); ReflectionBindingExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension"); RelativeSource = cfg.TypeSystem.GetType("Avalonia.Data.RelativeSource"); + UInt = cfg.TypeSystem.GetType("System.UInt32"); Long = cfg.TypeSystem.GetType("System.Int64"); Uri = cfg.TypeSystem.GetType("System.Uri"); FontFamily = cfg.TypeSystem.GetType("Avalonia.Media.FontFamily"); @@ -141,6 +146,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers (Size, SizeFullConstructor) = GetNumericTypeInfo("Avalonia.Size", XamlIlTypes.Double, 2); (Matrix, MatrixFullConstructor) = GetNumericTypeInfo("Avalonia.Matrix", XamlIlTypes.Double, 6); (CornerRadius, CornerRadiusFullConstructor) = GetNumericTypeInfo("Avalonia.CornerRadius", XamlIlTypes.Double, 4); + + GridLength = cfg.TypeSystem.GetType("Avalonia.Controls.GridLength"); + GridLengthConstructorValueType = GridLength.GetConstructor(new List { XamlIlTypes.Double, cfg.TypeSystem.GetType("Avalonia.Controls.GridUnitType") }); + Color = cfg.TypeSystem.GetType("Avalonia.Media.Color"); } } From ff9981cfbbf058bcd839b1e8bbbc98381f07eb13 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 17 Nov 2020 13:05:56 -0500 Subject: [PATCH 180/314] Update macOS build instructions dylib copy instructions --- Documentation/build.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/build.md b/Documentation/build.md index 2f59146a48..45ee980e0b 100644 --- a/Documentation/build.md +++ b/Documentation/build.md @@ -68,7 +68,15 @@ On macOS it is necessary to build and manually install the respective native lib ``` cd ~/Library/Developer/Xcode/DerivedData/Avalonia.Native.OSX-[guid]/Build/Products/Debug -cp libAvalonia.Native.OSX.dylib /usr/local/lib/libAvaloniaNative.dylib +cp libAvalonia.Native.OSX.dylib /usr/local/lib/libAvalonia.Native.OSX.dylib +``` + +For compilation we also need this library on the build path. From the Avalonia root project directory: + +``` +mkdir -p build/Products/Release +cp /usr/local/lib/libAvalonia.Native.OSX.dylib build/Products/Release + ``` ### Build and Run Avalonia From 823ab3a40ddd8f37bb3384f1a386d4f67ee13fc2 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 18 Nov 2020 18:21:07 +0800 Subject: [PATCH 181/314] address review --- src/Avalonia.Visuals/Media/PathFigure.cs | 8 ++++---- src/Avalonia.Visuals/Media/PathGeometry.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index a9e3c6d628..311a70a098 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -30,9 +30,9 @@ namespace Avalonia.Media internal event EventHandler SegmentsInvalidated; - private IDisposable? _segmentsObserver; + private IDisposable _segmentsDisposable; - private IDisposable? _segmentsPropertiesObserver; + private IDisposable _segmentsPropertiesObserver; /// /// Initializes a new instance of the class. @@ -50,10 +50,10 @@ namespace Avalonia.Media private void OnSegmentsChanged(PathSegments? arg2NewValue) { - _segmentsObserver?.Dispose(); + _segmentsDisposable?.Dispose(); _segmentsPropertiesObserver?.Dispose(); - _segmentsObserver = _segments?.ForEachItem( + _segmentsDisposable = _segments?.ForEachItem( _ => InvalidateSegments(), _ => InvalidateSegments(), InvalidateSegments); diff --git a/src/Avalonia.Visuals/Media/PathGeometry.cs b/src/Avalonia.Visuals/Media/PathGeometry.cs index 819669d86e..3d11c19b7d 100644 --- a/src/Avalonia.Visuals/Media/PathGeometry.cs +++ b/src/Avalonia.Visuals/Media/PathGeometry.cs @@ -120,7 +120,7 @@ namespace Avalonia.Media } - public void InvalidateGeometryFromSegments(object _, EventArgs __) + private void InvalidateGeometryFromSegments(object _, EventArgs __) { InvalidateGeometry(); } From 90e6e072212b1fb5924ba7f21027ab9a8dd993ac Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 18 Nov 2020 18:23:28 +0800 Subject: [PATCH 182/314] address review --- src/Avalonia.Visuals/Media/PathFigure.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index 311a70a098..0c4cc592af 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -32,7 +32,7 @@ namespace Avalonia.Media private IDisposable _segmentsDisposable; - private IDisposable _segmentsPropertiesObserver; + private IDisposable _segmentsPropertiesDisposable; /// /// Initializes a new instance of the class. @@ -51,14 +51,14 @@ namespace Avalonia.Media private void OnSegmentsChanged(PathSegments? arg2NewValue) { _segmentsDisposable?.Dispose(); - _segmentsPropertiesObserver?.Dispose(); + _segmentsPropertiesDisposable?.Dispose(); _segmentsDisposable = _segments?.ForEachItem( _ => InvalidateSegments(), _ => InvalidateSegments(), InvalidateSegments); - _segmentsPropertiesObserver = _segments?.TrackItemPropertyChanged(_ => InvalidateSegments()); + _segmentsPropertiesDisposable = _segments?.TrackItemPropertyChanged(_ => InvalidateSegments()); } private void InvalidateSegments() From 538b723c2d25916bd1e1d2f0898a7923862d2281 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 18 Nov 2020 20:53:07 +0800 Subject: [PATCH 183/314] address review --- src/Avalonia.Visuals/Media/PathFigure.cs | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index 0c4cc592af..2f8d11b06e 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -1,5 +1,5 @@ +#nullable enable using System; -using System.ComponentModel; using Avalonia.Collections; using Avalonia.Metadata; @@ -11,29 +11,35 @@ namespace Avalonia.Media /// Defines the property. /// public static readonly StyledProperty IsClosedProperty - = AvaloniaProperty.Register(nameof(IsClosed), true); + = AvaloniaProperty.Register(nameof(IsClosed), true); + /// /// Defines the property. /// public static readonly StyledProperty IsFilledProperty - = AvaloniaProperty.Register(nameof(IsFilled), true); + = AvaloniaProperty.Register(nameof(IsFilled), true); + /// /// Defines the property. /// public static readonly DirectProperty SegmentsProperty - = AvaloniaProperty.RegisterDirect(nameof(Segments), f => f.Segments, (f, s) => f.Segments = s); + = AvaloniaProperty.RegisterDirect(nameof(Segments), f => f.Segments, + (f, s) => f.Segments = s); + /// /// Defines the property. /// public static readonly StyledProperty StartPointProperty - = AvaloniaProperty.Register(nameof(StartPoint)); + = AvaloniaProperty.Register(nameof(StartPoint)); + + internal event EventHandler? SegmentsInvalidated; - internal event EventHandler SegmentsInvalidated; + private PathSegments? _segments; - private IDisposable _segmentsDisposable; + private IDisposable? _segmentsDisposable; + + private IDisposable? _segmentsPropertiesDisposable; - private IDisposable _segmentsPropertiesDisposable; - /// /// Initializes a new instance of the class. /// @@ -57,7 +63,7 @@ namespace Avalonia.Media _ => InvalidateSegments(), _ => InvalidateSegments(), InvalidateSegments); - + _segmentsPropertiesDisposable = _segments?.TrackItemPropertyChanged(_ => InvalidateSegments()); } @@ -127,8 +133,6 @@ namespace Avalonia.Media ctx.EndFigure(IsClosed); } - private PathSegments _segments; - public override string ToString() => $"M {StartPoint} {string.Join(" ", _segments)}{(IsClosed ? "Z" : "")}"; } From 1800ad01257216c30ae5c40b8567ab437a0432f2 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 18 Nov 2020 13:57:16 +0000 Subject: [PATCH 184/314] fix nullable warnings. --- src/Avalonia.Visuals/Media/PathFigure.cs | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs index 2f8d11b06e..caf86cb234 100644 --- a/src/Avalonia.Visuals/Media/PathFigure.cs +++ b/src/Avalonia.Visuals/Media/PathFigure.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Linq; using Avalonia.Collections; using Avalonia.Metadata; @@ -22,8 +23,10 @@ namespace Avalonia.Media /// /// Defines the property. /// - public static readonly DirectProperty SegmentsProperty - = AvaloniaProperty.RegisterDirect(nameof(Segments), f => f.Segments, + public static readonly DirectProperty SegmentsProperty + = AvaloniaProperty.RegisterDirect( + nameof(Segments), + f => f.Segments, (f, s) => f.Segments = s); /// @@ -50,11 +53,12 @@ namespace Avalonia.Media static PathFigure() { - SegmentsProperty.Changed.AddClassHandler((s, e) => - s.OnSegmentsChanged(e.NewValue as PathSegments)); + SegmentsProperty.Changed.AddClassHandler( + (s, e) => + s.OnSegmentsChanged()); } - private void OnSegmentsChanged(PathSegments? arg2NewValue) + private void OnSegmentsChanged() { _segmentsDisposable?.Dispose(); _segmentsPropertiesDisposable?.Dispose(); @@ -103,7 +107,7 @@ namespace Avalonia.Media /// The segments. /// [Content] - public PathSegments Segments + public PathSegments? Segments { get { return _segments; } set { SetAndRaise(SegmentsProperty, ref _segments, value); } @@ -120,20 +124,23 @@ namespace Avalonia.Media get { return GetValue(StartPointProperty); } set { SetValue(StartPointProperty, value); } } + + public override string ToString() + => $"M {StartPoint} {string.Join(" ", _segments ?? Enumerable.Empty())}{(IsClosed ? "Z" : "")}"; internal void ApplyTo(StreamGeometryContext ctx) { ctx.BeginFigure(StartPoint, IsFilled); - foreach (var segment in Segments) + if (Segments != null) { - segment.ApplyTo(ctx); + foreach (var segment in Segments) + { + segment.ApplyTo(ctx); + } } ctx.EndFigure(IsClosed); } - - public override string ToString() - => $"M {StartPoint} {string.Join(" ", _segments)}{(IsClosed ? "Z" : "")}"; } } From dc698b3b1d404a92aebdf7183c13fe9769fcc116 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 19 Nov 2020 12:26:11 +0100 Subject: [PATCH 185/314] Reuse empty value store arrays. --- .../Utilities/AvaloniaPropertyValueStore.cs | 24 +++++++++++++++---- .../Layout/ControlsBenchmark.cs | 3 ++- .../Avalonia.Benchmarks/NullCursorFactory.cs | 14 +++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 tests/Avalonia.Benchmarks/NullCursorFactory.cs diff --git a/src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs b/src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs index 0238446892..6e52b6770a 100644 --- a/src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs +++ b/src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +#nullable enable namespace Avalonia.Utilities { @@ -9,12 +12,14 @@ namespace Avalonia.Utilities /// Stored value type. internal sealed class AvaloniaPropertyValueStore { + // The last item in the list is always int.MaxValue. + private static readonly Entry[] s_emptyEntries = { new Entry { PropertyId = int.MaxValue, Value = default! } }; + private Entry[] _entries; public AvaloniaPropertyValueStore() { - // The last item in the list is always int.MaxValue - _entries = new[] { new Entry { PropertyId = int.MaxValue, Value = default } }; + _entries = s_emptyEntries; } private (int, bool) TryFindEntry(int propertyId) @@ -86,7 +91,7 @@ namespace Avalonia.Utilities return (0, false); } - public bool TryGetValue(AvaloniaProperty property, out TValue value) + public bool TryGetValue(AvaloniaProperty property, [MaybeNull] out TValue value) { (int index, bool found) = TryFindEntry(property.Id); if (!found) @@ -132,7 +137,18 @@ namespace Avalonia.Utilities if (found) { - Entry[] entries = new Entry[_entries.Length - 1]; + var newLength = _entries.Length - 1; + + // Special case - one element left means that value store is empty so we can just reuse our "empty" array. + if (newLength == 1) + { + _entries = s_emptyEntries; + + return; + } + + var entries = new Entry[newLength]; + int ix = 0; for (int i = 0; i < _entries.Length; ++i) diff --git a/tests/Avalonia.Benchmarks/Layout/ControlsBenchmark.cs b/tests/Avalonia.Benchmarks/Layout/ControlsBenchmark.cs index 7170f6d7d4..3493dd0f53 100644 --- a/tests/Avalonia.Benchmarks/Layout/ControlsBenchmark.cs +++ b/tests/Avalonia.Benchmarks/Layout/ControlsBenchmark.cs @@ -17,7 +17,8 @@ namespace Avalonia.Benchmarks.Layout _app = UnitTestApplication.Start( TestServices.StyledWindow.With( renderInterface: new NullRenderingPlatform(), - threadingInterface: new NullThreadingPlatform())); + threadingInterface: new NullThreadingPlatform(), + standardCursorFactory: new NullCursorFactory())); _root = new TestRoot(true, null) { diff --git a/tests/Avalonia.Benchmarks/NullCursorFactory.cs b/tests/Avalonia.Benchmarks/NullCursorFactory.cs new file mode 100644 index 0000000000..012adce0f2 --- /dev/null +++ b/tests/Avalonia.Benchmarks/NullCursorFactory.cs @@ -0,0 +1,14 @@ +using System; +using Avalonia.Input; +using Avalonia.Platform; + +namespace Avalonia.Benchmarks +{ + internal class NullCursorFactory : IStandardCursorFactory + { + public IPlatformHandle GetCursor(StandardCursorType cursorType) + { + return new PlatformHandle(IntPtr.Zero, "null"); + } + } +} From 492534fc9a2239009baf7029b954b215c8526f33 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 19 Nov 2020 12:59:05 +0100 Subject: [PATCH 186/314] Parse cursor type during xaml compilation. --- .../CompilerExtensions/AvaloniaXamlIlLanguage.cs | 12 ++++++++++++ .../Transformers/AvaloniaXamlIlWellKnownTypes.cs | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 87b82c112e..40cfd21a76 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -341,6 +341,18 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions } } + if (type.Equals(types.Cursor)) + { + if (TypeSystemHelpers.TryGetEnumValueNode(types.StandardCursorType, text, node, out var enumConstantNode)) + { + var cursorTypeRef = new XamlAstClrTypeReference(node, types.Cursor, false); + + result = new XamlAstNewClrObjectNode(node, cursorTypeRef, types.CursorTypeConstructor, new List { enumConstantNode }); + + return true; + } + } + if (type.FullName == "Avalonia.AvaloniaProperty") { var scope = context.ParentNodes().OfType().FirstOrDefault(); diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 2a7e10d42e..f046778429 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -69,6 +69,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType GridLength { get; } public IXamlConstructor GridLengthConstructorValueType { get; } public IXamlType Color { get; } + public IXamlType StandardCursorType { get; } + public IXamlType Cursor { get; } + public IXamlConstructor CursorTypeConstructor { get; } public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -150,6 +153,9 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers GridLength = cfg.TypeSystem.GetType("Avalonia.Controls.GridLength"); GridLengthConstructorValueType = GridLength.GetConstructor(new List { XamlIlTypes.Double, cfg.TypeSystem.GetType("Avalonia.Controls.GridUnitType") }); Color = cfg.TypeSystem.GetType("Avalonia.Media.Color"); + StandardCursorType = cfg.TypeSystem.GetType("Avalonia.Input.StandardCursorType"); + Cursor = cfg.TypeSystem.GetType("Avalonia.Input.Cursor"); + CursorTypeConstructor = Cursor.GetConstructor(new List { StandardCursorType }); } } From eb0389e95635d405b104fe50dd8e53b15182dfed Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 19 Nov 2020 18:51:30 +0000 Subject: [PATCH 187/314] remove toggleswitch minwidth. --- src/Avalonia.Themes.Default/ToggleSwitch.xaml | 2 +- src/Avalonia.Themes.Fluent/ToggleSwitch.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Default/ToggleSwitch.xaml b/src/Avalonia.Themes.Default/ToggleSwitch.xaml index 9d1c024eb9..f11f77df5a 100644 --- a/src/Avalonia.Themes.Default/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Default/ToggleSwitch.xaml @@ -5,7 +5,7 @@ 0,0,0,6 6 6 - 154 + 0 0 1 diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml index 2491225a44..45537e41ad 100644 --- a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml @@ -5,7 +5,7 @@ 0,0,0,6 6 6 - 154 + 0 From 165bc2840909cda8c0c6fe751974757b4f32e84c Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 21 Nov 2020 19:19:27 +0300 Subject: [PATCH 188/314] [AVNCOM] Manually pass `bool` values as `int` for now --- src/Avalonia.Native/Extensions.cs | 8 ++++++++ src/Avalonia.Native/IAvnMenuItem.cs | 2 +- src/Avalonia.Native/PlatformThreadingInterface.cs | 6 +++--- src/Avalonia.Native/PopupImpl.cs | 4 ++-- src/Avalonia.Native/PredicateCallback.cs | 4 ++-- src/Avalonia.Native/ScreenImpl.cs | 2 +- src/Avalonia.Native/SystemDialogs.cs | 2 +- src/Avalonia.Native/WindowImpl.cs | 12 ++++++------ src/Avalonia.Native/WindowImplBase.cs | 12 ++++++------ src/Avalonia.Native/avn.idl | 1 + 10 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 src/Avalonia.Native/Extensions.cs diff --git a/src/Avalonia.Native/Extensions.cs b/src/Avalonia.Native/Extensions.cs new file mode 100644 index 0000000000..c0d90f7a85 --- /dev/null +++ b/src/Avalonia.Native/Extensions.cs @@ -0,0 +1,8 @@ +namespace Avalonia.Native +{ + internal static class Extensions + { + public static int AsComBool(this bool b) => b ? 1 : 0; + public static bool FromComBool(this int b) => b != 0; + } +} diff --git a/src/Avalonia.Native/IAvnMenuItem.cs b/src/Avalonia.Native/IAvnMenuItem.cs index e2feffaa33..4c0c81394f 100644 --- a/src/Avalonia.Native/IAvnMenuItem.cs +++ b/src/Avalonia.Native/IAvnMenuItem.cs @@ -24,7 +24,7 @@ namespace Avalonia.Native.Interop.Impl private void UpdateTitle(string title) => SetTitle(title ?? ""); - private void UpdateIsChecked(bool isChecked) => SetIsChecked(isChecked); + private void UpdateIsChecked(bool isChecked) => SetIsChecked(isChecked.AsComBool()); private void UpdateToggleType(NativeMenuItemToggleType toggleType) { diff --git a/src/Avalonia.Native/PlatformThreadingInterface.cs b/src/Avalonia.Native/PlatformThreadingInterface.cs index df69f2eafb..882d5a2ed3 100644 --- a/src/Avalonia.Native/PlatformThreadingInterface.cs +++ b/src/Avalonia.Native/PlatformThreadingInterface.cs @@ -33,9 +33,9 @@ namespace Avalonia.Native _parent = parent; } - public void Signaled(int priority, bool priorityContainsMeaningfulValue) + public void Signaled(int priority, int priorityContainsMeaningfulValue) { - _parent.Signaled?.Invoke(priorityContainsMeaningfulValue ? (DispatcherPriority?)priority : null); + _parent.Signaled?.Invoke(priorityContainsMeaningfulValue.FromComBool() ? (DispatcherPriority?)priority : null); } } @@ -50,7 +50,7 @@ namespace Avalonia.Native _native.SetSignaledCallback(cb); } - public bool CurrentThreadIsLoopThread => _native.CurrentThreadIsLoopThread; + public bool CurrentThreadIsLoopThread => _native.CurrentThreadIsLoopThread.FromComBool(); public event Action Signaled; diff --git a/src/Avalonia.Native/PopupImpl.cs b/src/Avalonia.Native/PopupImpl.cs index 2f98385038..60c552a937 100644 --- a/src/Avalonia.Native/PopupImpl.cs +++ b/src/Avalonia.Native/PopupImpl.cs @@ -50,9 +50,9 @@ namespace Avalonia.Native // NOP on Popup } - bool IAvnWindowEvents.Closing() + int IAvnWindowEvents.Closing() { - return true; + return true.AsComBool(); } void IAvnWindowEvents.WindowStateChanged(AvnWindowState state) diff --git a/src/Avalonia.Native/PredicateCallback.cs b/src/Avalonia.Native/PredicateCallback.cs index 1ed2ae36af..19c470bcb3 100644 --- a/src/Avalonia.Native/PredicateCallback.cs +++ b/src/Avalonia.Native/PredicateCallback.cs @@ -12,9 +12,9 @@ namespace Avalonia.Native _predicate = predicate; } - bool IAvnPredicateCallback.Evaluate() + int IAvnPredicateCallback.Evaluate() { - return _predicate(); + return _predicate().AsComBool(); } } } diff --git a/src/Avalonia.Native/ScreenImpl.cs b/src/Avalonia.Native/ScreenImpl.cs index ae6da01388..7b4a001486 100644 --- a/src/Avalonia.Native/ScreenImpl.cs +++ b/src/Avalonia.Native/ScreenImpl.cs @@ -33,7 +33,7 @@ namespace Avalonia.Native screen.PixelDensity, screen.Bounds.ToAvaloniaPixelRect(), screen.WorkingArea.ToAvaloniaPixelRect(), - screen.Primary); + screen.Primary.FromComBool()); } return result; diff --git a/src/Avalonia.Native/SystemDialogs.cs b/src/Avalonia.Native/SystemDialogs.cs index 0239fc680d..8012813644 100644 --- a/src/Avalonia.Native/SystemDialogs.cs +++ b/src/Avalonia.Native/SystemDialogs.cs @@ -26,7 +26,7 @@ namespace Avalonia.Native if (dialog is OpenFileDialog ofd) { _native.OpenFileDialog(nativeParent, - events, ofd.AllowMultiple, + events, ofd.AllowMultiple.AsComBool(), ofd.Title ?? "", ofd.Directory ?? "", ofd.InitialFileName ?? "", diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index b42831854d..f60e83efe3 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -42,14 +42,14 @@ namespace Avalonia.Native _parent = parent; } - bool IAvnWindowEvents.Closing() + int IAvnWindowEvents.Closing() { if (_parent.Closing != null) { - return _parent.Closing(); + return _parent.Closing().AsComBool(); } - return true; + return true.AsComBool(); } void IAvnWindowEvents.WindowStateChanged(AvnWindowState state) @@ -69,7 +69,7 @@ namespace Avalonia.Native public void CanResize(bool value) { - _native.SetCanResize(value); + _native.SetCanResize(value.AsComBool()); } public void SetSystemDecorations(Controls.SystemDecorations enabled) @@ -145,7 +145,7 @@ namespace Avalonia.Native { _isExtended = extendIntoClientAreaHint; - _native.SetExtendClientArea(extendIntoClientAreaHint); + _native.SetExtendClientArea(extendIntoClientAreaHint.AsComBool()); InvalidateExtendedMargins(); } @@ -198,7 +198,7 @@ namespace Avalonia.Native public void SetEnabled(bool enable) { - _native.SetEnabled(enable); + _native.SetEnabled(enable.AsComBool()); } } } diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 150ab2703e..88c3144884 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -192,14 +192,14 @@ namespace Avalonia.Native _parent.RawMouseEvent(type, timeStamp, modifiers, point, delta); } - bool IAvnWindowBaseEvents.RawKeyEvent(AvnRawKeyEventType type, uint timeStamp, AvnInputModifiers modifiers, uint key) + int IAvnWindowBaseEvents.RawKeyEvent(AvnRawKeyEventType type, uint timeStamp, AvnInputModifiers modifiers, uint key) { - return _parent.RawKeyEvent(type, timeStamp, modifiers, key); + return _parent.RawKeyEvent(type, timeStamp, modifiers, key).AsComBool(); } - bool IAvnWindowBaseEvents.RawTextInputEvent(uint timeStamp, string text) + int IAvnWindowBaseEvents.RawTextInputEvent(uint timeStamp, string text) { - return _parent.RawTextInputEvent(timeStamp, text); + return _parent.RawTextInputEvent(timeStamp, text).AsComBool(); } @@ -388,7 +388,7 @@ namespace Avalonia.Native public void SetTopmost(bool value) { - _native.SetTopMost(value); + _native.SetTopMost(value.AsComBool()); } public double RenderScaling => _native?.Scaling ?? 1; @@ -456,7 +456,7 @@ namespace Avalonia.Native TransparencyLevel = transparencyLevel; - _native?.SetBlurEnabled(TransparencyLevel >= WindowTransparencyLevel.Blur); + _native?.SetBlurEnabled((TransparencyLevel >= WindowTransparencyLevel.Blur).AsComBool()); TransparencyLevelChanged?.Invoke(TransparencyLevel); } } diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index 1d36cce20d..3f33476c3d 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -1,5 +1,6 @@ @clr-namespace Avalonia.Native.Interop @clr-access internal +@clr-map bool int @cpp-preamble @@ #include "com.h" #include "key.h" From b9a9ac94e76b0e75916539a355f4609bfff6824b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 21 Nov 2020 16:59:35 +0000 Subject: [PATCH 189/314] Fix mainthread detection osx. --- native/Avalonia.Native/src/OSX/platformthreading.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/Avalonia.Native/src/OSX/platformthreading.mm b/native/Avalonia.Native/src/OSX/platformthreading.mm index f93436d157..e83bf53331 100644 --- a/native/Avalonia.Native/src/OSX/platformthreading.mm +++ b/native/Avalonia.Native/src/OSX/platformthreading.mm @@ -101,7 +101,7 @@ public: virtual bool GetCurrentThreadIsLoopThread() override { - return [[NSThread currentThread] isMainThread]; + return [NSThread isMainThread]; } virtual void SetSignaledCallback(IAvnSignaledCallback* cb) override { From 89b5d13408cca05ec939474d78a8499b6ec4fa8c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 21 Nov 2020 23:01:57 +0000 Subject: [PATCH 190/314] [OSX] remove most of the stretching and flickering by calling updateLayer at the end of resize. --- native/Avalonia.Native/src/OSX/rendertarget.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/native/Avalonia.Native/src/OSX/rendertarget.mm b/native/Avalonia.Native/src/OSX/rendertarget.mm index 93a33bbbb0..6643c5c089 100644 --- a/native/Avalonia.Native/src/OSX/rendertarget.mm +++ b/native/Avalonia.Native/src/OSX/rendertarget.mm @@ -143,13 +143,17 @@ static IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(IOSurfaceRenderTarget* ta return _layer; } -- (void)resize:(AvnPixelSize)size withScale: (float) scale;{ +- (void)resize:(AvnPixelSize)size withScale: (float) scale{ @synchronized (lock) { if(surface == nil || surface->size.Width != size.Width || surface->size.Height != size.Height || surface->scale != scale) + { surface = [[IOSurfaceHolder alloc] initWithSize:size withScale:scale withOpenGlContext:_glContext.getRaw()]; + + [self updateLayer]; + } } } From d96bfe6996d7c8a3f42186f907134c4952f20466 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 21 Nov 2020 23:02:32 +0000 Subject: [PATCH 191/314] Remove last bit of flickering by wrapping layer updates inside a CATransaction. --- native/Avalonia.Native/src/OSX/rendertarget.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/native/Avalonia.Native/src/OSX/rendertarget.mm b/native/Avalonia.Native/src/OSX/rendertarget.mm index 6643c5c089..00b6dab219 100644 --- a/native/Avalonia.Native/src/OSX/rendertarget.mm +++ b/native/Avalonia.Native/src/OSX/rendertarget.mm @@ -2,6 +2,7 @@ #include "rendertarget.h" #import #import +#import #include #include @@ -163,12 +164,15 @@ static IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(IOSurfaceRenderTarget* ta @synchronized (lock) { if(_layer == nil) return; + [CATransaction begin]; [_layer setContents: nil]; if(surface != nil) { [_layer setContentsScale: surface->scale]; [_layer setContents: (__bridge IOSurface*) surface->surface]; } + [CATransaction commit]; + [CATransaction flush]; } } else From 019a5096f1372c4dee801befbd654bff0f1c72fe Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 22 Nov 2020 12:27:28 +0000 Subject: [PATCH 192/314] incremement min win10 version for win.ui.comp. --- .../WinRT/Composition/WinUICompositorConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs index 7e1f97ab84..2aa82436f6 100644 --- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs +++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs @@ -134,7 +134,7 @@ namespace Avalonia.Win32.WinRT.Composition public static void TryCreateAndRegister(EglPlatformOpenGlInterface angle) { const int majorRequired = 10; - const int buildRequired = 16299; + const int buildRequired = 17134; var majorInstalled = Win32Platform.WindowsVersion.Major; var buildInstalled = Win32Platform.WindowsVersion.Build; From 31bfcb6b05262cad46fce35340932b742e1b88e6 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 11:39:52 +0100 Subject: [PATCH 193/314] Fix BindingValue comparison. `NativeMenuBar` click forwarding was broken by https://github.com/AvaloniaUI/Avalonia/pull/4648 - this fixes it. --- src/Avalonia.Controls/NativeMenuBar.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/NativeMenuBar.cs b/src/Avalonia.Controls/NativeMenuBar.cs index 63bb39108f..5d2e1087a7 100644 --- a/src/Avalonia.Controls/NativeMenuBar.cs +++ b/src/Avalonia.Controls/NativeMenuBar.cs @@ -1,7 +1,6 @@ using System; using Avalonia.Controls.Primitives; using Avalonia.Interactivity; -using Avalonia.Styling; namespace Avalonia.Controls { @@ -16,7 +15,7 @@ namespace Avalonia.Controls EnableMenuItemClickForwardingProperty.Changed.Subscribe(args => { var item = (MenuItem)args.Sender; - if (args.NewValue.Equals(true)) + if (args.NewValue.GetValueOrDefault()) item.Click += OnMenuItemClick; else item.Click -= OnMenuItemClick; From 5d4b56d04207025a4e161606ceac6a34b11bfd8b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 12:18:16 +0100 Subject: [PATCH 194/314] NativeMenuItem.Clicked -> Click. And mark `Clicked` as obsolete. For consistency with `MenuItem.Click`. --- src/Avalonia.Controls/NativeMenuItem.cs | 16 +++++++++++++--- .../AvaloniaNativeMenuExporter.cs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/NativeMenuItem.cs b/src/Avalonia.Controls/NativeMenuItem.cs index a0fec9e677..e8cb59e76e 100644 --- a/src/Avalonia.Controls/NativeMenuItem.cs +++ b/src/Avalonia.Controls/NativeMenuItem.cs @@ -151,7 +151,7 @@ namespace Avalonia.Controls IsEnabled = _command?.CanExecute(null) ?? true; } - public bool HasClickHandlers => Clicked != null; + public bool HasClickHandlers => Click != null; public ICommand Command { @@ -182,11 +182,21 @@ namespace Avalonia.Controls set { SetValue(CommandParameterProperty, value); } } - public event EventHandler Clicked; + /// + /// Occurs when a is clicked. + /// + public event EventHandler Click; + + [Obsolete("Use Click event.")] + public event EventHandler Clicked + { + add => Click += value; + remove => Click -= value; + } void INativeMenuItemExporterEventsImplBridge.RaiseClicked() { - Clicked?.Invoke(this, new EventArgs()); + Click?.Invoke(this, new EventArgs()); if (Command?.CanExecute(CommandParameter) == true) { diff --git a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs index b192de95de..2e3408eca5 100644 --- a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs +++ b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs @@ -60,7 +60,7 @@ namespace Avalonia.Native Header = "About Avalonia", }; - aboutItem.Clicked += async (sender, e) => + aboutItem.Click += async (sender, e) => { var dialog = new AboutAvaloniaDialog(); From e59573d6309bb98e75ccd75d9c3c8050a9de4d7a Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 12:33:17 +0100 Subject: [PATCH 195/314] Mark NativeMenuItem.Menu as content property. Means that submenus don't need the extra `` element. --- samples/ControlCatalog/DecoratedWindow.xaml | 30 ++++------ samples/ControlCatalog/MainWindow.xaml | 66 +++++++++------------ src/Avalonia.Controls/NativeMenuItem.cs | 2 + 3 files changed, 44 insertions(+), 54 deletions(-) diff --git a/samples/ControlCatalog/DecoratedWindow.xaml b/samples/ControlCatalog/DecoratedWindow.xaml index 8e4c97b7f0..5251a2fa55 100644 --- a/samples/ControlCatalog/DecoratedWindow.xaml +++ b/samples/ControlCatalog/DecoratedWindow.xaml @@ -6,25 +6,21 @@ - - - - - - - - - - - + + + + + + + + + - - - - - - + + + + diff --git a/samples/ControlCatalog/MainWindow.xaml b/samples/ControlCatalog/MainWindow.xaml index 97bd88f5e4..6a70bb082f 100644 --- a/samples/ControlCatalog/MainWindow.xaml +++ b/samples/ControlCatalog/MainWindow.xaml @@ -16,47 +16,39 @@ - - - - - - - - - - - - - + + + + + + + + + - - - - - - + + + + - - - - - - - + + + + + diff --git a/src/Avalonia.Controls/NativeMenuItem.cs b/src/Avalonia.Controls/NativeMenuItem.cs index e8cb59e76e..76197b62ad 100644 --- a/src/Avalonia.Controls/NativeMenuItem.cs +++ b/src/Avalonia.Controls/NativeMenuItem.cs @@ -2,6 +2,7 @@ using System; using System.Windows.Input; using Avalonia.Input; using Avalonia.Media.Imaging; +using Avalonia.Metadata; using Avalonia.Utilities; namespace Avalonia.Controls @@ -62,6 +63,7 @@ namespace Avalonia.Controls public static readonly DirectProperty MenuProperty = AvaloniaProperty.RegisterDirect(nameof(Menu), o => o.Menu, (o, v) => o.Menu = v); + [Content] public NativeMenu Menu { get => _menu; From ad677f0ff43ca6bcd9f5f5524692e3d58a6956c6 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 15:28:42 +0100 Subject: [PATCH 196/314] Added failing test for #4900. --- .../Xaml/ShapeTests.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ShapeTests.cs diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ShapeTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ShapeTests.cs new file mode 100644 index 0000000000..bd577e84f8 --- /dev/null +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ShapeTests.cs @@ -0,0 +1,24 @@ +using Avalonia.Controls; +using Avalonia.Media; +using Xunit; + +namespace Avalonia.Markup.Xaml.UnitTests.Xaml +{ + public class ShapeTests : XamlTestBase + { + [Fact] + public void Can_Specify_DashStyle_In_XAML() + { + var xaml = @" + + + + +"; + + var target = AvaloniaRuntimeXamlLoader.Parse(xaml); + + Assert.NotNull(target); + } + } +} From d99512a785e78c5976a2f70f013a21dd40743342 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 15:29:37 +0100 Subject: [PATCH 197/314] Make DashStyle.Dashes an AvaloniaList. So that it can be parsed from XAML and changes can be made. --- src/Avalonia.Visuals/Media/DashStyle.cs | 75 +++++++++++++------ .../Media/PenTests.cs | 18 ++++- 2 files changed, 67 insertions(+), 26 deletions(-) diff --git a/src/Avalonia.Visuals/Media/DashStyle.cs b/src/Avalonia.Visuals/Media/DashStyle.cs index 1e813edc13..acba2d3615 100644 --- a/src/Avalonia.Visuals/Media/DashStyle.cs +++ b/src/Avalonia.Visuals/Media/DashStyle.cs @@ -1,11 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using Avalonia.Animation; +using Avalonia.Collections; +using Avalonia.Media.Immutable; + +#nullable enable + namespace Avalonia.Media { - using System; - using System.Collections.Generic; - using System.Linq; - using Avalonia.Animation; - using Avalonia.Media.Immutable; - /// /// Represents the sequence of dashes and gaps that will be applied by a . /// @@ -14,8 +17,8 @@ namespace Avalonia.Media /// /// Defines the property. /// - public static readonly StyledProperty> DashesProperty = - AvaloniaProperty.Register>(nameof(Dashes)); + public static readonly StyledProperty> DashesProperty = + AvaloniaProperty.Register>(nameof(Dashes)); /// /// Defines the property. @@ -23,10 +26,10 @@ namespace Avalonia.Media public static readonly StyledProperty OffsetProperty = AvaloniaProperty.Register(nameof(Offset)); - private static ImmutableDashStyle s_dash; - private static ImmutableDashStyle s_dot; - private static ImmutableDashStyle s_dashDot; - private static ImmutableDashStyle s_dashDotDot; + private static ImmutableDashStyle? s_dash; + private static ImmutableDashStyle? s_dot; + private static ImmutableDashStyle? s_dashDot; + private static ImmutableDashStyle? s_dashDotDot; /// /// Initializes a new instance of the class. @@ -41,9 +44,9 @@ namespace Avalonia.Media /// /// The dashes collection. /// The dash sequence offset. - public DashStyle(IEnumerable dashes, double offset) + public DashStyle(IEnumerable? dashes, double offset) { - Dashes = (IReadOnlyList)dashes?.ToList() ?? Array.Empty(); + Dashes = (dashes as AvaloniaList) ?? new AvaloniaList(dashes ?? Array.Empty()); Offset = offset; } @@ -61,31 +64,27 @@ namespace Avalonia.Media /// /// Represents a dashed . /// - public static IDashStyle Dash => - s_dash ?? (s_dash = new ImmutableDashStyle(new double[] { 2, 2 }, 1)); + public static IDashStyle Dash => s_dash ??= new ImmutableDashStyle(new double[] { 2, 2 }, 1); /// /// Represents a dotted . /// - public static IDashStyle Dot => - s_dot ?? (s_dot = new ImmutableDashStyle(new double[] { 0, 2 }, 0)); + public static IDashStyle Dot => s_dot ??= new ImmutableDashStyle(new double[] { 0, 2 }, 0); /// /// Represents a dashed dotted . /// - public static IDashStyle DashDot => - s_dashDot ?? (s_dashDot = new ImmutableDashStyle(new double[] { 2, 2, 0, 2 }, 1)); + public static IDashStyle DashDot => s_dashDot ??= new ImmutableDashStyle(new double[] { 2, 2, 0, 2 }, 1); /// /// Represents a dashed double dotted . /// - public static IDashStyle DashDotDot => - s_dashDotDot ?? (s_dashDotDot = new ImmutableDashStyle(new double[] { 2, 2, 0, 2, 0, 2 }, 1)); + public static IDashStyle DashDotDot => s_dashDotDot ??= new ImmutableDashStyle(new double[] { 2, 2, 0, 2, 0, 2 }, 1); /// /// Gets or sets the length of alternating dashes and gaps. /// - public IReadOnlyList Dashes + public AvaloniaList Dashes { get => GetValue(DashesProperty); set => SetValue(DashesProperty, value); @@ -100,15 +99,43 @@ namespace Avalonia.Media set => SetValue(OffsetProperty, value); } + IReadOnlyList IDashStyle.Dashes => Dashes; + /// /// Raised when the dash style changes. /// - public event EventHandler Invalidated; + public event EventHandler? Invalidated; /// /// Returns an immutable clone of the . /// /// public ImmutableDashStyle ToImmutable() => new ImmutableDashStyle(Dashes, Offset); + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == DashesProperty) + { + var oldValue = change.OldValue.GetValueOrDefault>(); + var newValue = change.NewValue.GetValueOrDefault>(); + + if (oldValue is object) + { + oldValue.CollectionChanged -= DashesChanged; + } + + if (newValue is object) + { + newValue.CollectionChanged += DashesChanged; + } + } + } + + private void DashesChanged(object sender, NotifyCollectionChangedEventArgs e) + { + Invalidated?.Invoke(this, e); + } } } diff --git a/tests/Avalonia.Visuals.UnitTests/Media/PenTests.cs b/tests/Avalonia.Visuals.UnitTests/Media/PenTests.cs index 418ac7576b..c2a1a5f9e4 100644 --- a/tests/Avalonia.Visuals.UnitTests/Media/PenTests.cs +++ b/tests/Avalonia.Visuals.UnitTests/Media/PenTests.cs @@ -1,4 +1,5 @@ -using Avalonia.Media; +using Avalonia.Collections; +using Avalonia.Media; using Avalonia.Media.Immutable; using Xunit; @@ -39,7 +40,20 @@ namespace Avalonia.Visuals.UnitTests.Media var raised = false; target.Invalidated += (s, e) => raised = true; - dashes.Dashes = new[] { 0.1, 0.2 }; + dashes.Dashes = new AvaloniaList { 0.1, 0.2 }; + + Assert.True(raised); + } + + [Fact] + public void Adding_DashStyle_Dashes_Raises_Invalidated() + { + var dashes = new DashStyle(); + var target = new Pen { DashStyle = dashes }; + var raised = false; + + target.Invalidated += (s, e) => raised = true; + dashes.Dashes.Add(0.3); Assert.True(raised); } From 6e41b197f0b9513ba264701f39d8ce1b7436a841 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 15:35:04 +0100 Subject: [PATCH 198/314] Updated API compat. --- src/Avalonia.Visuals/ApiCompatBaseline.txt | 42 +++------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/Avalonia.Visuals/ApiCompatBaseline.txt b/src/Avalonia.Visuals/ApiCompatBaseline.txt index 2d00d82a46..62f4def701 100644 --- a/src/Avalonia.Visuals/ApiCompatBaseline.txt +++ b/src/Avalonia.Visuals/ApiCompatBaseline.txt @@ -1,39 +1,5 @@ Compat issues with assembly Avalonia.Visuals: -MembersMustExist : Member 'public void Avalonia.Media.DrawingContext.DrawGlyphRun(Avalonia.Media.IBrush, Avalonia.Media.GlyphRun, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Media.Typeface Avalonia.Media.FontManager.GetOrAddTypeface(Avalonia.Media.FontFamily, Avalonia.Media.FontStyle, Avalonia.Media.FontWeight)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Media.Typeface Avalonia.Media.FontManager.MatchCharacter(System.Int32, Avalonia.Media.FontStyle, Avalonia.Media.FontWeight, Avalonia.Media.FontFamily, System.Globalization.CultureInfo)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Rect Avalonia.Media.Geometry.GetRenderBounds(Avalonia.Media.Pen)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.Boolean Avalonia.Media.Geometry.StrokeContains(Avalonia.Media.Pen, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Rect Avalonia.Media.GlyphRun.Bounds.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.StyledProperty Avalonia.StyledProperty Avalonia.Media.GlyphRunDrawing.BaselineOriginProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Point Avalonia.Media.GlyphRunDrawing.BaselineOrigin.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Media.GlyphRunDrawing.BaselineOrigin.set(Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -CannotSealType : Type 'Avalonia.Media.Typeface' is actually (has the sealed modifier) sealed in the implementation but not sealed in the contract. -TypeCannotChangeClassification : Type 'Avalonia.Media.Typeface' is a 'struct' in the implementation but is a 'class' in the contract. -CannotMakeMemberNonVirtual : Member 'public System.Boolean Avalonia.Media.Typeface.Equals(System.Object)' is non-virtual in the implementation but is virtual in the contract. -CannotMakeMemberNonVirtual : Member 'public System.Int32 Avalonia.Media.Typeface.GetHashCode()' is non-virtual in the implementation but is virtual in the contract. -TypesMustExist : Type 'Avalonia.Media.Fonts.FontKey' does not exist in the implementation but it does exist in the contract. -CannotAddAbstractMembers : Member 'public Avalonia.Size Avalonia.Media.TextFormatting.DrawableTextRun.Size' is abstract in the implementation but is missing in the contract. -MembersMustExist : Member 'public Avalonia.Rect Avalonia.Media.TextFormatting.DrawableTextRun.Bounds.get()' does not exist in the implementation but it does exist in the contract. -CannotAddAbstractMembers : Member 'public void Avalonia.Media.TextFormatting.DrawableTextRun.Draw(Avalonia.Media.DrawingContext)' is abstract in the implementation but is missing in the contract. -MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.DrawableTextRun.Draw(Avalonia.Media.DrawingContext, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -CannotAddAbstractMembers : Member 'public Avalonia.Size Avalonia.Media.TextFormatting.DrawableTextRun.Size.get()' is abstract in the implementation but is missing in the contract. -MembersMustExist : Member 'public Avalonia.Rect Avalonia.Media.TextFormatting.ShapedTextCharacters.Bounds.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.ShapedTextCharacters.Draw(Avalonia.Media.DrawingContext, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.TextLayout.Draw(Avalonia.Media.DrawingContext, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -CannotAddAbstractMembers : Member 'public Avalonia.Media.TextFormatting.TextLineBreak Avalonia.Media.TextFormatting.TextLine.TextLineBreak' is abstract in the implementation but is missing in the contract. -CannotAddAbstractMembers : Member 'public void Avalonia.Media.TextFormatting.TextLine.Draw(Avalonia.Media.DrawingContext)' is abstract in the implementation but is missing in the contract. -MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.TextLine.Draw(Avalonia.Media.DrawingContext, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Media.TextFormatting.TextLineBreak Avalonia.Media.TextFormatting.TextLine.LineBreak.get()' does not exist in the implementation but it does exist in the contract. -CannotAddAbstractMembers : Member 'public Avalonia.Media.TextFormatting.TextLineBreak Avalonia.Media.TextFormatting.TextLine.TextLineBreak.get()' is abstract in the implementation but is missing in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IDrawingContextLayerImpl Avalonia.Platform.IDrawingContextImpl.CreateLayer(Avalonia.Size)' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.Platform.IRenderTargetBitmapImpl Avalonia.Platform.IDrawingContextImpl.CreateLayer(Avalonia.Size)' is present in the contract but not in the implementation. -MembersMustExist : Member 'public Avalonia.Platform.IRenderTargetBitmapImpl Avalonia.Platform.IDrawingContextImpl.CreateLayer(Avalonia.Size)' does not exist in the implementation but it does exist in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.IDrawingContextImpl.DrawGlyphRun(Avalonia.Media.IBrush, Avalonia.Media.GlyphRun)' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.IDrawingContextImpl.DrawGlyphRun(Avalonia.Media.IBrush, Avalonia.Media.GlyphRun, Avalonia.Point)' is present in the contract but not in the implementation. -MembersMustExist : Member 'public void Avalonia.Platform.IDrawingContextImpl.DrawGlyphRun(Avalonia.Media.IBrush, Avalonia.Media.GlyphRun, Avalonia.Point)' does not exist in the implementation but it does exist in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public System.Boolean Avalonia.Platform.IFontManagerImpl.TryMatchCharacter(System.Int32, Avalonia.Media.FontStyle, Avalonia.Media.FontWeight, Avalonia.Media.FontFamily, System.Globalization.CultureInfo, Avalonia.Media.Fonts.FontKey)' is present in the contract but not in the implementation. -MembersMustExist : Member 'public System.Boolean Avalonia.Platform.IFontManagerImpl.TryMatchCharacter(System.Int32, Avalonia.Media.FontStyle, Avalonia.Media.FontWeight, Avalonia.Media.FontFamily, System.Globalization.CultureInfo, Avalonia.Media.Fonts.FontKey)' does not exist in the implementation but it does exist in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public System.Boolean Avalonia.Platform.IFontManagerImpl.TryMatchCharacter(System.Int32, Avalonia.Media.FontStyle, Avalonia.Media.FontWeight, Avalonia.Media.FontFamily, System.Globalization.CultureInfo, Avalonia.Media.Typeface)' is present in the implementation but not in the contract. -MembersMustExist : Member 'public Avalonia.Utilities.IRef Avalonia.Rendering.RenderLayer.Bitmap.get()' does not exist in the implementation but it does exist in the contract. -Total Issues: 37 +MembersMustExist : Member 'public Avalonia.StyledProperty> Avalonia.StyledProperty> Avalonia.Media.DashStyle.DashesProperty' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public System.Collections.Generic.IReadOnlyList Avalonia.Media.DashStyle.Dashes.get()' does not exist in the implementation but it does exist in the contract. +MembersMustExist : Member 'public void Avalonia.Media.DashStyle.Dashes.set(System.Collections.Generic.IReadOnlyList)' does not exist in the implementation but it does exist in the contract. +Total Issues: 3 From 90fb76f364605928ef124e9e875066a4bcc10a60 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 15:50:11 +0100 Subject: [PATCH 199/314] Prevent exceptions when removing styles. When `_target.Owner` was null, the resource observable produced a `null` which may not be valid for the target property, resulting in an exception . Although the exception is caught, it slows things down. --- src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs b/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs index 250274c39b..fedd3469e6 100644 --- a/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs +++ b/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs @@ -147,13 +147,16 @@ namespace Avalonia.Controls { if (_target.Owner is object) { - observer.OnNext(Convert(_target.Owner?.FindResource(_key))); + observer.OnNext(Convert(_target.Owner.FindResource(_key))); } } private void PublishNext() { - PublishNext(Convert(_target.Owner?.FindResource(_key))); + if (_target.Owner is object) + { + PublishNext(Convert(_target.Owner.FindResource(_key))); + } } private void OwnerChanged(object sender, EventArgs e) From 4aa013a79e67e4152ec57b93ce4b1cbfc339212c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 16:25:07 +0100 Subject: [PATCH 200/314] Don't handle tab navigation in DefaultMenuInteractionHandler. Allow the default keyboard interaction handler to handle tab key presses in menus, because the logic in `DefaultMenuInteractionHandler` was causing the focus to get stuck in the menu. Also fix `NavigationDirection.IsDirectional` method. Fixes #5002. --- src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs | 2 +- src/Avalonia.Input/NavigationDirection.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs b/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs index a54d1ce308..5cbd3698b6 100644 --- a/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs +++ b/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs @@ -231,7 +231,7 @@ namespace Avalonia.Controls.Platform { var direction = e.Key.ToNavigationDirection(); - if (direction.HasValue) + if (direction?.IsDirectional() == true) { if (item == null && _isContextMenu) { diff --git a/src/Avalonia.Input/NavigationDirection.cs b/src/Avalonia.Input/NavigationDirection.cs index 9b9af0b0a6..9bd6a8bb42 100644 --- a/src/Avalonia.Input/NavigationDirection.cs +++ b/src/Avalonia.Input/NavigationDirection.cs @@ -83,7 +83,7 @@ namespace Avalonia.Input /// public static bool IsDirectional(this NavigationDirection direction) { - return direction > NavigationDirection.Previous || + return direction > NavigationDirection.Previous && direction <= NavigationDirection.PageDown; } From 4ab5cc4bbdf0dda18db79db1d389867fa6f36d41 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 23 Nov 2020 16:24:28 +0000 Subject: [PATCH 201/314] enable datavalidation on slider value property. --- src/Avalonia.Controls/Slider.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index 6e08e78813..fe4b24099f 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -3,6 +3,7 @@ using Avalonia.Collections; using Avalonia.Controls.Metadata; using Avalonia.Controls.Mixins; using Avalonia.Controls.Primitives; +using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Layout; @@ -94,6 +95,8 @@ namespace Avalonia.Controls Thumb.DragStartedEvent.AddClassHandler((x, e) => x.OnThumbDragStarted(e), RoutingStrategies.Bubble); Thumb.DragCompletedEvent.AddClassHandler((x, e) => x.OnThumbDragCompleted(e), RoutingStrategies.Bubble); + + ValueProperty.OverrideMetadata(new DirectPropertyMetadata(enableDataValidation: true)); } /// @@ -225,6 +228,14 @@ namespace Avalonia.Controls Value = IsSnapToTickEnabled ? SnapToTick(finalValue) : finalValue; } + protected override void UpdateDataValidation(AvaloniaProperty property, BindingValue value) + { + if (property == ValueProperty) + { + DataValidationErrors.SetError(this, value.Error); + } + } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); From b16820a230e566ed7606cdc7ed3a302f1f88c53e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 23:12:09 +0100 Subject: [PATCH 202/314] Added failing test for application resources. `DynamicResource` in `Application.Resources` fails to resolve resource. --- .../DynamicResourceExtensionTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/DynamicResourceExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/DynamicResourceExtensionTests.cs index 47a73cb360..9152131ab3 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/DynamicResourceExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/DynamicResourceExtensionTests.cs @@ -345,6 +345,23 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions Assert.Equal(0xff506070, brush.Color.ToUint32()); } + [Fact] + public void DynamicResource_Can_Be_Assigned_To_Resource_Property_In_Application() + { + var xaml = @" + + + #ff506070 + + +"; + + var application = (Application)AvaloniaRuntimeXamlLoader.Load(xaml); + var brush = (SolidColorBrush)application.Resources["brush"]; + + Assert.Equal(0xff506070, brush.Color.ToUint32()); + } [Fact] public void DynamicResource_Can_Be_Assigned_To_ItemTemplate_Property() From 64677edb8a50896baa9b15d1dbb81343c041da68 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 23:17:43 +0100 Subject: [PATCH 203/314] Fix resolving dynamic resource in Application. Instead of looking for an `IStyledElement` as an anchor, look for an `IResourceHost` because `Application` doesn't implement `IStyledElement` but it does implement `IResourceHost` and this interface has everything we need. --- .../Controls/ResourceNodeExtensions.cs | 6 +++--- .../DynamicResourceExtension.cs | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs b/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs index 250274c39b..9654d5d9e3 100644 --- a/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs +++ b/src/Avalonia.Styling/Controls/ResourceNodeExtensions.cs @@ -60,7 +60,7 @@ namespace Avalonia.Controls } public static IObservable GetResourceObservable( - this IStyledElement control, + this IResourceHost control, object key, Func? converter = null) { @@ -83,11 +83,11 @@ namespace Avalonia.Controls private class ResourceObservable : LightweightObservableBase { - private readonly IStyledElement _target; + private readonly IResourceHost _target; private readonly object _key; private readonly Func? _converter; - public ResourceObservable(IStyledElement target, object key, Func? converter) + public ResourceObservable(IResourceHost target, object key, Func? converter) { _target = target; _key = key; diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs index 03fd2e60dd..95380be65f 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs @@ -10,8 +10,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions { public class DynamicResourceExtension : IBinding { - private IStyledElement? _anchor; - private IResourceProvider? _resourceProvider; + private object? _anchor; public DynamicResourceExtension() { @@ -30,12 +29,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions if (!(provideTarget.TargetObject is IStyledElement)) { - _anchor = serviceProvider.GetFirstParent(); - - if (_anchor is null) - { - _resourceProvider = serviceProvider.GetFirstParent(); - } + _anchor = serviceProvider.GetFirstParent() ?? + serviceProvider.GetFirstParent() ?? + (object?)serviceProvider.GetFirstParent(); } return this; @@ -52,16 +48,16 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions return null; } - var control = target as IStyledElement ?? _anchor as IStyledElement; + var control = target as IResourceHost ?? _anchor as IResourceHost; if (control != null) { var source = control.GetResourceObservable(ResourceKey, GetConverter(targetProperty)); return InstancedBinding.OneWay(source); } - else if (_resourceProvider is object) + else if (_anchor is IResourceProvider resourceProvider) { - var source = _resourceProvider.GetResourceObservable(ResourceKey, GetConverter(targetProperty)); + var source = resourceProvider.GetResourceObservable(ResourceKey, GetConverter(targetProperty)); return InstancedBinding.OneWay(source); } From b989086c5f242feb1f06eb9cdc36de7be31eaf64 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 23 Nov 2020 23:27:16 +0100 Subject: [PATCH 204/314] Add breaking change. --- src/Avalonia.Styling/ApiCompatBaseline.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/Avalonia.Styling/ApiCompatBaseline.txt diff --git a/src/Avalonia.Styling/ApiCompatBaseline.txt b/src/Avalonia.Styling/ApiCompatBaseline.txt new file mode 100644 index 0000000000..001e165830 --- /dev/null +++ b/src/Avalonia.Styling/ApiCompatBaseline.txt @@ -0,0 +1,3 @@ +Compat issues with assembly Avalonia.Styling: +MembersMustExist : Member 'public System.IObservable Avalonia.Controls.ResourceNodeExtensions.GetResourceObservable(Avalonia.IStyledElement, System.Object, System.Func)' does not exist in the implementation but it does exist in the contract. +Total Issues: 1 From b488e882d448e4d758a609633ba334d4ac539fe7 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 24 Nov 2020 14:14:39 +0000 Subject: [PATCH 205/314] Add a background to PathIcon. --- src/Avalonia.Themes.Default/PathIcon.xaml | 15 +++++++++------ src/Avalonia.Themes.Fluent/PathIcon.xaml | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Themes.Default/PathIcon.xaml b/src/Avalonia.Themes.Default/PathIcon.xaml index a2d01f7b5b..039f0ef10c 100644 --- a/src/Avalonia.Themes.Default/PathIcon.xaml +++ b/src/Avalonia.Themes.Default/PathIcon.xaml @@ -2,16 +2,19 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> diff --git a/src/Avalonia.Themes.Fluent/PathIcon.xaml b/src/Avalonia.Themes.Fluent/PathIcon.xaml index 0a2c747514..d4952b3571 100644 --- a/src/Avalonia.Themes.Fluent/PathIcon.xaml +++ b/src/Avalonia.Themes.Fluent/PathIcon.xaml @@ -10,16 +10,19 @@ From c9f7461204df2a530d3e09d5df728aec0242f309 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 24 Nov 2020 16:47:00 -0500 Subject: [PATCH 206/314] Update build.md Update Mac instructions to use the build command --- Documentation/build.md | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Documentation/build.md b/Documentation/build.md index 45ee980e0b..5f75290424 100644 --- a/Documentation/build.md +++ b/Documentation/build.md @@ -60,23 +60,10 @@ git submodule update --init --recursive ### Build native libraries (macOS only) -On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). The steps to get this working correctly are: -- (for revisions after 2 Nov 2020) Run `./build.sh GenerateCppHeaders` to generate `avalonia-native.h` from `avn.idl` -- Navigate to the Avalonia/native/Avalonia.Native/src/OSX folder and open the `Avalonia.Native.OSX.xcodeproj` project -- Build the library via the Product->Build menu. This will generate binaries in your local path under ~/Library/Developer/Xcode/DerivedData/Avalonia.Native.OSX-*guid* where "guid" is uniquely generated every time you build. -- Manually install the native library by copying it from the build artifacts folder into the shared dynamic library path: - -``` -cd ~/Library/Developer/Xcode/DerivedData/Avalonia.Native.OSX-[guid]/Build/Products/Debug -cp libAvalonia.Native.OSX.dylib /usr/local/lib/libAvalonia.Native.OSX.dylib -``` - -For compilation we also need this library on the build path. From the Avalonia root project directory: - -``` -mkdir -p build/Products/Release -cp /usr/local/lib/libAvalonia.Native.OSX.dylib build/Products/Release +On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). Execute the build script in the root project with the `CompileNative` task. It will build the headers, build the libraries, and place them in the appropriate place to allow .NET to find them at compilation and run time. +```bash +./build.sh CompileNative ``` ### Build and Run Avalonia From f46a3b6138fbfbb19232e971b1d9b0ca0c39ff17 Mon Sep 17 00:00:00 2001 From: Luis von der Eltz Date: Wed, 25 Nov 2020 10:09:38 +0100 Subject: [PATCH 207/314] Set default visibility of scrollbar to "Visible" --- src/Avalonia.Controls/Primitives/ScrollBar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Primitives/ScrollBar.cs b/src/Avalonia.Controls/Primitives/ScrollBar.cs index a7fb7ae08c..d264ed76cc 100644 --- a/src/Avalonia.Controls/Primitives/ScrollBar.cs +++ b/src/Avalonia.Controls/Primitives/ScrollBar.cs @@ -35,7 +35,7 @@ namespace Avalonia.Controls.Primitives /// Defines the property. /// public static readonly StyledProperty VisibilityProperty = - AvaloniaProperty.Register(nameof(Visibility)); + AvaloniaProperty.Register(nameof(Visibility), ScrollBarVisibility.Visible); /// /// Defines the property. From dd1cbd1d8a03809a9202b6373f9b872604f289ec Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 22 Nov 2020 22:29:14 +0100 Subject: [PATCH 208/314] Add general purpose AST node for creating new Avalonia lists. Implement xaml compile time parsing of row/column definitions. --- src/Avalonia.Base/Collections/AvaloniaList.cs | 18 +++++++ ...aloniaXamlIlAvaloniaListConstantAstNode.cs | 54 +++++++++++++++++++ .../AvaloniaXamlIlLanguage.cs | 48 +++++++++++++++++ .../AvaloniaXamlIlWellKnownTypes.cs | 10 ++++ 4 files changed, 130 insertions(+) create mode 100644 src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlAvaloniaListConstantAstNode.cs diff --git a/src/Avalonia.Base/Collections/AvaloniaList.cs b/src/Avalonia.Base/Collections/AvaloniaList.cs index d43b4e04bb..5681214222 100644 --- a/src/Avalonia.Base/Collections/AvaloniaList.cs +++ b/src/Avalonia.Base/Collections/AvaloniaList.cs @@ -63,6 +63,15 @@ namespace Avalonia.Collections _inner = new List(); } + /// + /// Initializes a new instance of the . + /// + /// Initial list capacity. + public AvaloniaList(int capacity) + { + _inner = new List(capacity); + } + /// /// Initializes a new instance of the class. /// @@ -175,6 +184,15 @@ namespace Avalonia.Collections set { this[index] = (T)value; } } + /// + /// Gets or sets the total number of elements the internal data structure can hold without resizing. + /// + public int Capacity + { + get => _inner.Capacity; + set => _inner.Capacity = value; + } + /// /// Adds an item to the collection. /// diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlAvaloniaListConstantAstNode.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlAvaloniaListConstantAstNode.cs new file mode 100644 index 0000000000..0f4efc9f65 --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AstNodes/AvaloniaXamlIlAvaloniaListConstantAstNode.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using Avalonia.Controls; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using XamlX.Ast; +using XamlX.Emit; +using XamlX.IL; +using XamlX.TypeSystem; + +namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes +{ + class AvaloniaXamlIlAvaloniaListConstantAstNode : XamlAstNode, IXamlAstValueNode, IXamlAstILEmitableNode + { + private readonly IXamlType _elementType; + private readonly IReadOnlyList _values; + private readonly IXamlConstructor _constructor; + private readonly IXamlMethod _listAddMethod; + private readonly IXamlMethod _listSetCapacityMethod; + + public AvaloniaXamlIlAvaloniaListConstantAstNode(IXamlLineInfo lineInfo, AvaloniaXamlIlWellKnownTypes types, IXamlType listType, IXamlType elementType, IReadOnlyList values) : base(lineInfo) + { + _constructor = listType.GetConstructor(); + _listAddMethod = listType.GetMethod(new FindMethodMethodSignature("Add", types.XamlIlTypes.Void, elementType)); + _listSetCapacityMethod = listType.GetMethod(new FindMethodMethodSignature("set_Capacity", types.XamlIlTypes.Void, types.Int)); + + _elementType = elementType; + _values = values; + + Type = new XamlAstClrTypeReference(lineInfo, listType, false); + } + + public IXamlAstTypeReference Type { get; } + + public XamlILNodeEmitResult Emit(XamlEmitContext context, IXamlILEmitter codeGen) + { + codeGen.Newobj(_constructor); + + codeGen + .Dup() + .Ldc_I4(_values.Count) + .EmitCall(_listSetCapacityMethod); + + foreach (var value in _values) + { + codeGen.Dup(); + + context.Emit(value, codeGen, _elementType); + + codeGen.EmitCall(_listAddMethod); + } + + return XamlILNodeEmitResult.Type(0, Type.GetClrType()); + } + } +} diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 40cfd21a76..10c5e615bb 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -353,6 +353,16 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions } } + if (type.Equals(types.ColumnDefinitions)) + { + return ConvertDefinitionList(node, text, types, types.ColumnDefinitions, types.ColumnDefinition, "column definitions", out result); + } + + if (type.Equals(types.RowDefinitions)) + { + return ConvertDefinitionList(node, text, types, types.RowDefinitions, types.RowDefinition, "row definitions", out result); + } + if (type.FullName == "Avalonia.AvaloniaProperty") { var scope = context.ParentNodes().OfType().FirstOrDefault(); @@ -366,5 +376,43 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions result = null; return false; } + + private static bool ConvertDefinitionList( + IXamlAstValueNode node, + string text, + AvaloniaXamlIlWellKnownTypes types, + IXamlType listType, + IXamlType elementType, + string errorDisplayName, + out IXamlAstValueNode result) + { + try + { + var lengths = GridLength.ParseLengths(text); + + var definitionTypeRef = new XamlAstClrTypeReference(node, elementType, false); + + var definitionConstructorGridLength = elementType.GetConstructor(new List {types.GridLength}); + + IXamlAstValueNode CreateDefinitionNode(GridLength length) + { + var lengthNode = new AvaloniaXamlIlGridLengthAstNode(node, types, length); + + return new XamlAstNewClrObjectNode(node, definitionTypeRef, + definitionConstructorGridLength, new List {lengthNode}); + } + + var definitionNodes = + new List(lengths.Select(CreateDefinitionNode)); + + result = new AvaloniaXamlIlAvaloniaListConstantAstNode(node, types, listType, elementType, definitionNodes); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a {errorDisplayName}", node); + } + } } } diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index f046778429..125701ca9e 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -50,6 +50,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType RelativeSource { get; } public IXamlType UInt { get; } + public IXamlType Int { get; } public IXamlType Long { get; } public IXamlType Uri { get; } public IXamlType FontFamily { get; } @@ -72,6 +73,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType StandardCursorType { get; } public IXamlType Cursor { get; } public IXamlConstructor CursorTypeConstructor { get; } + public IXamlType RowDefinition { get; } + public IXamlType RowDefinitions { get; } + public IXamlType ColumnDefinition { get; } + public IXamlType ColumnDefinitions { get; } public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg) { @@ -130,6 +135,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers ReflectionBindingExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension"); RelativeSource = cfg.TypeSystem.GetType("Avalonia.Data.RelativeSource"); UInt = cfg.TypeSystem.GetType("System.UInt32"); + Int = cfg.TypeSystem.GetType("System.Int32"); Long = cfg.TypeSystem.GetType("System.Int64"); Uri = cfg.TypeSystem.GetType("System.Uri"); FontFamily = cfg.TypeSystem.GetType("Avalonia.Media.FontFamily"); @@ -156,6 +162,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers StandardCursorType = cfg.TypeSystem.GetType("Avalonia.Input.StandardCursorType"); Cursor = cfg.TypeSystem.GetType("Avalonia.Input.Cursor"); CursorTypeConstructor = Cursor.GetConstructor(new List { StandardCursorType }); + ColumnDefinition = cfg.TypeSystem.GetType("Avalonia.Controls.ColumnDefinition"); + ColumnDefinitions = cfg.TypeSystem.GetType("Avalonia.Controls.ColumnDefinitions"); + RowDefinition = cfg.TypeSystem.GetType("Avalonia.Controls.RowDefinition"); + RowDefinitions = cfg.TypeSystem.GetType("Avalonia.Controls.RowDefinitions"); } } From aefa58bdc4b1dabf5f8bb8832867b01ca5e39d26 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 22 Nov 2020 22:43:25 +0100 Subject: [PATCH 209/314] Optimize DefinitionList collection changed handler. --- src/Avalonia.Controls/DefinitionList.cs | 60 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/src/Avalonia.Controls/DefinitionList.cs b/src/Avalonia.Controls/DefinitionList.cs index bb815171c0..ad0e2513c4 100644 --- a/src/Avalonia.Controls/DefinitionList.cs +++ b/src/Avalonia.Controls/DefinitionList.cs @@ -1,8 +1,9 @@ -using System; +using System.Collections; using System.Collections.Specialized; -using System.Linq; using Avalonia.Collections; +#nullable enable + namespace Avalonia.Controls { public abstract class DefinitionList : AvaloniaList where T : DefinitionBase @@ -14,44 +15,65 @@ namespace Avalonia.Controls } internal bool IsDirty = true; - private Grid _parent; + private Grid? _parent; - internal Grid Parent + internal Grid? Parent { get => _parent; set => SetParent(value); } - private void SetParent(Grid value) + private void SetParent(Grid? value) { _parent = value; - foreach (var pair in this.Select((definitions, index) => (definitions, index))) + var idx = 0; + + foreach (T definition in this) { - pair.definitions.Parent = value; - pair.definitions.Index = pair.index; + definition.Parent = value; + definition.Index = idx++; } } internal void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { - foreach (var nI in this.Select((d, i) => (d, i))) - nI.d._parentIndex = nI.i; + var idx = 0; - foreach (var nD in e.NewItems?.Cast() - ?? Enumerable.Empty()) + foreach (T definition in this) { - nD.Parent = this.Parent; - nD.OnEnterParentTree(); + definition.Index = idx++; } + + UpdateDefinitionParent(e.NewItems, false); + UpdateDefinitionParent(e.OldItems, true); + + IsDirty = true; + } - foreach (var oD in e.OldItems?.Cast() - ?? Enumerable.Empty()) + private void UpdateDefinitionParent(IList? items, bool wasRemoved) + { + if (items is null) { - oD.OnExitParentTree(); + return; } + + var count = items.Count; - IsDirty = true; + for (var i = 0; i < count; i++) + { + var definition = (DefinitionBase) items[i]; + + if (wasRemoved) + { + definition.OnExitParentTree(); + } + else + { + definition.Parent = Parent; + definition.OnEnterParentTree(); + } + } } } -} \ No newline at end of file +} From 8a2701c84b0e8f7daac2a3ff06be5f440d073b20 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Wed, 25 Nov 2020 12:48:45 +0100 Subject: [PATCH 210/314] Move parsing code to a separate file. --- .../AvaloniaXamlIlLanguage.cs | 219 +--------------- .../AvaloniaXamlIlLanguageParseIntrinsics.cs | 243 ++++++++++++++++++ 2 files changed, 244 insertions(+), 218 deletions(-) create mode 100644 src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs index 10c5e615bb..a82f5b9e60 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguage.cs @@ -177,192 +177,13 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions } var text = textNode.Text; - var types = context.GetAvaloniaTypes(); - if (type.FullName == "System.TimeSpan") - { - var tsText = text.Trim(); - - if (!TimeSpan.TryParse(tsText, CultureInfo.InvariantCulture, out var timeSpan)) - { - // // shorthand seconds format (ie. "0.25") - if (!tsText.Contains(":") && double.TryParse(tsText, - NumberStyles.Float | NumberStyles.AllowThousands, - CultureInfo.InvariantCulture, out var seconds)) - timeSpan = TimeSpan.FromSeconds(seconds); - else - throw new XamlX.XamlLoadException($"Unable to parse {text} as a time span", node); - } - - - result = new XamlStaticOrTargetedReturnMethodCallNode(node, - type.FindMethod("FromTicks", type, false, types.Long), - new[] { new XamlConstantNode(node, types.Long, timeSpan.Ticks) }); - return true; - } - - if (type.Equals(types.FontFamily)) + if (AvaloniaXamlIlLanguageParseIntrinsics.TryConvert(context, node, text, type, types, out result)) { - result = new AvaloniaXamlIlFontFamilyAstNode(types, text, node); return true; } - - if (type.Equals(types.Thickness)) - { - try - { - var thickness = Thickness.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Thickness, types.ThicknessFullConstructor, - new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a thickness", node); - } - } - - if (type.Equals(types.Point)) - { - try - { - var point = Point.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Point, types.PointFullConstructor, - new[] { point.X, point.Y }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a point", node); - } - } - - if (type.Equals(types.Vector)) - { - try - { - var vector = Vector.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Vector, types.VectorFullConstructor, - new[] { vector.X, vector.Y }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a vector", node); - } - } - - if (type.Equals(types.Size)) - { - try - { - var size = Size.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Size, types.SizeFullConstructor, - new[] { size.Width, size.Height }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a size", node); - } - } - - if (type.Equals(types.Matrix)) - { - try - { - var matrix = Matrix.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Matrix, types.MatrixFullConstructor, - new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a matrix", node); - } - } - if (type.Equals(types.CornerRadius)) - { - try - { - var cornerRadius = CornerRadius.Parse(text); - - result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.CornerRadius, types.CornerRadiusFullConstructor, - new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a corner radius", node); - } - } - - if (type.Equals(types.Color)) - { - if (!Color.TryParse(text, out Color color)) - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a color", node); - } - - result = new XamlStaticOrTargetedReturnMethodCallNode(node, - type.GetMethod( - new FindMethodMethodSignature("FromUInt32", type, types.UInt) { IsStatic = true }), - new[] { new XamlConstantNode(node, types.UInt, color.ToUint32()) }); - - return true; - } - - if (type.Equals(types.GridLength)) - { - try - { - var gridLength = GridLength.Parse(text); - - result = new AvaloniaXamlIlGridLengthAstNode(node, types, gridLength); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a grid length", node); - } - } - - if (type.Equals(types.Cursor)) - { - if (TypeSystemHelpers.TryGetEnumValueNode(types.StandardCursorType, text, node, out var enumConstantNode)) - { - var cursorTypeRef = new XamlAstClrTypeReference(node, types.Cursor, false); - - result = new XamlAstNewClrObjectNode(node, cursorTypeRef, types.CursorTypeConstructor, new List { enumConstantNode }); - - return true; - } - } - - if (type.Equals(types.ColumnDefinitions)) - { - return ConvertDefinitionList(node, text, types, types.ColumnDefinitions, types.ColumnDefinition, "column definitions", out result); - } - - if (type.Equals(types.RowDefinitions)) - { - return ConvertDefinitionList(node, text, types, types.RowDefinitions, types.RowDefinition, "row definitions", out result); - } - if (type.FullName == "Avalonia.AvaloniaProperty") { var scope = context.ParentNodes().OfType().FirstOrDefault(); @@ -376,43 +197,5 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions result = null; return false; } - - private static bool ConvertDefinitionList( - IXamlAstValueNode node, - string text, - AvaloniaXamlIlWellKnownTypes types, - IXamlType listType, - IXamlType elementType, - string errorDisplayName, - out IXamlAstValueNode result) - { - try - { - var lengths = GridLength.ParseLengths(text); - - var definitionTypeRef = new XamlAstClrTypeReference(node, elementType, false); - - var definitionConstructorGridLength = elementType.GetConstructor(new List {types.GridLength}); - - IXamlAstValueNode CreateDefinitionNode(GridLength length) - { - var lengthNode = new AvaloniaXamlIlGridLengthAstNode(node, types, length); - - return new XamlAstNewClrObjectNode(node, definitionTypeRef, - definitionConstructorGridLength, new List {lengthNode}); - } - - var definitionNodes = - new List(lengths.Select(CreateDefinitionNode)); - - result = new AvaloniaXamlIlAvaloniaListConstantAstNode(node, types, listType, elementType, definitionNodes); - - return true; - } - catch - { - throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a {errorDisplayName}", node); - } - } } } diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs new file mode 100644 index 0000000000..7c4cc8d28b --- /dev/null +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs @@ -0,0 +1,243 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using Avalonia.Controls; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes; +using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; +using Avalonia.Media; +using XamlX.Ast; +using XamlX.Transform; +using XamlX.TypeSystem; + +namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions +{ + class AvaloniaXamlIlLanguageParseIntrinsics + { + public static bool TryConvert(AstTransformationContext context, IXamlAstValueNode node, string text, IXamlType type, AvaloniaXamlIlWellKnownTypes types, out IXamlAstValueNode result) + { + if (type.FullName == "System.TimeSpan") + { + var tsText = text.Trim(); + + if (!TimeSpan.TryParse(tsText, CultureInfo.InvariantCulture, out var timeSpan)) + { + // // shorthand seconds format (ie. "0.25") + if (!tsText.Contains(":") && double.TryParse(tsText, + NumberStyles.Float | NumberStyles.AllowThousands, + CultureInfo.InvariantCulture, out var seconds)) + timeSpan = TimeSpan.FromSeconds(seconds); + else + throw new XamlX.XamlLoadException($"Unable to parse {text} as a time span", node); + } + + result = new XamlStaticOrTargetedReturnMethodCallNode(node, + type.FindMethod("FromTicks", type, false, types.Long), + new[] { new XamlConstantNode(node, types.Long, timeSpan.Ticks) }); + return true; + } + + if (type.Equals(types.FontFamily)) + { + result = new AvaloniaXamlIlFontFamilyAstNode(types, text, node); + return true; + } + + if (type.Equals(types.Thickness)) + { + try + { + var thickness = Thickness.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Thickness, types.ThicknessFullConstructor, + new[] { thickness.Left, thickness.Top, thickness.Right, thickness.Bottom }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a thickness", node); + } + } + + if (type.Equals(types.Point)) + { + try + { + var point = Point.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Point, types.PointFullConstructor, + new[] { point.X, point.Y }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a point", node); + } + } + + if (type.Equals(types.Vector)) + { + try + { + var vector = Vector.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Vector, types.VectorFullConstructor, + new[] { vector.X, vector.Y }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a vector", node); + } + } + + if (type.Equals(types.Size)) + { + try + { + var size = Size.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Size, types.SizeFullConstructor, + new[] { size.Width, size.Height }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a size", node); + } + } + + if (type.Equals(types.Matrix)) + { + try + { + var matrix = Matrix.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.Matrix, types.MatrixFullConstructor, + new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32 }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a matrix", node); + } + } + + if (type.Equals(types.CornerRadius)) + { + try + { + var cornerRadius = CornerRadius.Parse(text); + + result = new AvaloniaXamlIlVectorLikeConstantAstNode(node, types, types.CornerRadius, types.CornerRadiusFullConstructor, + new[] { cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft }); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a corner radius", node); + } + } + + if (type.Equals(types.Color)) + { + if (!Color.TryParse(text, out Color color)) + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a color", node); + } + + result = new XamlStaticOrTargetedReturnMethodCallNode(node, + type.GetMethod( + new FindMethodMethodSignature("FromUInt32", type, types.UInt) { IsStatic = true }), + new[] { new XamlConstantNode(node, types.UInt, color.ToUint32()) }); + + return true; + } + + if (type.Equals(types.GridLength)) + { + try + { + var gridLength = GridLength.Parse(text); + + result = new AvaloniaXamlIlGridLengthAstNode(node, types, gridLength); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a grid length", node); + } + } + + if (type.Equals(types.Cursor)) + { + if (TypeSystemHelpers.TryGetEnumValueNode(types.StandardCursorType, text, node, out var enumConstantNode)) + { + var cursorTypeRef = new XamlAstClrTypeReference(node, types.Cursor, false); + + result = new XamlAstNewClrObjectNode(node, cursorTypeRef, types.CursorTypeConstructor, new List { enumConstantNode }); + + return true; + } + } + + if (type.Equals(types.ColumnDefinitions)) + { + return ConvertDefinitionList(node, text, types, types.ColumnDefinitions, types.ColumnDefinition, "column definitions", out result); + } + + if (type.Equals(types.RowDefinitions)) + { + return ConvertDefinitionList(node, text, types, types.RowDefinitions, types.RowDefinition, "row definitions", out result); + } + + result = null; + return false; + } + + private static bool ConvertDefinitionList( + IXamlAstValueNode node, + string text, + AvaloniaXamlIlWellKnownTypes types, + IXamlType listType, + IXamlType elementType, + string errorDisplayName, + out IXamlAstValueNode result) + { + try + { + var lengths = GridLength.ParseLengths(text); + + var definitionTypeRef = new XamlAstClrTypeReference(node, elementType, false); + + var definitionConstructorGridLength = elementType.GetConstructor(new List {types.GridLength}); + + IXamlAstValueNode CreateDefinitionNode(GridLength length) + { + var lengthNode = new AvaloniaXamlIlGridLengthAstNode(node, types, length); + + return new XamlAstNewClrObjectNode(node, definitionTypeRef, + definitionConstructorGridLength, new List {lengthNode}); + } + + var definitionNodes = + new List(lengths.Select(CreateDefinitionNode)); + + result = new AvaloniaXamlIlAvaloniaListConstantAstNode(node, types, listType, elementType, definitionNodes); + + return true; + } + catch + { + throw new XamlX.XamlLoadException($"Unable to parse \"{text}\" as a {errorDisplayName}", node); + } + } + } +} From 286ca73fdd417c363991b3d790e57d030835826b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 25 Nov 2020 15:15:30 +0100 Subject: [PATCH 211/314] Prevent hangs on win32 in case of clipboard errors. --- src/Windows/Avalonia.Win32/ClipboardImpl.cs | 37 +++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/ClipboardImpl.cs b/src/Windows/Avalonia.Win32/ClipboardImpl.cs index 7d9e0a8bd2..0475a9d607 100644 --- a/src/Windows/Avalonia.Win32/ClipboardImpl.cs +++ b/src/Windows/Avalonia.Win32/ClipboardImpl.cs @@ -12,6 +12,9 @@ namespace Avalonia.Win32 { internal class ClipboardImpl : IClipboard { + private const int OleRetryCount = 10; + private const int OleRetryDelay = 100; + private async Task OpenClipboard() { while (!UnmanagedMethods.OpenClipboard(IntPtr.Zero)) @@ -72,20 +75,32 @@ namespace Avalonia.Win32 { Dispatcher.UIThread.VerifyAccess(); var wrapper = new DataObject(data); + var i = OleRetryCount; + while (true) { - if (UnmanagedMethods.OleSetClipboard(wrapper) == 0) + var hr = UnmanagedMethods.OleSetClipboard(wrapper); + + if (hr == 0) break; - await Task.Delay(100); + + if (--i == 0) + Marshal.ThrowExceptionForHR(hr); + + await Task.Delay(OleRetryDelay); } } public async Task GetFormatsAsync() { Dispatcher.UIThread.VerifyAccess(); + var i = OleRetryCount; + while (true) { - if (UnmanagedMethods.OleGetClipboard(out var dataObject) == 0) + var hr = UnmanagedMethods.OleGetClipboard(out var dataObject); + + if (hr == 0) { var wrapper = new OleDataObject(dataObject); var formats = wrapper.GetDataFormats().ToArray(); @@ -93,16 +108,23 @@ namespace Avalonia.Win32 return formats; } - await Task.Delay(100); + if (--i == 0) + Marshal.ThrowExceptionForHR(hr); + + await Task.Delay(OleRetryDelay); } } public async Task GetDataAsync(string format) { Dispatcher.UIThread.VerifyAccess(); + var i = OleRetryCount; + while (true) { - if (UnmanagedMethods.OleGetClipboard(out var dataObject) == 0) + var hr = UnmanagedMethods.OleGetClipboard(out var dataObject); + + if (hr == 0) { var wrapper = new OleDataObject(dataObject); var rv = wrapper.Get(format); @@ -110,7 +132,10 @@ namespace Avalonia.Win32 return rv; } - await Task.Delay(100); + if (--i == 0) + Marshal.ThrowExceptionForHR(hr); + + await Task.Delay(OleRetryDelay); } } } From a088910f313635144559d3eabc9b007d6a15ac98 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 25 Nov 2020 19:06:37 +0000 Subject: [PATCH 212/314] Add OSX implementation. --- native/Avalonia.Native/src/OSX/window.mm | 8 ++++---- src/Avalonia.Native/PopupImpl.cs | 4 ++-- src/Avalonia.Native/WindowImplBase.cs | 4 ++-- src/Avalonia.Native/avn.idl | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index e3996a1fae..8419258fe9 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -106,13 +106,13 @@ public: return Window; } - virtual HRESULT Show() override + virtual HRESULT Show(bool activate) override { @autoreleasepool { SetPosition(lastPositionSet); UpdateStyle(); - if(ShouldTakeFocusOnShow()) + if(ShouldTakeFocusOnShow() && activate) { [Window makeKeyAndOrderFront:Window]; [NSApp activateIgnoringOtherApps:YES]; @@ -561,11 +561,11 @@ private: } } - virtual HRESULT Show () override + virtual HRESULT Show (bool activate) override { @autoreleasepool { - WindowBaseImpl::Show(); + WindowBaseImpl::Show(activate); HideOrShowTrafficLights(); diff --git a/src/Avalonia.Native/PopupImpl.cs b/src/Avalonia.Native/PopupImpl.cs index 60c552a937..c36675afcd 100644 --- a/src/Avalonia.Native/PopupImpl.cs +++ b/src/Avalonia.Native/PopupImpl.cs @@ -60,14 +60,14 @@ namespace Avalonia.Native } } - public override void Show() + public override void Show(bool activate) { var parent = _parent; while (parent is PopupImpl p) parent = p._parent; if (parent is WindowImpl w) w.Native.TakeFocusFromChildren(); - base.Show(); + base.Show(false); } public override IPopupImpl CreatePopup() => new PopupImpl(_factory, _opts, _glFeature, this); diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 88c3144884..927b739b0c 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -351,9 +351,9 @@ namespace Avalonia.Native } - public virtual void Show() + public virtual void Show(bool activate) { - _native.Show(); + _native.Show(activate.AsComBool()); } diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index 3f33476c3d..4f7e5833a3 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -225,7 +225,7 @@ interface IAvnString : IUnknown [uuid(e5aca675-02b7-4129-aa79-d6e417210bda)] interface IAvnWindowBase : IUnknown { - HRESULT Show(); + HRESULT Show(bool activate); HRESULT Hide(); HRESULT Close(); HRESULT Activate(); From 43078d720a6ca398795cbb081e4b588c2ca94425 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 25 Nov 2020 19:07:17 +0000 Subject: [PATCH 213/314] fix apicompat baselines. --- .../ApiCompatBaseline.txt | 6 +--- src/Avalonia.Controls/ApiCompatBaseline.txt | 29 +++---------------- .../ApiCompatBaseline.txt | 5 +--- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/ApiCompatBaseline.txt b/src/Avalonia.Controls.DataGrid/ApiCompatBaseline.txt index 82472c505a..fcc74cf864 100644 --- a/src/Avalonia.Controls.DataGrid/ApiCompatBaseline.txt +++ b/src/Avalonia.Controls.DataGrid/ApiCompatBaseline.txt @@ -1,5 +1 @@ -Compat issues with assembly Avalonia.Controls.DataGrid: -MembersMustExist : Member 'public Avalonia.StyledProperty Avalonia.StyledProperty Avalonia.Controls.DataGridTextColumn.FontFamilyProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public System.String Avalonia.Controls.DataGridTextColumn.FontFamily.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.DataGridTextColumn.FontFamily.set(System.String)' does not exist in the implementation but it does exist in the contract. -Total Issues: 3 +Total Issues: 0 diff --git a/src/Avalonia.Controls/ApiCompatBaseline.txt b/src/Avalonia.Controls/ApiCompatBaseline.txt index 16c801201c..7488ef8149 100644 --- a/src/Avalonia.Controls/ApiCompatBaseline.txt +++ b/src/Avalonia.Controls/ApiCompatBaseline.txt @@ -1,26 +1,5 @@ Compat issues with assembly Avalonia.Controls: -TypesMustExist : Type 'Avalonia.Controls.IndexPath' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.ISelectedItemInfo' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.ISelectionModel' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.DirectProperty Avalonia.DirectProperty Avalonia.Controls.ListBox.SelectionProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Controls.ISelectionModel Avalonia.Controls.ListBox.Selection.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.ListBox.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.SelectionModel' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.SelectionModelChildrenRequestedEventArgs' does not exist in the implementation but it does exist in the contract. -TypesMustExist : Type 'Avalonia.Controls.SelectionModelSelectionChangedEventArgs' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.StyledProperty Avalonia.StyledProperty Avalonia.Controls.SplitView.ContentProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.StyledProperty Avalonia.StyledProperty Avalonia.Controls.SplitView.PaneProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Controls.IControl Avalonia.Controls.SplitView.Content.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.SplitView.Content.set(Avalonia.Controls.IControl)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Controls.IControl Avalonia.Controls.SplitView.Pane.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.SplitView.Pane.set(Avalonia.Controls.IControl)' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.DirectProperty Avalonia.DirectProperty Avalonia.Controls.TreeView.SelectionProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Interactivity.RoutedEvent Avalonia.Interactivity.RoutedEvent Avalonia.Controls.TreeView.SelectionChangedEvent' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public Avalonia.Controls.ISelectionModel Avalonia.Controls.TreeView.Selection.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Controls.TreeView.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public System.String[] Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.Args' is present in the implementation but not in the contract. -InterfacesShouldHaveSameMembers : Interface member 'public System.String[] Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.Args.get()' is present in the implementation but not in the contract. -MembersMustExist : Member 'public Avalonia.DirectProperty Avalonia.DirectProperty Avalonia.Controls.Primitives.SelectingItemsControl.SelectionProperty' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'protected Avalonia.Controls.ISelectionModel Avalonia.Controls.Primitives.SelectingItemsControl.Selection.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'protected void Avalonia.Controls.Primitives.SelectingItemsControl.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. -Total Issues: 24 +InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.IWindowBaseImpl.Show()' is present in the contract but not in the implementation. +MembersMustExist : Member 'public void Avalonia.Platform.IWindowBaseImpl.Show()' does not exist in the implementation but it does exist in the contract. +InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.IWindowBaseImpl.Show(System.Boolean)' is present in the implementation but not in the contract. +Total Issues: 3 diff --git a/src/Markup/Avalonia.Markup.Xaml/ApiCompatBaseline.txt b/src/Markup/Avalonia.Markup.Xaml/ApiCompatBaseline.txt index c87dcacda4..fcc74cf864 100644 --- a/src/Markup/Avalonia.Markup.Xaml/ApiCompatBaseline.txt +++ b/src/Markup/Avalonia.Markup.Xaml/ApiCompatBaseline.txt @@ -1,4 +1 @@ -Compat issues with assembly Avalonia.Markup.Xaml: -MembersMustExist : Member 'public Avalonia.Data.Binding Avalonia.Markup.Xaml.Templates.TreeDataTemplate.ItemsSource.get()' does not exist in the implementation but it does exist in the contract. -MembersMustExist : Member 'public void Avalonia.Markup.Xaml.Templates.TreeDataTemplate.ItemsSource.set(Avalonia.Data.Binding)' does not exist in the implementation but it does exist in the contract. -Total Issues: 2 +Total Issues: 0 From d438e0e954c8b3e8d6e29eb1a996f0f86b5d77c1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 26 Nov 2020 09:41:19 +0100 Subject: [PATCH 214/314] Prevent infinite loop on OpenClipboard. --- src/Windows/Avalonia.Win32/ClipboardImpl.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Windows/Avalonia.Win32/ClipboardImpl.cs b/src/Windows/Avalonia.Win32/ClipboardImpl.cs index 0475a9d607..047b7c361f 100644 --- a/src/Windows/Avalonia.Win32/ClipboardImpl.cs +++ b/src/Windows/Avalonia.Win32/ClipboardImpl.cs @@ -17,8 +17,12 @@ namespace Avalonia.Win32 private async Task OpenClipboard() { + var i = OleRetryCount; + while (!UnmanagedMethods.OpenClipboard(IntPtr.Zero)) { + if (--i == 0) + throw new TimeoutException("Timeout opening clipboard."); await Task.Delay(100); } From 0cb25c78c95dd382a8368bd422c8ec3222ceff3e Mon Sep 17 00:00:00 2001 From: Loris Bognanni Date: Thu, 26 Nov 2020 09:01:08 +0000 Subject: [PATCH 215/314] Only handle the Enter key when the DropDown is open Fixes #5106 --- src/Avalonia.Controls/AutoCompleteBox.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox.cs index bfd633c947..b59fd7abde 100644 --- a/src/Avalonia.Controls/AutoCompleteBox.cs +++ b/src/Avalonia.Controls/AutoCompleteBox.cs @@ -1405,8 +1405,11 @@ namespace Avalonia.Controls break; case Key.Enter: - OnAdapterSelectionComplete(this, new RoutedEventArgs()); - e.Handled = true; + if (IsDropDownOpen) + { + OnAdapterSelectionComplete(this, new RoutedEventArgs()); + e.Handled = true; + } break; default: From 0e7e861009721dd7f0c1c964d5732d4105dab8cf Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 26 Nov 2020 12:13:58 +0100 Subject: [PATCH 216/314] Fix TransformToVisual not dealing with non-invertible transforms. --- src/Avalonia.Visuals/Matrix.cs | 25 ++++++++++++++++--- src/Avalonia.Visuals/VisualExtensions.cs | 10 +++++++- .../Avalonia.Visuals.UnitTests/VisualTests.cs | 19 ++++++++++++++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Visuals/Matrix.cs b/src/Avalonia.Visuals/Matrix.cs index 2ccfd43f03..ea7d0d63af 100644 --- a/src/Avalonia.Visuals/Matrix.cs +++ b/src/Avalonia.Visuals/Matrix.cs @@ -282,16 +282,16 @@ namespace Avalonia } /// - /// Inverts the Matrix. + /// Attempts to invert the Matrix. /// - /// The inverted matrix. - public Matrix Invert() + /// The inverted matrix or when matrix is not invertible. + public Matrix? TryInvert() { double d = GetDeterminant(); if (MathUtilities.IsZero(d)) { - throw new InvalidOperationException("Transform is not invertible."); + return null; } return new Matrix( @@ -303,6 +303,23 @@ namespace Avalonia ((_m12 * _m31) - (_m11 * _m32)) / d); } + /// + /// Inverts the Matrix. + /// + /// Matrix is not invertible. + /// The inverted matrix. + public Matrix Invert() + { + Matrix? inverted = TryInvert(); + + if (!inverted.HasValue) + { + throw new InvalidOperationException("Transform is not invertible."); + } + + return inverted.Value; + } + /// /// Parses a string. /// diff --git a/src/Avalonia.Visuals/VisualExtensions.cs b/src/Avalonia.Visuals/VisualExtensions.cs index 6079e5941f..6875e2c55a 100644 --- a/src/Avalonia.Visuals/VisualExtensions.cs +++ b/src/Avalonia.Visuals/VisualExtensions.cs @@ -50,7 +50,15 @@ namespace Avalonia { var thisOffset = GetOffsetFrom(common, from); var thatOffset = GetOffsetFrom(common, to); - return -thatOffset * thisOffset; + + var thatOffsetInverted = thatOffset.TryInvert(); + + if (!thatOffsetInverted.HasValue) + { + return null; + } + + return thatOffsetInverted.Value * thisOffset; } return null; diff --git a/tests/Avalonia.Visuals.UnitTests/VisualTests.cs b/tests/Avalonia.Visuals.UnitTests/VisualTests.cs index 447a68aa69..38131fbfca 100644 --- a/tests/Avalonia.Visuals.UnitTests/VisualTests.cs +++ b/tests/Avalonia.Visuals.UnitTests/VisualTests.cs @@ -235,6 +235,25 @@ namespace Avalonia.Visuals.UnitTests Assert.Equal(new Point(100, 100), point); } + [Fact] + public void TransformToVisual_With_NonInvertible_RenderTransform_Should_Work() + { + var child = new Decorator + { + Width = 100, + Height = 100, + RenderTransform = new ScaleTransform() { ScaleX = 0, ScaleY = 0 } + }; + var root = new TestRoot() { Child = child, Width = 400, Height = 400 }; + + root.Measure(Size.Infinity); + root.Arrange(new Rect(new Point(), root.DesiredSize)); + + var tr = root.TransformToVisual(child); + + Assert.Null(tr); + } + [Fact] public void Should_Not_Log_Binding_Error_When_Not_Attached_To_Logical_Tree() { From 713d4698ee66fc524eb480e69e7f14778b682e56 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 26 Nov 2020 12:25:35 +0100 Subject: [PATCH 217/314] Use different Try convention. --- src/Avalonia.Visuals/Matrix.cs | 16 +++++++++------- src/Avalonia.Visuals/VisualExtensions.cs | 8 +++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Visuals/Matrix.cs b/src/Avalonia.Visuals/Matrix.cs index ea7d0d63af..8136f843df 100644 --- a/src/Avalonia.Visuals/Matrix.cs +++ b/src/Avalonia.Visuals/Matrix.cs @@ -285,22 +285,26 @@ namespace Avalonia /// Attempts to invert the Matrix. /// /// The inverted matrix or when matrix is not invertible. - public Matrix? TryInvert() + public bool TryInvert(out Matrix inverted) { double d = GetDeterminant(); if (MathUtilities.IsZero(d)) { - return null; + inverted = default; + + return false; } - return new Matrix( + inverted = new Matrix( _m22 / d, -_m12 / d, -_m21 / d, _m11 / d, ((_m21 * _m32) - (_m22 * _m31)) / d, ((_m12 * _m31) - (_m11 * _m32)) / d); + + return true; } /// @@ -310,14 +314,12 @@ namespace Avalonia /// The inverted matrix. public Matrix Invert() { - Matrix? inverted = TryInvert(); - - if (!inverted.HasValue) + if (!TryInvert(out Matrix inverted)) { throw new InvalidOperationException("Transform is not invertible."); } - return inverted.Value; + return inverted; } /// diff --git a/src/Avalonia.Visuals/VisualExtensions.cs b/src/Avalonia.Visuals/VisualExtensions.cs index 6875e2c55a..e6523a1469 100644 --- a/src/Avalonia.Visuals/VisualExtensions.cs +++ b/src/Avalonia.Visuals/VisualExtensions.cs @@ -51,14 +51,12 @@ namespace Avalonia var thisOffset = GetOffsetFrom(common, from); var thatOffset = GetOffsetFrom(common, to); - var thatOffsetInverted = thatOffset.TryInvert(); - - if (!thatOffsetInverted.HasValue) + if (!thatOffset.TryInvert(out var thatOffsetInverted)) { return null; } - - return thatOffsetInverted.Value * thisOffset; + + return thatOffsetInverted * thisOffset; } return null; From 55967506345e289c5328e54e7991988f314e8af7 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 26 Nov 2020 11:36:47 +0000 Subject: [PATCH 218/314] initial attempt at detecting chrome double click. --- src/Avalonia.Native/DoubleClickHelper.cs | 31 ++++++++++++++++++++++++ src/Avalonia.Native/WindowImpl.cs | 22 ++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/Avalonia.Native/DoubleClickHelper.cs diff --git a/src/Avalonia.Native/DoubleClickHelper.cs b/src/Avalonia.Native/DoubleClickHelper.cs new file mode 100644 index 0000000000..7618d6976a --- /dev/null +++ b/src/Avalonia.Native/DoubleClickHelper.cs @@ -0,0 +1,31 @@ +using Avalonia.Platform; + +namespace Avalonia.Native +{ + internal class DoubleClickHelper + { + private int _clickCount; + private Rect _lastClickRect; + private ulong _lastClickTime; + + public bool IsDoubleClick( + ulong timestamp, + Point p) + { + var settings = AvaloniaLocator.Current.GetService(); + var doubleClickTime = settings.DoubleClickTime.TotalMilliseconds; + + if (!_lastClickRect.Contains(p) || timestamp - _lastClickTime > doubleClickTime) + { + _clickCount = 0; + } + + ++_clickCount; + _lastClickTime = timestamp; + _lastClickRect = new Rect(p, new Size()) + .Inflate(new Thickness(settings.DoubleClickSize.Width / 2, settings.DoubleClickSize.Height / 2)); + + return _clickCount == 2; + } + } +} diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index f60e83efe3..f3b60f07be 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -1,4 +1,5 @@ using System; +using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Platform; using Avalonia.Input; @@ -17,6 +18,8 @@ namespace Avalonia.Native private readonly AvaloniaNativePlatformOpenGlInterface _glFeature; IAvnWindow _native; private double _extendTitleBarHeight = -1; + private DoubleClickHelper _doubleClickHelper; + internal WindowImpl(IAvaloniaNativeFactory factory, AvaloniaNativePlatformOptions opts, AvaloniaNativePlatformOpenGlInterface glFeature) : base(opts, glFeature) @@ -24,6 +27,8 @@ namespace Avalonia.Native _factory = factory; _opts = opts; _glFeature = glFeature; + _doubleClickHelper = new DoubleClickHelper(); + using (var e = new WindowEvents(this)) { var context = _opts.UseGpu ? glFeature?.MainContext : null; @@ -118,7 +123,22 @@ namespace Avalonia.Native if(visual == null) { - _native.BeginMoveDrag(); + if (_doubleClickHelper.IsDoubleClick(e.Timestamp, e.Position)) + { + // TOGGLE WINDOW STATE. + if (WindowState == WindowState.Maximized || WindowState == WindowState.FullScreen) + { + WindowState = WindowState.Normal; + } + else + { + WindowState = WindowState.Maximized; + } + } + else + { + _native.BeginMoveDrag(); + } } } } From aa8e0651ee995d61ccc18a932511414eef022adb Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 27 Nov 2020 09:26:32 +0100 Subject: [PATCH 219/314] Make ItemContainerInfo.Index setter public. It's needed to implement custom `ItemContainerGenerator`s. --- src/Avalonia.Controls/Generators/ItemContainerInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Generators/ItemContainerInfo.cs b/src/Avalonia.Controls/Generators/ItemContainerInfo.cs index 023b108061..31d9a5c02e 100644 --- a/src/Avalonia.Controls/Generators/ItemContainerInfo.cs +++ b/src/Avalonia.Controls/Generators/ItemContainerInfo.cs @@ -37,6 +37,6 @@ namespace Avalonia.Controls.Generators /// /// Gets the index of the item in the collection. /// - public int Index { get; internal set; } + public int Index { get; set; } } -} \ No newline at end of file +} From 7165fe6abb147e9d7dadb72a32dc7540497e0e45 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 27 Nov 2020 14:23:30 -0500 Subject: [PATCH 220/314] Thread safe SKTextBlobBuilder --- .../Avalonia.Skia/PlatformRenderInterface.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index 72700fb8fd..6d0be9f64d 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -3,6 +3,8 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; + using Avalonia.Controls.Platform.Surfaces; using Avalonia.Media; using Avalonia.OpenGL; @@ -166,12 +168,13 @@ namespace Avalonia.Skia LinearMetrics = true }; - private static readonly SKTextBlobBuilder s_textBlobBuilder = new SKTextBlobBuilder(); + private static readonly ThreadLocal s_textBlobBuilderThreadLocal = new ThreadLocal(() => new SKTextBlobBuilder()); /// public IGlyphRunImpl CreateGlyphRun(GlyphRun glyphRun, out double width) { var count = glyphRun.GlyphIndices.Length; + var textBlobBuilder = s_textBlobBuilderThreadLocal.Value; var glyphTypeface = (GlyphTypefaceImpl)glyphRun.GlyphTypeface.PlatformImpl; @@ -191,15 +194,15 @@ namespace Avalonia.Skia { if (glyphTypeface.IsFixedPitch) { - s_textBlobBuilder.AddRun(glyphRun.GlyphIndices.Buffer.Span, s_font); + textBlobBuilder.AddRun(glyphRun.GlyphIndices.Buffer.Span, s_font); - textBlob = s_textBlobBuilder.Build(); + textBlob = textBlobBuilder.Build(); width = glyphTypeface.GetGlyphAdvance(glyphRun.GlyphIndices[0]) * scale * glyphRun.GlyphIndices.Length; } else { - var buffer = s_textBlobBuilder.AllocateHorizontalRun(s_font, count, 0); + var buffer = textBlobBuilder.AllocateHorizontalRun(s_font, count, 0); var positions = buffer.GetPositionSpan(); @@ -219,12 +222,12 @@ namespace Avalonia.Skia buffer.SetGlyphs(glyphRun.GlyphIndices.Buffer.Span); - textBlob = s_textBlobBuilder.Build(); + textBlob = textBlobBuilder.Build(); } } else { - var buffer = s_textBlobBuilder.AllocatePositionedRun(s_font, count); + var buffer = textBlobBuilder.AllocatePositionedRun(s_font, count); var glyphPositions = buffer.GetPositionSpan(); @@ -250,7 +253,7 @@ namespace Avalonia.Skia width = currentX; - textBlob = s_textBlobBuilder.Build(); + textBlob = textBlobBuilder.Build(); } return new GlyphRunImpl(textBlob); From 960ae38ecdc1a6b5a75dce50a2f53c54fa1b9d1f Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 28 Nov 2020 16:51:30 +0100 Subject: [PATCH 221/314] Fix TextBox crashing when PointerMoved gets called and text presenter has 0 size. --- src/Avalonia.Controls/TextBox.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 0fe3ac62e4..28426ee70f 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -867,7 +867,10 @@ namespace Avalonia.Controls { var point = e.GetPosition(_presenter); - point = new Point(MathUtilities.Clamp(point.X, 0, _presenter.Bounds.Width - 1), MathUtilities.Clamp(point.Y, 0, _presenter.Bounds.Height - 1)); + point = new Point( + MathUtilities.Clamp(point.X, 0, Math.Max(_presenter.Bounds.Width - 1, 0)), + MathUtilities.Clamp(point.Y, 0, Math.Max(_presenter.Bounds.Height - 1, 0))); + CaretIndex = SelectionEnd = _presenter.GetCaretIndex(point); } } From 37dda37e469631b0fbe852017261aa2459b8344d Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 28 Nov 2020 22:14:06 -0500 Subject: [PATCH 222/314] Move Fluent theme files --- samples/ControlCatalog/App.xaml.cs | 4 +- samples/RenderDemo/App.xaml | 2 +- samples/Sandbox/App.axaml | 2 +- .../ApiCompatBaseline.txt | 3 + .../Avalonia.Themes.Fluent.csproj | 1 + .../{ => Controls}/AutoCompleteBox.xaml | 0 .../{ => Controls}/Button.xaml | 0 .../{ => Controls}/ButtonSpinner.xaml | 0 .../{ => Controls}/Calendar.xaml | 0 .../{ => Controls}/CalendarButton.xaml | 0 .../{ => Controls}/CalendarDatePicker.xaml | 0 .../{ => Controls}/CalendarDayButton.xaml | 0 .../{ => Controls}/CalendarItem.xaml | 0 .../{ => Controls}/CaptionButtons.xaml | 0 .../{ => Controls}/Carousel.xaml | 0 .../{ => Controls}/CheckBox.xaml | 0 .../{ => Controls}/ComboBox.xaml | 0 .../{ => Controls}/ComboBoxItem.xaml | 0 .../{ => Controls}/Common.xaml | 0 .../{ => Controls}/ContentControl.xaml | 0 .../{ => Controls}/ContextMenu.xaml | 0 .../{ => Controls}/DataValidationErrors.xaml | 0 .../{ => Controls}/DatePicker.xaml | 0 .../{ => Controls}/EmbeddableControlRoot.xaml | 0 .../{ => Controls}/Expander.xaml | 0 .../Controls/FluentTheme.xaml | 62 +++++++++++++++++++ .../{ => Controls}/FluentTheme.xaml.cs | 2 +- .../{ => Controls}/FocusAdorner.xaml | 0 .../{ => Controls}/GridSplitter.xaml | 0 .../{ => Controls}/ItemsControl.xaml | 0 .../{ => Controls}/Label.xaml | 0 .../{ => Controls}/ListBox.xaml | 0 .../{ => Controls}/ListBoxItem.xaml | 0 .../{ => Controls}/Menu.xaml | 0 .../{ => Controls}/MenuItem.xaml | 0 .../{ => Controls}/NativeMenuBar.xaml | 0 .../{ => Controls}/NotificationCard.xaml | 0 .../{ => Controls}/NumericUpDown.xaml | 0 .../{ => Controls}/OverlayPopupHost.xaml | 0 .../{ => Controls}/PathIcon.xaml | 0 .../{ => Controls}/PopupRoot.xaml | 0 .../{ => Controls}/ProgressBar.xaml | 0 .../{ => Controls}/RadioButton.xaml | 0 .../{ => Controls}/RepeatButton.xaml | 0 .../{ => Controls}/ScrollBar.xaml | 0 .../{ => Controls}/ScrollViewer.xaml | 0 .../{ => Controls}/Separator.xaml | 0 .../{ => Controls}/Slider.xaml | 0 .../{ => Controls}/SplitView.xaml | 0 .../{ => Controls}/TabControl.xaml | 0 .../{ => Controls}/TabItem.xaml | 0 .../{ => Controls}/TabStrip.xaml | 0 .../{ => Controls}/TabStripItem.xaml | 0 .../{ => Controls}/TextBox.xaml | 0 .../{ => Controls}/TimePicker.xaml | 0 .../{ => Controls}/TitleBar.xaml | 0 .../{ => Controls}/ToggleButton.xaml | 0 .../{ => Controls}/ToggleSwitch.xaml | 0 .../{ => Controls}/ToolTip.xaml | 0 .../{ => Controls}/TreeView.xaml | 0 .../{ => Controls}/TreeViewItem.xaml | 0 .../{ => Controls}/UserControl.xaml | 0 .../{ => Controls}/Window.xaml | 0 .../WindowNotificationManager.xaml | 0 .../{Accents => }/FluentDark.xaml | 2 +- .../{Accents => }/FluentLight.xaml | 2 +- src/Avalonia.Themes.Fluent/FluentTheme.xaml | 62 ------------------- 67 files changed, 73 insertions(+), 69 deletions(-) create mode 100644 src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt rename src/Avalonia.Themes.Fluent/{ => Controls}/AutoCompleteBox.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Button.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ButtonSpinner.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Calendar.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CalendarButton.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CalendarDatePicker.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CalendarDayButton.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CalendarItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CaptionButtons.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Carousel.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/CheckBox.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ComboBox.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ComboBoxItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Common.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ContentControl.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ContextMenu.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/DataValidationErrors.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/DatePicker.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/EmbeddableControlRoot.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Expander.xaml (100%) create mode 100644 src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml rename src/Avalonia.Themes.Fluent/{ => Controls}/FluentTheme.xaml.cs (81%) rename src/Avalonia.Themes.Fluent/{ => Controls}/FocusAdorner.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/GridSplitter.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ItemsControl.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Label.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ListBox.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ListBoxItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Menu.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/MenuItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/NativeMenuBar.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/NotificationCard.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/NumericUpDown.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/OverlayPopupHost.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/PathIcon.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/PopupRoot.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ProgressBar.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/RadioButton.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/RepeatButton.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ScrollBar.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ScrollViewer.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Separator.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Slider.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/SplitView.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TabControl.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TabItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TabStrip.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TabStripItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TextBox.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TimePicker.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TitleBar.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ToggleButton.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ToggleSwitch.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/ToolTip.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TreeView.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/TreeViewItem.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/UserControl.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/Window.xaml (100%) rename src/Avalonia.Themes.Fluent/{ => Controls}/WindowNotificationManager.xaml (100%) rename src/Avalonia.Themes.Fluent/{Accents => }/FluentDark.xaml (86%) rename src/Avalonia.Themes.Fluent/{Accents => }/FluentLight.xaml (86%) delete mode 100644 src/Avalonia.Themes.Fluent/FluentTheme.xaml diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs index 22f4e9be1f..020fb2fff3 100644 --- a/samples/ControlCatalog/App.xaml.cs +++ b/samples/ControlCatalog/App.xaml.cs @@ -23,7 +23,7 @@ namespace ControlCatalog { new StyleInclude(new Uri("avares://ControlCatalog/Styles")) { - Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml") + Source = new Uri("avares://Avalonia.Themes.Fluent/FluentDark.xaml") }, DataGridFluent }; @@ -32,7 +32,7 @@ namespace ControlCatalog { new StyleInclude(new Uri("avares://ControlCatalog/Styles")) { - Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/FluentLight.xaml") + Source = new Uri("avares://Avalonia.Themes.Fluent/FluentLight.xaml") }, DataGridFluent }; diff --git a/samples/RenderDemo/App.xaml b/samples/RenderDemo/App.xaml index 61e4d2385b..eeeaf5b0ae 100644 --- a/samples/RenderDemo/App.xaml +++ b/samples/RenderDemo/App.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="RenderDemo.App"> - + diff --git a/samples/Sandbox/App.axaml b/samples/Sandbox/App.axaml index 699781eb94..a351ba93e9 100644 --- a/samples/Sandbox/App.axaml +++ b/samples/Sandbox/App.axaml @@ -3,6 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Sandbox.App"> - + diff --git a/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt b/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt new file mode 100644 index 0000000000..68dc477cbc --- /dev/null +++ b/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt @@ -0,0 +1,3 @@ +Compat issues with assembly Avalonia.Themes.Fluent: +TypesMustExist : Type 'Avalonia.Themes.Fluent.FluentTheme' does not exist in the implementation but it does exist in the contract. +Total Issues: 1 diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj index 72f1fbf973..b710b5ef3b 100644 --- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj +++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj @@ -1,5 +1,6 @@  + true netstandard2.0 diff --git a/src/Avalonia.Themes.Fluent/AutoCompleteBox.xaml b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/AutoCompleteBox.xaml rename to src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml diff --git a/src/Avalonia.Themes.Fluent/Button.xaml b/src/Avalonia.Themes.Fluent/Controls/Button.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Button.xaml rename to src/Avalonia.Themes.Fluent/Controls/Button.xaml diff --git a/src/Avalonia.Themes.Fluent/ButtonSpinner.xaml b/src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ButtonSpinner.xaml rename to src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Controls/Calendar.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Calendar.xaml rename to src/Avalonia.Themes.Fluent/Controls/Calendar.xaml diff --git a/src/Avalonia.Themes.Fluent/CalendarButton.xaml b/src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CalendarButton.xaml rename to src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml diff --git a/src/Avalonia.Themes.Fluent/CalendarDatePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CalendarDatePicker.xaml rename to src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CalendarDayButton.xaml rename to src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CalendarItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml diff --git a/src/Avalonia.Themes.Fluent/CaptionButtons.xaml b/src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CaptionButtons.xaml rename to src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml diff --git a/src/Avalonia.Themes.Fluent/Carousel.xaml b/src/Avalonia.Themes.Fluent/Controls/Carousel.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Carousel.xaml rename to src/Avalonia.Themes.Fluent/Controls/Carousel.xaml diff --git a/src/Avalonia.Themes.Fluent/CheckBox.xaml b/src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/CheckBox.xaml rename to src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml diff --git a/src/Avalonia.Themes.Fluent/ComboBox.xaml b/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ComboBox.xaml rename to src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml diff --git a/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml b/src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ComboBoxItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml diff --git a/src/Avalonia.Themes.Fluent/Common.xaml b/src/Avalonia.Themes.Fluent/Controls/Common.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Common.xaml rename to src/Avalonia.Themes.Fluent/Controls/Common.xaml diff --git a/src/Avalonia.Themes.Fluent/ContentControl.xaml b/src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ContentControl.xaml rename to src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml diff --git a/src/Avalonia.Themes.Fluent/ContextMenu.xaml b/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ContextMenu.xaml rename to src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml diff --git a/src/Avalonia.Themes.Fluent/DataValidationErrors.xaml b/src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/DataValidationErrors.xaml rename to src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml diff --git a/src/Avalonia.Themes.Fluent/DatePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/DatePicker.xaml rename to src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml diff --git a/src/Avalonia.Themes.Fluent/EmbeddableControlRoot.xaml b/src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/EmbeddableControlRoot.xaml rename to src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml diff --git a/src/Avalonia.Themes.Fluent/Expander.xaml b/src/Avalonia.Themes.Fluent/Controls/Expander.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Expander.xaml rename to src/Avalonia.Themes.Fluent/Controls/Expander.xaml diff --git a/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml b/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml new file mode 100644 index 0000000000..5205fc16a6 --- /dev/null +++ b/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.xaml.cs b/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs similarity index 81% rename from src/Avalonia.Themes.Fluent/FluentTheme.xaml.cs rename to src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs index 9c65a7227c..bf880f2334 100644 --- a/src/Avalonia.Themes.Fluent/FluentTheme.xaml.cs +++ b/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs @@ -1,7 +1,7 @@ using Avalonia.Markup.Xaml; using Avalonia.Styling; -namespace Avalonia.Themes.Fluent +namespace Avalonia.Themes.Fluent.Controls { /// /// The default Avalonia theme. diff --git a/src/Avalonia.Themes.Fluent/FocusAdorner.xaml b/src/Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/FocusAdorner.xaml rename to src/Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml diff --git a/src/Avalonia.Themes.Fluent/GridSplitter.xaml b/src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/GridSplitter.xaml rename to src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml diff --git a/src/Avalonia.Themes.Fluent/ItemsControl.xaml b/src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ItemsControl.xaml rename to src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml diff --git a/src/Avalonia.Themes.Fluent/Label.xaml b/src/Avalonia.Themes.Fluent/Controls/Label.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Label.xaml rename to src/Avalonia.Themes.Fluent/Controls/Label.xaml diff --git a/src/Avalonia.Themes.Fluent/ListBox.xaml b/src/Avalonia.Themes.Fluent/Controls/ListBox.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ListBox.xaml rename to src/Avalonia.Themes.Fluent/Controls/ListBox.xaml diff --git a/src/Avalonia.Themes.Fluent/ListBoxItem.xaml b/src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ListBoxItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml diff --git a/src/Avalonia.Themes.Fluent/Menu.xaml b/src/Avalonia.Themes.Fluent/Controls/Menu.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Menu.xaml rename to src/Avalonia.Themes.Fluent/Controls/Menu.xaml diff --git a/src/Avalonia.Themes.Fluent/MenuItem.xaml b/src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/MenuItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml diff --git a/src/Avalonia.Themes.Fluent/NativeMenuBar.xaml b/src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/NativeMenuBar.xaml rename to src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml diff --git a/src/Avalonia.Themes.Fluent/NotificationCard.xaml b/src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/NotificationCard.xaml rename to src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml diff --git a/src/Avalonia.Themes.Fluent/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/NumericUpDown.xaml rename to src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml diff --git a/src/Avalonia.Themes.Fluent/OverlayPopupHost.xaml b/src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/OverlayPopupHost.xaml rename to src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml diff --git a/src/Avalonia.Themes.Fluent/PathIcon.xaml b/src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/PathIcon.xaml rename to src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml diff --git a/src/Avalonia.Themes.Fluent/PopupRoot.xaml b/src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/PopupRoot.xaml rename to src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml diff --git a/src/Avalonia.Themes.Fluent/ProgressBar.xaml b/src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ProgressBar.xaml rename to src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml diff --git a/src/Avalonia.Themes.Fluent/RadioButton.xaml b/src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/RadioButton.xaml rename to src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml diff --git a/src/Avalonia.Themes.Fluent/RepeatButton.xaml b/src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/RepeatButton.xaml rename to src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml diff --git a/src/Avalonia.Themes.Fluent/ScrollBar.xaml b/src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ScrollBar.xaml rename to src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml diff --git a/src/Avalonia.Themes.Fluent/ScrollViewer.xaml b/src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ScrollViewer.xaml rename to src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml diff --git a/src/Avalonia.Themes.Fluent/Separator.xaml b/src/Avalonia.Themes.Fluent/Controls/Separator.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Separator.xaml rename to src/Avalonia.Themes.Fluent/Controls/Separator.xaml diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Controls/Slider.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Slider.xaml rename to src/Avalonia.Themes.Fluent/Controls/Slider.xaml diff --git a/src/Avalonia.Themes.Fluent/SplitView.xaml b/src/Avalonia.Themes.Fluent/Controls/SplitView.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/SplitView.xaml rename to src/Avalonia.Themes.Fluent/Controls/SplitView.xaml diff --git a/src/Avalonia.Themes.Fluent/TabControl.xaml b/src/Avalonia.Themes.Fluent/Controls/TabControl.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TabControl.xaml rename to src/Avalonia.Themes.Fluent/Controls/TabControl.xaml diff --git a/src/Avalonia.Themes.Fluent/TabItem.xaml b/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TabItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/TabItem.xaml diff --git a/src/Avalonia.Themes.Fluent/TabStrip.xaml b/src/Avalonia.Themes.Fluent/Controls/TabStrip.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TabStrip.xaml rename to src/Avalonia.Themes.Fluent/Controls/TabStrip.xaml diff --git a/src/Avalonia.Themes.Fluent/TabStripItem.xaml b/src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TabStripItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml diff --git a/src/Avalonia.Themes.Fluent/TextBox.xaml b/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TextBox.xaml rename to src/Avalonia.Themes.Fluent/Controls/TextBox.xaml diff --git a/src/Avalonia.Themes.Fluent/TimePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TimePicker.xaml rename to src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml diff --git a/src/Avalonia.Themes.Fluent/TitleBar.xaml b/src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TitleBar.xaml rename to src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml diff --git a/src/Avalonia.Themes.Fluent/ToggleButton.xaml b/src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ToggleButton.xaml rename to src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml diff --git a/src/Avalonia.Themes.Fluent/ToggleSwitch.xaml b/src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ToggleSwitch.xaml rename to src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml diff --git a/src/Avalonia.Themes.Fluent/ToolTip.xaml b/src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/ToolTip.xaml rename to src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml diff --git a/src/Avalonia.Themes.Fluent/TreeView.xaml b/src/Avalonia.Themes.Fluent/Controls/TreeView.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TreeView.xaml rename to src/Avalonia.Themes.Fluent/Controls/TreeView.xaml diff --git a/src/Avalonia.Themes.Fluent/TreeViewItem.xaml b/src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/TreeViewItem.xaml rename to src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml diff --git a/src/Avalonia.Themes.Fluent/UserControl.xaml b/src/Avalonia.Themes.Fluent/Controls/UserControl.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/UserControl.xaml rename to src/Avalonia.Themes.Fluent/Controls/UserControl.xaml diff --git a/src/Avalonia.Themes.Fluent/Window.xaml b/src/Avalonia.Themes.Fluent/Controls/Window.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/Window.xaml rename to src/Avalonia.Themes.Fluent/Controls/Window.xaml diff --git a/src/Avalonia.Themes.Fluent/WindowNotificationManager.xaml b/src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml similarity index 100% rename from src/Avalonia.Themes.Fluent/WindowNotificationManager.xaml rename to src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentDark.xaml b/src/Avalonia.Themes.Fluent/FluentDark.xaml similarity index 86% rename from src/Avalonia.Themes.Fluent/Accents/FluentDark.xaml rename to src/Avalonia.Themes.Fluent/FluentDark.xaml index 9ef92a44d5..48f3553b92 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentDark.xaml +++ b/src/Avalonia.Themes.Fluent/FluentDark.xaml @@ -5,5 +5,5 @@ - + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentLight.xaml b/src/Avalonia.Themes.Fluent/FluentLight.xaml similarity index 86% rename from src/Avalonia.Themes.Fluent/Accents/FluentLight.xaml rename to src/Avalonia.Themes.Fluent/FluentLight.xaml index 8c92040122..565212328b 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentLight.xaml +++ b/src/Avalonia.Themes.Fluent/FluentLight.xaml @@ -5,5 +5,5 @@ - + diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.xaml b/src/Avalonia.Themes.Fluent/FluentTheme.xaml deleted file mode 100644 index 4e0e4fe862..0000000000 --- a/src/Avalonia.Themes.Fluent/FluentTheme.xaml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From e8c40d4275b36ef03fbc3e1862cc304cd2bac95b Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 28 Nov 2020 22:24:34 -0500 Subject: [PATCH 223/314] Rename FluentControls --- samples/ControlCatalog/MainWindow.xaml.cs | 2 +- src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj | 1 - .../Controls/{FluentTheme.xaml => FluentControls.xaml} | 2 +- .../Controls/{FluentTheme.xaml.cs => FluentControls.xaml.cs} | 2 +- src/Avalonia.Themes.Fluent/FluentDark.xaml | 2 +- src/Avalonia.Themes.Fluent/FluentLight.xaml | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) rename src/Avalonia.Themes.Fluent/Controls/{FluentTheme.xaml => FluentControls.xaml} (98%) rename src/Avalonia.Themes.Fluent/Controls/{FluentTheme.xaml.cs => FluentControls.xaml.cs} (81%) diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index a316321cd1..723351ae57 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -67,7 +67,7 @@ namespace ControlCatalog if (Application.Current.Styles.Contains(App.FluentDark) || Application.Current.Styles.Contains(App.FluentLight)) { - var theme = new Avalonia.Themes.Fluent.FluentTheme(); + var theme = new Avalonia.Themes.Fluent.Controls.FluentControls(); theme.TryGetResource("Button", out _); } else diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj index b710b5ef3b..72f1fbf973 100644 --- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj +++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj @@ -1,6 +1,5 @@  - true netstandard2.0 diff --git a/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml similarity index 98% rename from src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml rename to src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml index 5205fc16a6..0acb8f4f6e 100644 --- a/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml @@ -1,6 +1,6 @@ + x:Class="Avalonia.Themes.Fluent.Controls.FluentControls"> diff --git a/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml.cs similarity index 81% rename from src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs rename to src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml.cs index bf880f2334..37822f5c8c 100644 --- a/src/Avalonia.Themes.Fluent/Controls/FluentTheme.xaml.cs +++ b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml.cs @@ -6,7 +6,7 @@ namespace Avalonia.Themes.Fluent.Controls /// /// The default Avalonia theme. /// - public class FluentTheme : Styles + public class FluentControls : Styles { } } diff --git a/src/Avalonia.Themes.Fluent/FluentDark.xaml b/src/Avalonia.Themes.Fluent/FluentDark.xaml index 48f3553b92..74b583a240 100644 --- a/src/Avalonia.Themes.Fluent/FluentDark.xaml +++ b/src/Avalonia.Themes.Fluent/FluentDark.xaml @@ -5,5 +5,5 @@ - + diff --git a/src/Avalonia.Themes.Fluent/FluentLight.xaml b/src/Avalonia.Themes.Fluent/FluentLight.xaml index 565212328b..1bc51f655e 100644 --- a/src/Avalonia.Themes.Fluent/FluentLight.xaml +++ b/src/Avalonia.Themes.Fluent/FluentLight.xaml @@ -5,5 +5,5 @@ - + From 856ead263cf111f8a6fbd175fb9258850f2cfcf3 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Sun, 29 Nov 2020 13:56:46 +0700 Subject: [PATCH 224/314] EmbedXaml: remove items generated for XAML files by default These items are generated by Microsoft.Net.SDK.DefaultItems.props, and aren't supposed to be here. --- build/EmbedXaml.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/EmbedXaml.props b/build/EmbedXaml.props index 7ce0366dea..0bb8da4f47 100644 --- a/build/EmbedXaml.props +++ b/build/EmbedXaml.props @@ -4,8 +4,9 @@ %(Filename) + Designer - \ No newline at end of file + From 3d131473164a352539e80f3abd6de057093485c4 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 30 Nov 2020 01:14:14 +0000 Subject: [PATCH 225/314] Sign assemblies --- build/SharedVersion.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index a5c0aa1bea..43ec995ed9 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -16,7 +16,7 @@ https://github.com/AvaloniaUI/Avalonia/releases git $(MSBuildThisFileDirectory)\avalonia.snk - false + true $(DefineConstants);SIGNED_BUILD From 9a591f517eb59bb5c77dd15f81690cbdd40565b3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 30 Nov 2020 15:10:06 +0000 Subject: [PATCH 226/314] sign test assemblies --- .../Avalonia.Direct2D1.RenderTests.csproj | 1 + tests/Avalonia.Skia.UnitTests/Avalonia.Skia.UnitTests.csproj | 3 ++- tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj b/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj index 1cfc1a6ab8..c59e59be63 100644 --- a/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj +++ b/tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj @@ -27,4 +27,5 @@ + diff --git a/tests/Avalonia.Skia.UnitTests/Avalonia.Skia.UnitTests.csproj b/tests/Avalonia.Skia.UnitTests/Avalonia.Skia.UnitTests.csproj index 584eaf6fa9..ef69865e32 100644 --- a/tests/Avalonia.Skia.UnitTests/Avalonia.Skia.UnitTests.csproj +++ b/tests/Avalonia.Skia.UnitTests/Avalonia.Skia.UnitTests.csproj @@ -8,6 +8,7 @@ + @@ -23,4 +24,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj b/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj index 6b5c7a66ff..d4abf9416a 100644 --- a/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj +++ b/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj @@ -28,4 +28,5 @@ + From 9eb7a1002fd29ed6b208e4492d9d7c4730bcc253 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 30 Nov 2020 15:17:25 +0000 Subject: [PATCH 227/314] fix test signing --- tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj | 3 ++- .../Avalonia.Controls.DataGrid.UnitTests.csproj | 1 + .../Avalonia.Controls.UnitTests.csproj | 1 + .../Avalonia.Direct2D1.UnitTests.csproj | 3 ++- .../Avalonia.Visuals.UnitTests.csproj | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj index 0d87f0eb03..badfd09430 100644 --- a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj +++ b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj @@ -10,6 +10,7 @@ + @@ -17,4 +18,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj b/tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj index 396dfee691..c0c9303767 100644 --- a/tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj +++ b/tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj @@ -12,6 +12,7 @@ + diff --git a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj index 7a6d77ef46..6b17427eda 100644 --- a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj +++ b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj @@ -12,6 +12,7 @@ + diff --git a/tests/Avalonia.Direct2D1.UnitTests/Avalonia.Direct2D1.UnitTests.csproj b/tests/Avalonia.Direct2D1.UnitTests/Avalonia.Direct2D1.UnitTests.csproj index e346ce944d..42229ba456 100644 --- a/tests/Avalonia.Direct2D1.UnitTests/Avalonia.Direct2D1.UnitTests.csproj +++ b/tests/Avalonia.Direct2D1.UnitTests/Avalonia.Direct2D1.UnitTests.csproj @@ -7,6 +7,7 @@ + @@ -22,4 +23,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj index aee54e87a9..13a04be5db 100644 --- a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj +++ b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj @@ -13,6 +13,7 @@ + From 8ac71278091c0c2922f5e41c2e0857cb7f8b9191 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 30 Nov 2020 16:05:48 +0000 Subject: [PATCH 228/314] sign more test assemblies --- .../Avalonia.Animation.UnitTests.csproj | 1 + tests/Avalonia.LeakTests/Avalonia.LeakTests.csproj | 3 ++- .../Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj | 1 + .../Avalonia.Markup.Xaml.UnitTests.csproj | 1 + .../Avalonia.Styling.UnitTests.csproj | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj b/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj index dd50eff2b6..5b686dea4c 100644 --- a/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj +++ b/tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj @@ -10,6 +10,7 @@ + diff --git a/tests/Avalonia.LeakTests/Avalonia.LeakTests.csproj b/tests/Avalonia.LeakTests/Avalonia.LeakTests.csproj index 27f3223c6c..d49a859b89 100644 --- a/tests/Avalonia.LeakTests/Avalonia.LeakTests.csproj +++ b/tests/Avalonia.LeakTests/Avalonia.LeakTests.csproj @@ -7,6 +7,7 @@ + @@ -25,4 +26,4 @@ - \ No newline at end of file + diff --git a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj index ec5b2f0ed1..7d1285c025 100644 --- a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj +++ b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj @@ -10,6 +10,7 @@ + diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj index ad3592294d..44b604197d 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj @@ -10,6 +10,7 @@ + diff --git a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj index 2b7f6263a7..a07ec050a6 100644 --- a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj +++ b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj @@ -11,6 +11,7 @@ + From 315d8be0ead4db017d2adaeb77e4c733629259ea Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 30 Nov 2020 16:34:46 +0000 Subject: [PATCH 229/314] sign more test assemblies --- tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj | 1 + tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj b/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj index 463bc50008..74cc6e292b 100644 --- a/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj +++ b/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj @@ -8,6 +8,7 @@ + diff --git a/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj b/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj index 65df5e7cb0..14d0f4debf 100644 --- a/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj +++ b/tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj @@ -29,4 +29,5 @@ + From 289e787938a6e4d898ad46e01440fa0df3d8bc03 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 1 Dec 2020 12:14:39 +0100 Subject: [PATCH 230/314] Implement FluentTheme class. For easier selection of fluent theme in App.xaml. --- samples/RenderDemo/App.xaml | 2 +- samples/Sandbox/App.axaml | 2 +- src/Avalonia.Themes.Fluent/FluentTheme.cs | 114 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 3 + 4 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 src/Avalonia.Themes.Fluent/FluentTheme.cs create mode 100644 src/Avalonia.Themes.Fluent/Properties/AssemblyInfo.cs diff --git a/samples/RenderDemo/App.xaml b/samples/RenderDemo/App.xaml index eeeaf5b0ae..7cdcea2e1d 100644 --- a/samples/RenderDemo/App.xaml +++ b/samples/RenderDemo/App.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="RenderDemo.App"> - + diff --git a/samples/Sandbox/App.axaml b/samples/Sandbox/App.axaml index a351ba93e9..9f97822a97 100644 --- a/samples/Sandbox/App.axaml +++ b/samples/Sandbox/App.axaml @@ -3,6 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Sandbox.App"> - + diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.cs b/src/Avalonia.Themes.Fluent/FluentTheme.cs new file mode 100644 index 0000000000..09e9561cb1 --- /dev/null +++ b/src/Avalonia.Themes.Fluent/FluentTheme.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.Styling; + +#nullable enable + +namespace Avalonia.Themes.Fluent +{ + public enum FluentColorScheme + { + Light, + Dark, + } + + /// + /// Includes the fluent theme in an application. + /// + public class FluentTheme : IStyle, IResourceProvider + { + private readonly Uri _baseUri; + private IStyle[]? _loaded; + private bool _isLoading; + + /// + /// Initializes a new instance of the class. + /// + /// The base URL for the XAML context. + public FluentTheme(Uri baseUri) + { + _baseUri = baseUri; + } + + /// + /// Initializes a new instance of the class. + /// + /// The XAML service provider. + public FluentTheme(IServiceProvider serviceProvider) + { + _baseUri = ((IUriContext)serviceProvider.GetService(typeof(IUriContext))).BaseUri; + } + + /// + /// Gets or sets the color scheme to use (light, dark). + /// + public FluentColorScheme Scheme { get; set; } + + public IResourceHost? Owner => (Loaded as IResourceProvider)?.Owner; + + /// + /// Gets the loaded style. + /// + public IStyle Loaded + { + get + { + if (_loaded == null) + { + _isLoading = true; + var loaded = (IStyle)AvaloniaXamlLoader.Load(GetUri(), _baseUri); + _loaded = new[] { loaded }; + _isLoading = false; + } + + return _loaded?[0]!; + } + } + + bool IResourceNode.HasResources => (Loaded as IResourceProvider)?.HasResources ?? false; + + IReadOnlyList IStyle.Children => _loaded ?? Array.Empty(); + + public event EventHandler OwnerChanged + { + add + { + if (Loaded is IResourceProvider rp) + { + rp.OwnerChanged += value; + } + } + remove + { + if (Loaded is IResourceProvider rp) + { + rp.OwnerChanged -= value; + } + } + } + + public SelectorMatchResult TryAttach(IStyleable target, IStyleHost? host) => Loaded.TryAttach(target, host); + + public bool TryGetResource(object key, out object? value) + { + if (!_isLoading && Loaded is IResourceProvider p) + { + return p.TryGetResource(key, out value); + } + + value = null; + return false; + } + + void IResourceProvider.AddOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.AddOwner(owner); + void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); + + private Uri GetUri() => Scheme switch + { + FluentColorScheme.Dark => new Uri("avares://Avalonia.Themes.Fluent/FluentDark.xaml", UriKind.Absolute), + _ => new Uri("avares://Avalonia.Themes.Fluent/FluentLight.xaml", UriKind.Absolute), + }; + } +} diff --git a/src/Avalonia.Themes.Fluent/Properties/AssemblyInfo.cs b/src/Avalonia.Themes.Fluent/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..0bad226ba7 --- /dev/null +++ b/src/Avalonia.Themes.Fluent/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using Avalonia.Metadata; + +[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Themes.Fluent")] From f08bfb329dfc601afc5a3ae1b78f3add2c68f7ea Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 1 Dec 2020 12:18:45 +0100 Subject: [PATCH 231/314] Update API compat baseline. --- src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt b/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt index 68dc477cbc..44e250b889 100644 --- a/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt +++ b/src/Avalonia.Themes.Fluent/ApiCompatBaseline.txt @@ -1,3 +1,4 @@ Compat issues with assembly Avalonia.Themes.Fluent: -TypesMustExist : Type 'Avalonia.Themes.Fluent.FluentTheme' does not exist in the implementation but it does exist in the contract. -Total Issues: 1 +CannotRemoveBaseTypeOrInterface : Type 'Avalonia.Themes.Fluent.FluentTheme' does not inherit from base type 'Avalonia.Styling.Styles' in the implementation but it does in the contract. +MembersMustExist : Member 'public void Avalonia.Themes.Fluent.FluentTheme..ctor()' does not exist in the implementation but it does exist in the contract. +Total Issues: 2 From 31e4d9b5156e7f0d9d7b41101fd53e30df5a5f9a Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 1 Dec 2020 13:53:38 +0100 Subject: [PATCH 232/314] Renamed Theme -> Mode in FluentTheme. --- samples/Sandbox/App.axaml | 2 +- src/Avalonia.Themes.Fluent/FluentTheme.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/Sandbox/App.axaml b/samples/Sandbox/App.axaml index 9f97822a97..f601f9f78f 100644 --- a/samples/Sandbox/App.axaml +++ b/samples/Sandbox/App.axaml @@ -3,6 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Sandbox.App"> - + diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.cs b/src/Avalonia.Themes.Fluent/FluentTheme.cs index 09e9561cb1..43b71567fa 100644 --- a/src/Avalonia.Themes.Fluent/FluentTheme.cs +++ b/src/Avalonia.Themes.Fluent/FluentTheme.cs @@ -8,7 +8,7 @@ using Avalonia.Styling; namespace Avalonia.Themes.Fluent { - public enum FluentColorScheme + public enum FluentThemeMode { Light, Dark, @@ -42,9 +42,9 @@ namespace Avalonia.Themes.Fluent } /// - /// Gets or sets the color scheme to use (light, dark). + /// Gets or sets the mode of the fluent theme (light, dark). /// - public FluentColorScheme Scheme { get; set; } + public FluentThemeMode Mode { get; set; } public IResourceHost? Owner => (Loaded as IResourceProvider)?.Owner; @@ -105,9 +105,9 @@ namespace Avalonia.Themes.Fluent void IResourceProvider.AddOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.AddOwner(owner); void IResourceProvider.RemoveOwner(IResourceHost owner) => (Loaded as IResourceProvider)?.RemoveOwner(owner); - private Uri GetUri() => Scheme switch + private Uri GetUri() => Mode switch { - FluentColorScheme.Dark => new Uri("avares://Avalonia.Themes.Fluent/FluentDark.xaml", UriKind.Absolute), + FluentThemeMode.Dark => new Uri("avares://Avalonia.Themes.Fluent/FluentDark.xaml", UriKind.Absolute), _ => new Uri("avares://Avalonia.Themes.Fluent/FluentLight.xaml", UriKind.Absolute), }; } From 3a247bde2afc4cc7a31f525a95e3aaf3fd9aaa19 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 2 Dec 2020 21:59:44 +0100 Subject: [PATCH 233/314] LayoutState should call LayoutStateCore. See upstream implementation at https://github.com/microsoft/microsoft-ui-xaml/blob/c6c8d084231f8cc4ffa978305e9f2a0f93a9a39c/dev/Repeater/LayoutContext.cpp#L13-L18 --- src/Avalonia.Layout/LayoutContext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Layout/LayoutContext.cs b/src/Avalonia.Layout/LayoutContext.cs index 45a8048ea2..dadce58c0c 100644 --- a/src/Avalonia.Layout/LayoutContext.cs +++ b/src/Avalonia.Layout/LayoutContext.cs @@ -14,7 +14,11 @@ namespace Avalonia.Layout /// /// Gets or sets an object that represents the state of a layout. /// - public object LayoutState { get; set; } + public object LayoutState + { + get => LayoutStateCore; + set => LayoutStateCore = value; + } /// /// Implements the behavior of in a derived or custom LayoutContext. From f4eb53330c4b9a17abf575726fa36fa52abce2d0 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 2 Dec 2020 18:18:17 -0500 Subject: [PATCH 234/314] Add missing DataGridRowHeader template for DataGrid --- .../Themes/Default.xaml | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/Themes/Default.xaml b/src/Avalonia.Controls.DataGrid/Themes/Default.xaml index cf062e0920..09d19c8e43 100644 --- a/src/Avalonia.Controls.DataGrid/Themes/Default.xaml +++ b/src/Avalonia.Controls.DataGrid/Themes/Default.xaml @@ -137,12 +137,37 @@ + + diff --git a/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml b/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml index 1c9574f169..508473796c 100644 --- a/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/TabItem.xaml @@ -97,8 +97,8 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml index 1da48ebd8a..288b3ccee6 100644 --- a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml @@ -1,8 +1,7 @@ - + @@ -48,6 +49,8 @@ Padding="{TemplateBinding Padding}" Watermark="{TemplateBinding Watermark}" IsReadOnly="{TemplateBinding IsReadOnly}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Text="{TemplateBinding Text}" AcceptsReturn="False" TextWrapping="NoWrap" /> From 107b4d83fdc026dcfc3fe692c8ae683341b11126 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 2 Jan 2021 02:50:10 -0500 Subject: [PATCH 289/314] Add HorizontalContentAlignment/VerticalContentAlignment props to CalendarDatePicker --- .../Calendar/CalendarDatePicker.cs | 32 +++++++++++++++++++ .../CalendarDatePicker.xaml | 2 ++ .../Controls/CalendarDatePicker.xaml | 8 +++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs index 7c259f0a09..af3fdbd662 100644 --- a/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs +++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs @@ -11,6 +11,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.Layout; namespace Avalonia.Controls { @@ -209,6 +210,18 @@ namespace Avalonia.Controls TextBox.UseFloatingWatermarkProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly StyledProperty HorizontalContentAlignmentProperty = + ContentControl.HorizontalContentAlignmentProperty.AddOwner(); + + /// + /// Defines the property. + /// + public static readonly StyledProperty VerticalContentAlignmentProperty = + ContentControl.VerticalContentAlignmentProperty.AddOwner(); + /// /// Gets or sets the date to display. /// @@ -364,6 +377,25 @@ namespace Avalonia.Controls set { SetValue(UseFloatingWatermarkProperty, value); } } + + /// + /// Gets or sets the horizontal alignment of the content within the control. + /// + public HorizontalAlignment HorizontalContentAlignment + { + get => GetValue(HorizontalContentAlignmentProperty); + set => SetValue(HorizontalContentAlignmentProperty, value); + } + + /// + /// Gets or sets the vertical alignment of the content within the control. + /// + public VerticalAlignment VerticalContentAlignment + { + get => GetValue(VerticalContentAlignmentProperty); + set => SetValue(VerticalContentAlignmentProperty, value); + } + /// /// Occurs when the drop-down /// is closed. diff --git a/src/Avalonia.Themes.Default/CalendarDatePicker.xaml b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml index bc1aba1a03..aab7d06c46 100644 --- a/src/Avalonia.Themes.Default/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml @@ -93,6 +93,8 @@ Watermark="{TemplateBinding Watermark}" UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Column="0"/>