Skip to content

.Net: Bug: KernelParameterMetadata not compatible with C# 7.3 (netstandard 2.0 and Framework 4.7.2) #12297

Closed
@cabal95

Description

@cabal95

Describe the bug
The KernelParameterMetadata class uses init-only properties, but some of these do not have a constructor that allows setting them. When trying to create an instance of this class in .NET Framework 4.7.2 the compiler gives an error because init-only properties are not supported on C# 7.3.

The properties affected by this are:

  • Description
  • DefaultValue
  • ParameterType
  • Schema

As noted here NET Standard 2.0 and all versions of .NET Framework only support C# 7.3.

To Reproduce
Create a .NET Framework console with a reference to the Microsoft.SemanticKernal.Abstractions package and then paste in this code:

var parameter = new KernelParameterMetadata( "promptAsJson" )
{
    Description = "A JSON object with the information to register for the event.",
    IsRequired = true,
    Schema = ParseSchema( function.InputSchema )
};

Expected behavior
A constructor should be provided to allow initializing all init-only properties.

Workaround
It seems like I can use reflection to set those properties, but that isn't an ideal long-term solution.

Platform

  • Language: C#
  • Source: Microsoft.SemanticKernel.Abstractions 1.54.0
  • AI model: n/a
  • IDE: Visual Studio 17.13.7
  • OS: Windows

Additional context
n/a

Metadata

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

Status

Sprint: In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions