Skip to content

Conversation

@ShivangiReja
Copy link
Collaborator

This PR removes the use of the required modifier as it is not necessary. According to the guidelines, the constructor should take the required parameters.

BinaryData IPersistableModel<FileSearchToolResources>.Write(ModelReaderWriterOptions options);
}
public class FunctionToolDefinition : ToolDefinition, IJsonModel<FunctionToolDefinition>, IPersistableModel<FunctionToolDefinition> {
public FunctionToolDefinition();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the required keyword on these if we provide a public default constructor -- that is, if we want to support use like:

Tools =
{
    new FunctionToolDefinition()
    {
        FunctionName = "my_function",
    }
},

Without the keyword, there's no enforcement of the required properties being present.

I thought we'd agreed in the architecture discussion to keep the required property with default constructor support together with the constructor that accepts all required properties.

If we want to remove required, I'd like to understand why but also don't think we can do it without also removing the public default constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the default constructor as it aligns better with our established guidelines. According to the guidelines, we should provide public constructors with required parameters instead of relying on property initializers, as this ensures that necessary properties are always set.

Currently, only two models use the required modifier, which is inconsistent with the rest of our models. I think a better approach is to remove the required modifier from these models and provide only public constructors with required parameters. This way, we maintain consistency and follow best practices.

@joseharriaga joseharriaga marked this pull request as draft September 19, 2024 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants