Skip to content

Back Compat Model Factory Method Should Not Instantiate Abstract Model Types #11877

Description

This was first reported by a user in link

Original error:

##[error]D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Generated\ArmAvsModelFactory.cs(1827,20): error CS0144: Cannot create an instance of the abstract type or interface 'AvsHostProperties' [D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Azure.ResourceManager.Avs.csproj::TargetFramework=netstandard2.0]
##[error]D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Generated\ArmAvsModelFactory.cs(1827,20): error CS0144: Cannot create an instance of the abstract type or interface 'AvsHostProperties' [D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Azure.ResourceManager.Avs.csproj::TargetFramework=net8.0]
##[error]D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Generated\ArmAvsModelFactory.cs(1827,20): error CS0144: Cannot create an instance of the abstract type or interface 'AvsHostProperties' [D:\a\_work\1\s\sdk\avs\Azure.ResourceManager.Avs\src\Azure.ResourceManager.Avs.csproj::TargetFramework=net10.0]

AvsHostProperties is abstract, so the generated back compat model factory method should never attempt to instantiate that model type directly. Instead, it should have instantiated the UnknownAvsHostProperties variant for this model. If we encounter a back compat method missing for an abstract type, we should follow that rule otherwise do not generate the method.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions