https://pulumi.com logo
#dotnet
Title
# dotnet
m

miniature-leather-70472

09/02/2021, 1:06 PM
is it possible to have a component resource inherit from another component resource? We've got a component resource that we'd like to make some of the methods virtual and overwrite them in a child class, but it looks like it might not be possible, particuarly because we can't register the child class with the component resource class
b

bored-oyster-3147

09/02/2021, 2:08 PM
hmm can you expand on issues you're having? I am currently using some abstract component resource classes.
particuarly because we can't register the child class with the component resource class
what do you mean by this?
m

miniature-leather-70472

09/02/2021, 3:03 PM
the component resource has as a call to the base pulumi componentresource class to registry the componet e.g. : base("Network:CustomApplicationGateway", name, opts), but if the component resource inherits from another component resource, rather than the base pulumi componentResource class, this won't work because it's not calling that base class
b

bored-oyster-3147

09/02/2021, 3:15 PM
sure it can, you just need to pass everything from the derived classes constructor, and interpolate something into the resource type name parameter such that it is different from the parent class