Skip to content

Code Quality: Update DependencyProperty generator to have the property declaration #12889

Closed as not planned
@0x5bfa

Description

@0x5bfa

Description

We have a problem about SourceGenerator - that is we cannot reference to the generated property in advance. Whenever I hover on the property, Visual Studio tells me there's a error that there's no such a property in the project because the proeprty is not declared explicitly although they will be disappeared in building.

image

Current:

namespace Files.App.UserControls
{
	[DependencyProperty<ToolbarViewModel>("ViewModel")]
	public sealed partial class PathBreadcrumb : UserControl
	{
		private void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
			=> ViewModel.PathItemSeparator_DataContextChanged(sender, args);
	}
}

Proposal:

namespace Files.App.UserControls
{
	public sealed partial class PathBreadcrumb : UserControl
	{
		[DependencyProperty]
		pubilc ToolbarViewModel ViewModel { get; set; }

		private void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
			=> ViewModel.PathItemSeparator_DataContextChanged(sender, args);
	}
}

Concerned code

  • Files.Core.SourceGenerator

Gains

  • A better readability.
  • A better maintainability.

Requirements

  • Update source generation way

Comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions