Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Avalonia v11 #141

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

DamianSuess
Copy link

@DamianSuess DamianSuess commented Jul 24, 2023

NOTE: This upgrade is a work-in-progress

Feature Includes:

  • Upgrade from Avalonia v0.10.x to v11.0.0
  • Added EditorConfig for VS styling and basic coding standards

References

Avalonia Changes

Pending Fixes

  • CaretHighlightAdorner.cs
    • TextBlock does not contain a definition for GetForeground
    • No overload method for RunAsync takes 3 arguments
  • ContextMenuEntry.cs
    • ContextMenu does not contain definition for ContextMenuOpening
  • CopyFullyQualifiedNameContextMenuEntry.cs
    • Application does not contain a definition for Clipboard
  • CreateListDialog.xaml.cs
    • Cannot convert lambda expression to IObserver<string> because it is not a delegate type
    • Application does not contain a definition for FocusManager
  • CustomDialog.xaml.cs
    • Cannot convert from Avalonia.StyledElement to Avalonia.Controls.Control
  • DecompilerTextView.xaml.cs
    • IWindowImpl does not contain a definition for MouseDevice
    • IPointerDevice does not contain a definition for GetPosition
    • FontManager does not contain a definition for GetInstalledForntFamilyNames
    • FontManager does not contain a definition for DefaultFontFamilyName
  • Images.cs
    • AvaloniaLocator does not contain a definition for Current
      • Deprecated: AvaloniaLocator.Current.GetService<T>
      • Usage: ...GetService<IPlatformRenderInterface>().CreateRenderTarget(...)
    • Bitmap does not contain definition for PlatformImpl (x3)
  • PlatformDependentWindow.cs
    • ITopLevelImpl.Input is inaccessable due to its protection level
    • RawKeyEventArgs does not contain a definition for Modifiers - Ava v11 is now [PrivateApi] and internal
    • RawKeyEventArgs does not contain a definition for Key
  • ResourceObjectTable.xaml.cs
    • Application does not contain a definition for Clipboard
  • ResourceStringTable.xaml.cs
    • Application does not contain a definition for Clipboard
  • SearchPane.xaml.cs
  • TextMarkerService.cs
    • Cannot convert AvaloniaEdit.Document.ISegment to int
      • Deprecated method overload: TextView.Redraw(ISegment, DispatcherPriority)
      • NEW: TextView.Redraw(ISegment)
    • Property VisualLineElementTextRunProperties.ForegroundBrush cannot be assigned - It's read only.
      • NEW: Use, element.TextRunProperties.SetForegroundBrush(foregroundBrush);
  • ThreadingSupport.cs
    • Application does not contain a definition for Clipboard

Notes

Stretch TO-DO

  • Rename .xaml to .axaml

Overview of Changes Made

Focus Manager

OpenListDialog.xaml.cs

// Avalonia v0.10
//// TemplateApplied += (sender, e) => Application.Current.FocusManager.Focus(listView);

TemplateApplied += (sender, e) => {
  // Avalonia v11
  var focusManager = TopLevel.GetTopLevel(listView).FocusManager;
  focusManager.GetFocusedElement().Focus();
};

Clipboard

// v0.10
App.Current.Clipboard.SetTextAsync(sb.ToString());

// v11.0 - TopLevel
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard.SetTextAsync(sb.ToString());

// v11.0 - Main Window
var clipboard = App.Current.GetMainWindow()?.Clipboard;
clipboard.SetTextAsync(member.ReflectionName);

@DamianSuess DamianSuess marked this pull request as draft July 24, 2023 02:19
@christophwille
Copy link
Member

Avalonia-v11-Update.md - please add that to the description of the PR but remove the file

@christophwille
Copy link
Member

Please rebase on latest master - because then the build automation fixes I made will kick in.

@DamianSuess
Copy link
Author

DamianSuess commented Jul 24, 2023

Wonderful, thanks for the heads up on both areas @christophwille. This upgrade isn't as smooth as I'd like it to be, but it was expected considering there are a lot of breaking changes moving to v11.

I'm trying to keep tabs on the undocumented Avalonia v11 upgrade areas and making updates for their docs as well.

@christophwille
Copy link
Member

Really appreciate you providing feedback to the Avalonia project!

@christophwille
Copy link
Member

How are things going? How bad is it?

@DamianSuess
Copy link
Author

Hi @christophwille, though it's not as straightforward as I'd like it to be, it is going well.

The biggest part of the slow turnaround comes down to time prioritization during the summer months. It's the usual adult life items: open-source projects, fixing my house, working on a new startup, rewind-repeat.

…rity)` to only pass, `ISegment`. Updated deprecated usage of `ForegroundBrush` property to `SetForegroundBrush()` method.
…g` to use override method, `OnPropertyChanged`. Reference: AvaloniaUI/Avalonia#10088
@DamianSuess
Copy link
Author

I didn't forget about this repo. Daytime job got very busy as we're aiming to deliver a lot in Q3. I aim to see this completed and will wrap this upgrade up as time allows.

@christophwille
Copy link
Member

How does it look like on your end - got a little time to chip away at this?

@DamianSuess
Copy link
Author

Thanks Chris for the tap on the shoulder, things got super busy at work over the past few months (got to love layoff/fire season).

I'll get back on track for you sir with Christmas vacation time coming up soon

@KubeRoot
Copy link

KubeRoot commented Nov 30, 2023

Decided to try to get this to build and run, and surprisingly, I did get it to run in some capacity.
The decompiler output isn't displaying anything, and frankly, more things are broken than working (including some outright commented out bits), but I hope I got at least some things right - the treeview appears to be functioning correctly!

Screenshot

image

I put up the changes on https://github.com/KubeRoot/AvaloniaILSpy/tree/UpgradeAvalonia11-WIP, but I didn't care much for code quality with this, so not sure how much of this is usable.
If I figure out more details, I might make a PR to your repository, if you don't mind.

EDIT: Small update, figured out the errors I've made with some things. Code is now rendering, the menu and toolbar are populated, font selection is working.
I might try to figure out how theming should work, but I can see a few big issues that I don't know how to tackle, like generating the icons and PlatformDependentWindow

@maxkatz6
Copy link

@DamianSuess @KubeRoot @christophwille please let me know if you need any help with this upgrade.

Although, I am wondering if it might be better to recreate this project from latest WPF-version sources.

@christophwille
Copy link
Member

@maxkatz6 please coordinate the porting / adaptation work with @DamianSuess (I don't know about his plans or available time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Avalonia 11
4 participants