Using a different base component class
See original GitHub issueMvvmComponentBase
inherits from ComponentBase
. What’s the best practice if we want to use a different base component class, say OwningComponentBase
or AbpComponentBase
as we are using the ABP framework, yet still want to keep the functionalities provided by MvvmComponentBase
?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:15 (15 by maintainers)
Top Results From Across the Web
How To Extend Classes with Angular Component Inheritance
Using class inheritance in TypeScript, you can declare a base component that ... Let's start by using the Angular CLI to create a...
Read more >How to inherit a component in Angular and reuse its template
You may override Base component's CSS by adding multiple CSS files too. ... You create a BaseComponent class, and do ChildComponent extends BaseComponent...
Read more >How to extend / inherit components? - angular
2 - Base Component with @Component decorator: ... more components contains shared logic: use a service or even create a new typescript class...
Read more >All about that BaseComponent
I find in most large projects you end up having some reusable functionality that fits perfectly in a base class. In a future...
Read more >Component Inheritance in Angular - Bits and Pieces
Using inheritance in TypeScript we can use the Parent-Child design to delegate the common code to a base class and let other components...
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
Since we now got code generators in .NET I’m not a huge fan of Fody weavers any more. They served their purpose, but the built in source generators should do the job. The docs cover our use case.
My plan would be to ship that source generator too (either in a separate NuGet package or directly with the main one). This way, any integration would happen by defining a partial class with a given attribute that would be picked up by the source generator.
So the problem here is misusing of the
ISyntaxContextReceiver
. For each compilation unit (assembly), only one instance of eachISyntaxContextReceiver
is created and they are being reused again and again, for allGeneratorSyntaxContext
s.In the
MvvmBlazor
project, there are 3 classes annotated with theMvvmComponentAttribute
. TheMvvmSyntaxReceiver
visits them one by one, and only keeps theComponentClass
andComponentSymbol
values for the last of them, which I see isMvvmOwningComponentBase
. Therefore you can see the code was only generated for that last class, but not for other classes, e.g.MvvmComponentBase<T>
, which is used in the sample project and thus it did not compile.With that fixed, some minor issues expose, like
MvvmComponentBase<T>
andMvvmComponentBase
has the same identifier, but you have to generate their code to different files, and the generic source template missed thepartial
modifier etc.I’ve fixed those problems here, the solution now compiles, except for a test project which I did not bother to look: https://github.com/klemmchr/MvvmBlazor/pull/54