MVVM Source Generators: Never Write MVVM Boilerplate Code Again!

Поделиться
HTML-код
  • Опубликовано: 18 янв 2025

Комментарии • 293

  • @JamesMontemagno
    @JamesMontemagno  2 года назад +17

    There have been several updates to the library and name changes for the properties, so check out github.com/CommunityToolkit/dotnet/releases/tag/v8.0.0 for changes

    • @mikp1280
      @mikp1280 2 года назад

      This comment saved my day :) Thanks James!

    • @meilleur102
      @meilleur102 2 года назад

      Hi! Idk if you can help me on one thing. When I create a [ObservableProperty] of anything (string, ObservableCollection etc) the binding work perfectly.
      When I create a [ObservableProperty ] of a Model, i can't get the ui to update...I really don't get it.
      When I debug my Model.Properties get updated, but the ui dont. I try UpdateSourceTrigger=PropertyChanged, OneWay, TwoWay etc on the view. Nothing works.
      Thanks

    • @paulegan3783
      @paulegan3783 2 года назад

      Cheers!

  • @comediehero
    @comediehero 2 года назад +39

    Wow, finally something that fixes my biggest gripe with xaml MVVM development. Thx James!

  • @jontemplin6990
    @jontemplin6990 2 года назад +19

    This is so awesome! One of the hurdles of understanding and effectively using MVVM was getting your head around all the boilerplate plumbing code and understanding why it's needed. I always thought to myself "why can I just specify properties and commands and let the compiler do all the ceremony?" Yay! It finally happened!

  • @georgeleithead
    @georgeleithead 2 года назад +15

    Makes the code so much cleaner, and easier to understand for others.

  • @munver19
    @munver19 2 года назад +1

    Great tutorial, Thanks James.

  • @mrrob1454
    @mrrob1454 2 года назад +6

    Amazing. This just made WPF applications 100 times easier. Thanks for the great video.

  • @ByronBennett
    @ByronBennett 2 года назад +6

    This is beyond awesome! Super easy to implement. Makes your code soooo lean and easy to read. I love how you can use the code generation where you want to and still go the long route if you need to do stuff in your Get or Set. Excellent code! And a great video showing how to use it!

  • @stevehidem816
    @stevehidem816 2 года назад +3

    Shout out to James! You continue to help me up my game. This MVVM source generator is awesome and I look forward to more updates on recent developments.

  • @has_ali
    @has_ali 2 года назад

    Love to see the excitement in your own expressions, tells you how great it is !

  • @e2a2j
    @e2a2j 2 года назад +1

    MIND BLOWN! I love this with a passion. This helps reduce stupid errors both in initial creation and going back and modifying. This is awesome. I've used code generators in the past and I love them, but this is next level. Thanks again James!

  • @MaximilienNoal
    @MaximilienNoal 2 года назад +1

    I was stuck with mvvm since 2010. Now, I finally love it.

  • @danielblakeley2995
    @danielblakeley2995 2 года назад

    The best MVVM content creator ever thanks james.

  • @Otonium
    @Otonium 2 года назад +1

    Wow, at last all that tons of lines went away... Keep those in just (a little few) attributes (not towers) thogh
    Maybe with a comma we'll avoid attributes towers. Great video!😎 James.

  • @xamarinmaster1403
    @xamarinmaster1403 4 месяца назад

    Awesome! I just tried this against OpenSilver and it works GREAT!

  • @JesseLiberty
    @JesseLiberty 2 года назад +2

    Great, great, great. And as usual, brilliantly described. Nice work James & team.

  • @jimsimson7266
    @jimsimson7266 2 года назад

    My mind IS blown James! Thank you!

  • @Agredo10
    @Agredo10 2 года назад +1

    Wow simply wow! The MCT.MVVM was already very helpful but this is incredible!

  • @Jgathairu
    @Jgathairu 2 года назад +1

    Thanks James! Amazing and easily broken down. Definitely applying this

  • @enzodiaz3921
    @enzodiaz3921 2 года назад +1

    You said it: it's ridiculously awesome. I've been working with WINUI 3 and i can see some differences that could be tricky for a newbie like me, but in the road we learn. Thanks James.

  • @azizjel
    @azizjel 2 года назад

    Listening to James makes me think of those old grow hair potion salesmen:
    " Well James, you wrote the ISync command, now What if you want to sink the Submit button and make it sing the song?"
    James:"Well you just need to carry the CommunityDev boilerplate which comes with the Generator..".
    Thanks for the the very interesting presentation James though! I like it 🙃😉

  • @worknaturebalance
    @worknaturebalance 2 года назад +5

    Hey James. You can do this for many years using propertychanged.fody nuget package.
    What is even better it can do this without all those attributes. Especially combined values like Full name from your example. You can use them directly without specifying that it should be updated in other properties attribute.
    The thing about ICommand is quite neat in your presentation, this is currently not present in propertychanged.fody
    But also it's quite small price to pay in comparison with all the boilerplate code for properties.
    On a side note. Keep up the good work. I was using many packages of yours for few years already. Thank you for every single one of them. Cheers

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +2

      I should have talked a bit about fody a bit in there. It is more assembly weaving to manipulate IL from my understanding. Where this is source generators where they are generated instantly without compilation. Correct me if I am wrong.

    • @EngLuizFranco
      @EngLuizFranco 2 года назад +1

      @@JamesMontemagno You're right. Despite fody adding zero boilerplate, you do not have access to the generated code, because its generated at compile time. With source generators, you can see in real time all the code that is generated which is awesome in my opinion and gives us the opportunity to learn new things by exploring the generated code.

    • @williamliu8985
      @williamliu8985 2 года назад +1

      @@JamesMontemagno I think the source generator might not be mature enough at this time. It sometimes bring in strange issues and I should reload the project for fixing it. Hope MSFT can make this tool much better.

    • @worknaturebalance
      @worknaturebalance 2 года назад

      @@JamesMontemagno as Luiz said, you are absolutely right.
      Source generators have other benefits, but also propertychanged.fody gives you the same outcome with cleaner code (no attributes needed). Also I don't remember if I ever needed to inspect the code that got generated. In most cases it's quite simple.
      Would it be possible to use source generators without those attributes?

    • @morgenrot2640
      @morgenrot2640 2 года назад

      @@williamliu8985 Unfortunately, I had to find that out too.

  • @LordErnie
    @LordErnie 2 года назад +2

    Yet again James is here to save the day for devs and students, thanks man.

  • @collinsk8754
    @collinsk8754 2 года назад +1

    Really great addition to the community toolkit! Thanks a lot for the tutorial.

  • @zappledd6598
    @zappledd6598 2 года назад +1

    Top notch! Nice work.

  • @kwesiboateng2646
    @kwesiboateng2646 2 года назад

    My mind was blown james, when you decorated the private fields with ObservableProperty

  • @maso4u
    @maso4u 2 года назад +1

    I keep getting "the namespace for AlsoNotifyChangeForAttribute could not be found" Error when I try using AlsoNotifyChangeForAttribute in my view model property

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      The final version introduces some new names github.com/CommunityToolkit/dotnet/releases/tag/v8.0.0

    • @maso4u
      @maso4u 2 года назад

      @@JamesMontemagno Oh! thank you, I thought I had broken something somewhere
      Are you aware if there have been any fixes on the .Net SDK bug that duplicates source generators on-build?

  • @malkywullur8683
    @malkywullur8683 2 года назад +1

    Yes, this would be my 1st personal choice among others mmvm library out there !! Thanks a bunch

  • @GeorgAubele
    @GeorgAubele 2 месяца назад

    That is absolutely amazing! Thanks!

  • @marcelfischer5139
    @marcelfischer5139 2 года назад +1

    James, thank you for this video. I wrote so much code over the last years, that I can now delete. - Just a joke. I definitely check this out!

  • @LeeM0to
    @LeeM0to 2 года назад +1

    Wow... Game changer. Kudos to all involved. Can't wait to start using it. Thanks for the video James 👍

  • @ericblankenburg
    @ericblankenburg 2 года назад +1

    This is really great. Thanks for posting.

  • @isax55
    @isax55 2 года назад +2

    Hooo, I need to update my projects right now!!

  • @belmiris1371
    @belmiris1371 2 года назад +4

    It's a great idea. Since I'm a WinForms guy I keep sliding back to it because it's so simple and I can write stuff fast and clean. I tried MVVM again on my latest Xamarin application (since WinForms was not an option) but still ended up using mostly code behind because I found all the MVVM stuff just too hard to keep track of and getting it to work cleanly with the UI was just too daunting. If these people can make it less complicated that would be great. I DID find the code it generated very scary looking though. If I get some bizarre error about eyepoke() not properly initialized or the my app just hanging or disappearing I would probably give up and go simple again.

  • @kosteash
    @kosteash 2 года назад

    wow James, you are amazing. You showed my so many cool nugets, that make my life easier. Thank you very much !

  • @ignispurgatorius5297
    @ignispurgatorius5297 Год назад

    While I've gotten used to MVVM in WPF, at the end of the day I'm still not convinced it is actually nearly as good a pattern as the head-in-the-clounds programers make it out to be. The reality of my (and I think many others) is simply not at the scale where we really profit from it. Back when we switched to it, it was sold with the promises of having the option to easily outsource the view design (because of the decoupling), being unit testable and being oh-so-efficient. After working with it for years, I have to say that I still end up writing most if not all of my view code myself. I have barely written any unit tests, because the stuff that actually fails is way to much effort to unit test and the simple stuff I have clicked through quicker than I've set up the test. And lastly I don't think having to do 3 things to handle a button event or drowning in property boilerplate code has made the code any more readable or quicker to produce. The tiny bit of intellisense support you get from it hardly makes it worth it imho. I know there are plenty of nugets and extension to help with this and we've used a couple of them mostly successfully over the years, but it never really felt like at the base the effort was worth it
    That being said, seeing this auto code generation I feel like we've finally reached a the point where the extra effort has been reduced to a level that no longer negates all the smaller benefits (I will probably still not write alot of unit tests or have some of those mythical html programmers swoop in and design beautiful GUIs for me :P). I just wish I could actually use it in all the older projets we still have to maintain, but sadly they are still mostly on .Net4.7. Well at least going forward it will become alot nicer.

  • @paulegan3783
    @paulegan3783 2 года назад

    Thanks so much James, very nice

  • @joehanna_
    @joehanna_ 2 года назад +1

    Sweet! I use base classes to do some of that but it is not a lovely as using the attributes with the generators. The new code feels right and clean. Chunky boilerplate code has always felt dirty

  • @origamiiekiller
    @origamiiekiller 2 года назад +3

    Hi James,
    Great content and thank you for bringing this to my attention, seems to work perfectly in your demo.
    Small question: You had an example with the asynchronous command. Will the binding still work if I postfix the name of the method to 'SubmitAsync'? Or does the generated binding only work, because the name is 'Submit' for the method and 'SubmitCommand' in the Xaml?

  • @shrikantthorve5701
    @shrikantthorve5701 2 года назад +2

    Thank you James for really nice video..
    One suggestion, could you please create video on DeepLinking where application can launch from url like Amazon...

  • @Gazcan
    @Gazcan 2 года назад

    This is so good, that it makes me wonder why this wasn't there with the release of WPF.

  • @zandyaverhoff9554
    @zandyaverhoff9554 2 года назад

    wow, how many things are change. Thank jame

  • @TonyHenrique
    @TonyHenrique 2 года назад +1

    This is awesome! Very clever implementation.

  • @Proto61
    @Proto61 2 года назад

    Thank you for the awesome video, could you make a video how to use Messengers with the toolkit? And a video for navigation would be also very nice. Thank you!

  • @hrishikeshgarud7177
    @hrishikeshgarud7177 2 года назад

    Very useful. I was doing everything code behind. Now i will try this.

  • @Sajgoniarz
    @Sajgoniarz 2 года назад

    Amazing stuff, thanks You very much! I'm writing a simple app for my team and i just can't wrap my head around how inefficient to write is WPF.

  • @astrowalker2629
    @astrowalker2629 2 года назад

    Awesome, thank you very much. Now I am on the hunt for some good tutorials how to create such generators by myself 🙂.

  • @billymartin6497
    @billymartin6497 2 года назад +2

    Great video, as usual, James. Couple quick questions: How do we pass command parameters? Does it function inside of VS 2019? Sometimes we have to drop back to use the MultiLingual extension, since it's not in VS 2022.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      I believe they should, but I only have 2022 on my machines now

    • @Sergio0694
      @Sergio0694 2 года назад

      You can pass command parameter through whatever system the UI framework you're using has, that's separate from the command implementations the MVVM Toolkit has (for instance, on WPF/UWP/WinUI you'd do CommandParameter="{Binding ...}", or {x:Bind ...}, etc.). As for VS2019, no the generators will not work there. For the 8.0.0 release of the MVVM Toolkit I've rewritten all of them to be incremental generators, and that feature needs Roslyn 4.x to work, which isn't available on VS2019. You'll need VS2022 for that (or another modern IDE of your choice, eg. Rider). Hope this helps!

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Checkout github.com/CommunityToolkit/dotnet/issues/158 for a working sample, You will need to put things in a .NET Standard library for it to fully work.

  • @suchtendolp644
    @suchtendolp644 2 года назад

    You changed my life, bro.

  • @PticostaricaGS
    @PticostaricaGS 2 года назад

    Excellent video, and great topic, there is still a lack of video-content on Source Generators

  • @RaabStephan
    @RaabStephan 2 года назад

    This is honestly pretty amazing!

  • @emmanueladebiyi2109
    @emmanueladebiyi2109 2 года назад

    Truly an awesome library

  • @matk5087
    @matk5087 2 года назад +1

    Such a great tool :) thx for sharing!!!!

  • @anderson.damasio
    @anderson.damasio 2 года назад

    very good this! James

  • @marufahmad4385
    @marufahmad4385 2 года назад +1

    Thanks for the great content. Can you please also make a video on MVVM Messaging?

  • @MarcJennings
    @MarcJennings 2 года назад +1

    Game changer! Can't wait to get stuck in!

  • @ssg3219
    @ssg3219 2 года назад

    AlsoNotifyCanExecuteFor() and the AllowConcurrentExecutions flag are currently missing from the Community Toolkit. Will they be coming back? If not, how should that functionality be implemented?

  • @billashton6511
    @billashton6511 2 года назад

    Looks like the future to me James..!

  • @waynemv
    @waynemv 2 года назад

    Is there a source generator or other clean way to add undo/redo functionality to the form in your example?

  • @anandshindey
    @anandshindey 2 года назад

    This is awesome. Thanks James.

  • @buddysnackit1758
    @buddysnackit1758 2 года назад

    I actually made a post about "Why doesn't a system that generates the MVVM code for you!" in one of your older videos! Yes!

  • @ghanimalmarzouqi3277
    @ghanimalmarzouqi3277 2 года назад +1

    Many thanks to you James. This is really helpful and blowing my mind too 🤯🤯🤩.

  • @WilliamCarinci
    @WilliamCarinci 2 года назад

    In using the MVVM pattern, how do you go about handling Navigation.PushModalAsync when it often expects a parameter of type Page? In particular, this seems to be a concern of mine when handling a page NOT defined as a shell page. For instance, a settings modal. It seems peculiar that you get caught in an issue where the .xaml.cs of a page gets set with the BindingContext = viewModel.

  • @hernanlanusse5558
    @hernanlanusse5558 Год назад

    Hi James, how can I implement an ObservableCollection using this method?

  • @JoseSilva-gt6zj
    @JoseSilva-gt6zj 2 года назад +2

    Awesome explanation, James! Thank you! Let me ask about obfuscation. Do you know if it works after obfuscating the code? I mean for a WPF app. Thanks!

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      Yes it does from my understanding, it is the same as if you wrote the code ;)

  • @nyumbanikwetu9194
    @nyumbanikwetu9194 2 года назад

    It seems I can't user interface beside ObservableObject, is there a way around this? Is it possible to do:
    public partial class NameViewModel : ObservableObject
    , IName

  • @Albahadly
    @Albahadly 2 года назад

    Thanks James, you really treasure

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 2 года назад +1

    I am with you. I created a source generator for MVVM 7 years ago, and since then I stopped writing a lot of a code. Everything is done by the source generator. Continue to propagate the idea.

    • @ostelaymetaule
      @ostelaymetaule 2 года назад +1

      How many juniour developers could understand and extend on your code without wondering about black magic and stuff? D: I am very very cautious every time I see some work being done in background by some sort of extensions or dynamic code generation or self invented conventions nobody else in the world knows about. One thing is to rely on ms own attributes and conventions with tons of documentation and tests and usage and another is thinking that I am able to create, support and fix this on my own and that when I quit the job the next guy will know what the hell is happening in the code

    • @kamertonaudiophileplayer847
      @kamertonaudiophileplayer847 2 года назад +1

      @@ostelaymetaule It is a very good concern and actually I had a fear that simply developers will run away. But to my surprise, a feedback was completely opposite. They gladly started using it. Why? If system is designed well, it is so natural and intuitive, developers on any level, especially juniors, just use it.

    • @ostelaymetaule
      @ostelaymetaule 2 года назад +1

      @@kamertonaudiophileplayer847 I am glad to hear you managed to make it work, I have seen couple examples earlier in my career as well, but also encountered some over engineered magic bazoongas nobody knows what it does and the original dev is long gone ;)

    • @kamertonaudiophileplayer847
      @kamertonaudiophileplayer847 2 года назад

      @@ostelaymetaule It is normal, we lost several good developers exactly for the reason. Some system for some reason wasn't designed by us well. The result was really disappointing, we started loosing people because they simply can't use the system. Solution? Do not be afraid of to redesign the system instead of trying to fix it little by little.

  • @kashifenet1983
    @kashifenet1983 2 года назад

    Cool that is too much life will be easy after using this Thank you JM

  • @MohitKesarwaniPhoton
    @MohitKesarwaniPhoton 2 года назад +1

    Amazing that is what I wanted

  • @lerocher2182
    @lerocher2182 2 года назад

    Thx James,
    How can I use CanExecute for the Command function?

  • @soixantelly
    @soixantelly 2 года назад +2

    MVVM is now practical with this

  • @nixnemo
    @nixnemo 2 года назад

    Looks/sounds amazing. Many thanks for the efforts. If [ObservableProperty] attribute would work without compilation error, telling MyViewModel already exists, I would really appreciate. Many thanks in advance. Again, really appreciate what you done.

  • @zappledd6598
    @zappledd6598 2 года назад

    Hi James, I love your tutorials. I've been diving a bit deeper into the MMVM Toolkit as I steadily replace my old MVVMLight code. One area not covered in your video that I'd like some more insight into is the ICommand "RaiseCanExecuteChanged". I'm seeing things like [NotifyCanExecuteChangedFor] in the new Toolkit that looks promising. Do you have a video that covers this or can you point me somewhere that might? Thanks so much.

  • @L-E-son
    @L-E-son 2 года назад

    VERY cool! Thanks for sharing!

  • @solomonfried7018
    @solomonfried7018 2 года назад +2

    Incredible tool! Thanks. How is Can Execute Command implemented?

    • @williamliu8985
      @williamliu8985 2 года назад

      +1

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +2

      Good question, checkout the blog for sure -> devblogs.microsoft.com/ifdef-windows/announcing-net-community-toolkit-v8-0-0-preview-1/ You can do -> [AlsoNotifyCanExecuteFor] on a property

    • @gwisekor
      @gwisekor 2 года назад

      +1

    • @robertodalmonte504
      @robertodalmonte504 2 года назад

      I had same question myself...
      [INotifyPropertyChanged]
      public partial class MainWindowViewModel
      {
      [ObservableProperty]
      [AlsoNotifyChangeFor(nameof(FullName))]
      [AlsoNotifyCanExecuteFor(nameof(ShowCommand))]
      private string firstName = string.Empty;
      [ObservableProperty]
      [AlsoNotifyChangeFor(nameof(FullName))]
      [AlsoNotifyCanExecuteFor(nameof(ShowCommand))]
      private string lastName = string.Empty;
      public string FullName => $"{LastName} {FirstName}";
      public bool CanShow { get => firstName.Length > 2 && lastName.Length > 2; }
      [ICommand(CanExecute = nameof(CanShow))]
      private void Show()
      {
      MessageBox.Show(FullName);
      }
      partial void OnFirstNameChanged(string value)
      {
      if (CanShow)
      {
      MessageBox.Show($"Execute Custom code on {value}");
      }
      }
      }
      XAML:

  • @MarekLS60
    @MarekLS60 2 года назад +1

    Great tutorial !!!

  • @RebrandSoon0000
    @RebrandSoon0000 2 года назад

    James, I am confused on this method, how do I add a Model to this? or does it all go in ViewModels?

  • @umermahmood6366
    @umermahmood6366 2 года назад

    Cant seem to find documentation for using these attributes anywhere. If someone knows, please share.

  • @xamarinmaster1403
    @xamarinmaster1403 2 года назад

    With Xamarin.Forms, I am used to using the code behind page class as the view model since it already implements INotifyPropertyChanged. Therefore, I would just set the BindingContext = this and life was good. I attempted to do the same thing with MAUI and with these new code generators. Unfortunately, it doesn't work. It looks like the implementation of INotifyPropertyChanged is slightly different between MAUI Pages and the CommunityToolkit. The end result is: cannot convert from 'System.ComponentModel.PropertyChangedEventArgs' to 'string'. Can this be fixed? I find using the Page class as the ViewModel very convenient as that means one less class to deal with. But perhaps this is bad practice?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Added a Xamarin.Forms sample for you, make sure you set your "LangVersion" for your shared code -> github.com/jamesmontemagno/mvvmsourcegenerators works prefect.

    • @xamarinmaster1403
      @xamarinmaster1403 2 года назад

      @@JamesMontemagno I think you misunderstood. Your new Forms sample still uses a separate class as the view model. My question is regarding using the code behind Page class as the view model. So in your new sample, delete the MainViewModel.cs and try to put your bindable properties in the MainPage.xaml.cs file instead.

  • @sobad123
    @sobad123 2 года назад

    Is there a way that ICommand attribute would take OnException delegate as argument? Similary to how it is used it Xamarin Community Toolkit AsyncCommand?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      I don't think so, but I would open an issue and ask github.com/CommunityToolkit/dotnet

  • @beater6967
    @beater6967 2 года назад

    How do I control the generated property name casing? For example if I have backing field of _iPhone this tool insists on renaming that property to IPhone.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      I believe it just uses standard c# rules. I try to stay away from iPhone and iOS in my source code as rule validates get mad. Seems like a good feature request to request generated name. Throw it up on GitHub

  • @jewersp
    @jewersp 2 года назад

    Hi James. This is pretty awesome. The pattern with the if(SetProperty(...)) { ... } is not new to me, I've been using that already for a while now since MvvmLight allowed me to do the same thing, except for the code generation part of it. Does this mean that we can reuse our ViewModels and share them between Xamarin/MAUI and WPF applications? Does the new Community Toolkit also include ICommand derivatives and implementations for IAsyncCommand like the Xamarin Community Toolkit does? BTW, I absolutely love that we can update the canExecute flag of Commands using attributes now, it takes away a lot of messy code pain.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      It does, it included RelayCommand and AsyncRelayCommand or something like that, it is what it generates

    • @jewersp
      @jewersp 2 года назад

      @@JamesMontemagno that's awesome. Thanks! 😊

  • @WarBorg
    @WarBorg 2 года назад

    hey James, awesome video as always, one question sits on my mind, how does this work with the xamarin community toolkit and the future MAUI community toolkit, as I see some overlapping bits, thx!

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      So they are all on the same GitHub organization now and are aligned. The genera .NET one will focus on full compatibility with all .NET apps and then the individual one will be specific to the frameworks and they are working on minimizing any overlap

    • @WarBorg
      @WarBorg 2 года назад

      @@JamesMontemagno awesome thx for the answer, I really like the code generated stuff but I would like to use the xamarin / Maui community toolkit as well and not have to worry about using the wrong namespace :D

  • @diogopio
    @diogopio 2 года назад

    Hi James, thank you for this awesome video! I was trying to use the MVVM with App Center but it seems that the code is not being generated, does anyone knows how to fix that? Thanks!

  • @doublebass120
    @doublebass120 2 года назад +1

    Excellent library, great video!
    Does this also work for Xamarin Forms and WPF?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +3

      Yes it does!

    • @royeagle
      @royeagle 2 года назад

      I tried it but I get “This generator is not generating files…”

    • @royeagle
      @royeagle 2 года назад

      @@JamesMontemagno I can get the ObservableProperty to work after changing to C# 9 in Xamarin Forms. Can't get the ICommand to work, the method is never called. Ver 8.0 preview2.

    • @royeagle
      @royeagle 2 года назад +1

      I figured it out. I named my method ClickMeCommand and it did not work. I changed it to ClickMe and now it works.

  • @KySuHocCode
    @KySuHocCode Год назад

    I use the Class Library but it doesn't automatically generate code for me? How do I solve that problem. Thank you.

    • @JamesMontemagno
      @JamesMontemagno  Год назад

      What type of class library? Try .net 6 or .net 7 class library or make sure to turn on newer language features in the csproj

  • @randyblock8747
    @randyblock8747 2 года назад

    Thankyou for the video. Does the mvvm community toolkit make navigation easier?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      It isn’t a framework at all just helpers. Not sure what you are building with and for our what problems what you are having but would love to learn. Reach out on twitter

    • @randyblock8747
      @randyblock8747 2 года назад

      @@JamesMontemagno just hard to set up navigation in mvvm..it’s not too bad when you have a simple UI, just when you’re UI is a little different and you need communication between viewmodels.. was hoping that it would have a little framework behind it instead of just helpers.

  • @ArabGirlLifestyle
    @ArabGirlLifestyle 2 года назад

    Doesn't work with VS for Mac in Xamarin for iOS or Android :(

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Source generators will need the latest version of .NET installed on the machine. I would test out VS 2022 preview and it should work there.

  • @RajK09
    @RajK09 2 года назад

    It'll be very useful. What if we'd like to call a method when a property has changed?

  • @NehaSingh-fe7nu
    @NehaSingh-fe7nu 2 года назад

    Hi James, I am building a poc blazor hybrid application using .NET Maui in VS Preview 2022, and I am using razor pages for the UI. I am using INotifyPropertyChanged, but somehow it doesn't seem to work, anything you might know about this? Any help appreciated, thanks!

  • @vladmartian
    @vladmartian 2 года назад

    How about wrapping objects POCO classes like SetProperty(_client.Code, value, _client, (c, c) => c.Code = c). How do I use the attributes?

  • @jeffgaskill8577
    @jeffgaskill8577 2 года назад

    Anyone know how you'd specify a command predicate through the ICommand attribute? Says it has one overload, but it has none.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      The attribute is now RelayCommand in the latest version so take a look at that and the docs

  • @sbsp20052000
    @sbsp20052000 2 года назад

    This is cool but I'm coming from WPF and MVVMLight world, how do you handle CanExecute with this implementation? Also on the properties how would we make an Observable property immutable (read-only)?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      You can pass in a method that is call for canexecute on the attribute. I am not sure about the immutable property, would ask them on github

  • @clyntneikorupinta5760
    @clyntneikorupinta5760 2 года назад

    Is this possible on razor files? like "@attribute [ObservableObject]

  • @stasasekulic6917
    @stasasekulic6917 Год назад

    Can you create some advanced tutorial on this? Navigation bar with views, commands and stuff?

  • @diogopio
    @diogopio 2 года назад

    How to integrate that library with with App Center?

  • @esmildervidal3990
    @esmildervidal3990 3 месяца назад

    How to pass parameters in RelayCommand?

  • @mashrulhaque1168
    @mashrulhaque1168 2 года назад

    Thank you so much James

  • @debasishdey8460
    @debasishdey8460 2 года назад

    Hey James what will be the effect of app size for large production app

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      None as it is all generated optimized code, nothing is happening at runtime. If anything maybe every performance gains due to optimizations.

  • @felipeapj
    @felipeapj 2 года назад

    I wish a can give more than just a thumbs up, thats awesome!!!