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

Generated code in latest version not compiling/missing OnPropertyChanged #39

Open
VMelnalksnis opened this issue Mar 15, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@VMelnalksnis
Copy link

Description
After upgrading to 1.1.0, OnPropertyChanged either does not get called, or PropertyChanged.SourceGenerator.Internal.EventArgsCache.PropertyChanged_PropertyName gets passed instead of property name.

To Reproduce
This only generated OnPropertyChanging, but not OnPropertyChanged.

public sealed partial class TestModel
{
	[Notify]
	private decimal _total;
}

Version Info

  • PropertyChanged.SourceGenerator version: 1.1.0
  • Roslyn Version: Compiler version: '4.5.0-6.23127.3 (e2bc27d2)'. Language version: 11.0.

Additional Info
Upgrading to this version also caused various issues in Rider.
I had to clear caches/restart it multiple times to even reproduce the simple case.

@canton7
Copy link
Owner

canton7 commented Mar 15, 2023

Thanks! I've unlisted v1.1.0 until I get a chance to look into this

@canton7 canton7 added the bug Something isn't working label Mar 15, 2023
@LeviGNMBS
Copy link

Maybe related, is this a typo on line 69?

interfaces.Add("global::System.CompoenntModel.INotifyPropertyChanging");

@chjrom
Copy link

chjrom commented Mar 16, 2024

When I cloned the repository (master branch) and manually packaged the project (dotnet pack) and used it in my project, everything works fine. There are no errors.

canton7 added a commit that referenced this issue Jul 20, 2024
canton7 added a commit that referenced this issue Jul 20, 2024
@canton7
Copy link
Owner

canton7 commented Jul 20, 2024

Maybe related, is this a typo on line 69?

interfaces.Add("global::System.CompoenntModel.INotifyPropertyChanging");

Good spot, thanks. It shouldn't be possible to actually hit that code path: we only generate an INotifyPropertyChanging implementation if the user explicitly adds that interface to their type, and in that case we don't need to add the interface to our generated type.

@LeviGNMBS
Copy link

Good spot, thanks. It shouldn't be possible to actually hit that code path: we only generate an INotifyPropertyChanging implementation if the user explicitly adds that interface to their type, and in that case we don't need to add the interface to our generated type.

No problem but are you sure about that though? The example in the quick start doesn't add the interface. Isn't it supposed to be added by the source generator then?

@canton7
Copy link
Owner

canton7 commented Jul 22, 2024

Good spot, thanks. It shouldn't be possible to actually hit that code path: we only generate an INotifyPropertyChanging implementation if the user explicitly adds that interface to their type, and in that case we don't need to add the interface to our generated type.

No problem but are you sure about that though? The example in the quick start doesn't add the interface. Isn't it supposed to be added by the source generator then?

See here:

Working with INotifyPropertyChanging is similar, with the caveat that your class or one of its base classes must implement INotifyPropertyChanging (not everone wants to implement this interface, so it's opt-in)

@LeviGNMBS
Copy link

🤦 I misread changing for changed, typical MS to make such confusing names 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants