Code Quality: Update DependencyProperty generator to have the property declaration
See original GitHub issueDescription
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.
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:
- Created 2 months ago
- Reactions:2
- Comments:10 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
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.