diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5433a86..0904f01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,9 @@ name: CI Build env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: true - BUILD_VERSION: 1.5.0 + BUILD_VERSION: 1.5.1 PACKAGE_RELEASE_NOTES: | - Updates the tfm and packages - Disable IsEditable when IsDynamicCodeSupported false - Add exception handlers to TextMate loading + Downgrade source generator TFM to netstandard2.0 to bypass the VS bullshit # NOTE: Instead of , use %2c on: diff --git a/ShowMeTheXaml.Avalonia.Generator/ShowMeTheXaml.Avalonia.Generator.csproj b/ShowMeTheXaml.Avalonia.Generator/ShowMeTheXaml.Avalonia.Generator.csproj index 36a8aa4..7872328 100644 --- a/ShowMeTheXaml.Avalonia.Generator/ShowMeTheXaml.Avalonia.Generator.csproj +++ b/ShowMeTheXaml.Avalonia.Generator/ShowMeTheXaml.Avalonia.Generator.csproj @@ -1,7 +1,7 @@ - netstandard2.1 + netstandard2.0 preview true false diff --git a/ShowMeTheXaml.Avalonia/ShowMeTheXaml.Avalonia.csproj b/ShowMeTheXaml.Avalonia/ShowMeTheXaml.Avalonia.csproj index f086b5c..b2501e1 100644 --- a/ShowMeTheXaml.Avalonia/ShowMeTheXaml.Avalonia.csproj +++ b/ShowMeTheXaml.Avalonia/ShowMeTheXaml.Avalonia.csproj @@ -1,7 +1,6 @@ - netstandard2.1 preview enable true @@ -14,6 +13,7 @@ Git avalonia avaloniaui ShowMeTheXaml + netstandard2.1;netstandard2.0 diff --git a/ShowMeTheXaml.Avalonia/XamlDisplay.xaml.cs b/ShowMeTheXaml.Avalonia/XamlDisplay.xaml.cs index d619635..78c2680 100644 --- a/ShowMeTheXaml.Avalonia/XamlDisplay.xaml.cs +++ b/ShowMeTheXaml.Avalonia/XamlDisplay.xaml.cs @@ -11,8 +11,10 @@ using Avalonia.Metadata; // ReSharper disable once CheckNamespace -namespace ShowMeTheXaml { - public class XamlDisplay : TemplatedControl { +namespace ShowMeTheXaml +{ + public class XamlDisplay : TemplatedControl + { public static readonly StyledProperty XamlTextProperty = AvaloniaProperty.Register(nameof(XamlText)); @@ -22,7 +24,7 @@ public class XamlDisplay : TemplatedControl { public static readonly StyledProperty XamlButtonAlignmentProperty = AvaloniaProperty.Register(nameof(XamlButtonAlignment), AlignmentY.Bottom); - public static readonly StyledProperty IsEditableProperty = + public static readonly StyledProperty IsEditableProperty = AvaloniaProperty.Register("IsEditable", true); private IDisposable? _buttonClickHandler; @@ -31,38 +33,49 @@ public class XamlDisplay : TemplatedControl { public XamlDisplay() { +#if NETSTANDARD2_1_OR_GREATER IsEditable = RuntimeFeature.IsDynamicCodeSupported; +#else + IsEditable = false; +#endif } - public bool IsEditable { + public bool IsEditable + { get => GetValue(IsEditableProperty); set => SetValue(IsEditableProperty, value); } - public string UniqueId { + public string UniqueId + { get => _uniqueId; - set { + set + { _uniqueId = value; Reset(); } } - public string? XamlText { + public string? XamlText + { get => GetValue(XamlTextProperty); set => SetValue(XamlTextProperty, value); } [Content] - public object? Content { + public object? Content + { get => GetValue(ContentProperty); - set { + set + { if (GetValue(ContentProperty) is ILogical oldLogical) LogicalChildren.Remove(oldLogical); SetValue(ContentProperty, value); if (value is ILogical newLogical) LogicalChildren.Add(newLogical); } } - public AlignmentY XamlButtonAlignment { + public AlignmentY XamlButtonAlignment + { get => GetValue(XamlButtonAlignmentProperty); set => SetValue(XamlButtonAlignmentProperty, value); } @@ -70,24 +83,32 @@ public AlignmentY XamlButtonAlignment { public Dictionary CurrentFileNamespaceAliases => XamlFilesNamespaceAliases[DisplayContent[UniqueId].FileName]; - private void SourceXamlButtonOnPointerPressed(object sender, PointerPressedEventArgs e) { - if (_popup != null) { + private void SourceXamlButtonOnPointerPressed(object sender, PointerPressedEventArgs e) + { + if (_popup != null) + { _popup.IsOpen = !_popup.IsOpen; } } - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { base.OnApplyTemplate(e); _buttonClickHandler?.Dispose(); _popup = e.NameScope.Find("XamlPopup"); - _buttonClickHandler = e.NameScope.Find("SourceXamlButton").AddDisposableHandler(PointerPressedEvent, SourceXamlButtonOnPointerPressed); + _buttonClickHandler = e.NameScope.Find("SourceXamlButton") + .AddDisposableHandler(PointerPressedEvent, SourceXamlButtonOnPointerPressed); } - public void Reset() { + public void Reset() + { if (!DisplayContent.TryGetValue(UniqueId, out var xamlDisplayInstanceData)) return; - if (!string.IsNullOrEmpty(XamlText)) { - Content = AvaloniaRuntimeXamlLoaderHelper.Parse(xamlDisplayInstanceData.Data, CurrentFileNamespaceAliases); + if (!string.IsNullOrEmpty(XamlText)) + { + Content = AvaloniaRuntimeXamlLoaderHelper.Parse(xamlDisplayInstanceData.Data, + CurrentFileNamespaceAliases); } + XamlText = xamlDisplayInstanceData.Data; } @@ -96,17 +117,21 @@ public void Reset() { private static Dictionary? _displayContent; private static Dictionary>? _xamlFilesNamespaceAliases; - public static Dictionary DisplayContent { + public static Dictionary DisplayContent + { get => _displayContent - ?? throw new NullReferenceException("Install ShowMeTheXaml.Avalonia.Generator and call XamlDisplayInternalData.RegisterXamlDisplayData" + - "Also check \"Getting started\" on our Github"); + ?? throw new NullReferenceException( + "Install ShowMeTheXaml.Avalonia.Generator and call XamlDisplayInternalData.RegisterXamlDisplayData" + + "Also check \"Getting started\" on our Github"); set => _displayContent = value; } - public static Dictionary> XamlFilesNamespaceAliases { + public static Dictionary> XamlFilesNamespaceAliases + { get => _xamlFilesNamespaceAliases - ?? throw new NullReferenceException("Install ShowMeTheXaml.Avalonia.Generator and call XamlDisplayInternalData.RegisterXamlDisplayData" + - "Also check \"Getting started\" on our Github"); + ?? throw new NullReferenceException( + "Install ShowMeTheXaml.Avalonia.Generator and call XamlDisplayInternalData.RegisterXamlDisplayData" + + "Also check \"Getting started\" on our Github"); set => _xamlFilesNamespaceAliases = value; }