question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code Quality: Update DependencyProperty generator to have the property declaration

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:2
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
michael-hawkercommented, Jul 11, 2023

@Poker-sang FYI we have a Toolkit Labs proposal together for this once partial properties come to .NET: https://github.com/CommunityToolkit/Labs-Windows/discussions/449

1reaction
Poker-sangcommented, Jul 13, 2023

Yes, I’m using VS2022. THat’s wierd. It should depend on .NET SDK not VS version, I suppose.

The ability to build projects depends on the .NET SDK, but the static analysis of the code (syntax highlighting) depends on the version of vs. The latest version of vs2022 (i.e. vs17.6) corresponds to roslyn version 4.6. vs2019(vs16.x) can only use the api of roslyn 3.x, while the incremental generator is a new feature of Roslyn 4.3.0 (corresponding to vs17.3). So earlier versions of vs won’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The DependencyProperty Generator
Uno provides an internal DependencyPproperty code generator, used to provide the ... To declare a dependency property, the following code must be provided:...
Read more >
How to get property change notifications with EF 4.x ...
I'm playing around with Entity Framework 4.3, and so I am using the DbContext Generator to create the context and entity classes. With...
Read more >
Dependency property callbacks and validation - WPF .NET
This article describes how to define a dependency property and implement dependency property callbacks. The callbacks support value ...
Read more >
Property Dependency | Entities | 0.17.0-preview.42
Before OnUpdate(), the Dependency property represents the combined job handles of any job that writes to the same components that the current ...
Read more >
Predefined live templates | ReSharper Documentation
This topic lists all predefined live templates in ReSharper 2023.2. Live/Surround templates can be used for generating code in existing files ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found