anthropics / anthropics/anthropic-sdk-csharp

Unable to use Anthropic package from .Net Standard 2.0 environments due to the "get;init" properties

オープン
#258 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C#
スター
322
フォーク
105
平均マージ
1日 6時間
マージ済み PR(30日)
9

説明

The `Anthropic` package declares itself as compatible with .Net Standard 2.0.
In particular that means it [should work][1] in the classic .Net Framework 4.6.1 and later.
It does not.

It installs successfully, but it cannot be used because Visual Studio will refuse to touch any classes from it whose properties are declared as `{ get; init; }`. Starting with the `MessageCreateParams` class.

So trying to do the simple:

```cs
var parameters = new MessageCreateParams
{
Model = Model.ClaudeSonnet5,
MaxTokens = 2048,
...
};
```
will result in multiple of:

> Feature 'init-only setters' is not available in C# 7.3. Please use language version 9.0 or greater.

, one for each property of `MessageCreateParams` that you have touched.

The language version is set at 7.3 by Visual Studio based on the FW 4.7.1 used.

Here is a Stack Overflow question about this same problem, as applied to the CvsHelper library: https://stackoverflow.com/questions/66491591/after-update-to-vs-16-9-0-feature-init-only-setters-is-not-available-in-c-sha.

The authors of said library have reverted the `init` change; I believe you should too.

[1]: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。