私はこのプロパティ設定ツールで.netコアにコードを移植しようとしています。私はこの場合、私が期待していなかったエラーを得る。どうして?違いは?C#のオプションの列挙型のプロパティsetterは古典的な.netでコンパイルされますが、.netのコアではコンパイルされませんか? (cs0019)
/// <remarks>This uses the native .NET datatype, rather than the FHIR equivalent</remarks>
[NotMapped]
[IgnoreDataMemberAttribute]
public Hl7.Fhir.Model.RemittanceOutcome? Outcome
{
get { return OutcomeElement != null ? OutcomeElement.Value : null; }
set
{
if(value == null) // CS00019
OutcomeElement = null;
else
OutcomeElement = new Code<Hl7.Fhir.Model.RemittanceOutcome>(value);
OnPropertyChanged("Outcome");
}
}
エラーがEnum?
任意タイプのセッターである:
CS0019 Operator '==' cannot be applied to operands of type
'RemittanceOutcome?' and '<null>'
型RemittanceOutcomeがpublic enum RemittanceOutcome
あります。オプションの列挙型の場合、これは不可能になったのか、それとも実装が異なるのでしょうか?私はASP.netコア1.0.0 rtmでコンパイラのバグに襲われていますか?
これは、このようなproject.jsonと.NETのコアライブラリである:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"Newtonsoft.Json": "9.0.1",
"System.ComponentModel.Annotations": "4.1.0",
"System.ComponentModel.Primitives": "4.1.0",
"System.Diagnostics.Contracts": "4.0.1",
"System.Net.Requests": "4.0.11"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
},
"buildOptions": {
"define": [],
"nowarn": [ "CS3016" ]
}
}
は(ASPNETコア1.0.0 RTM)をdnxcore50するために、このコードを移植する他のいくつかの驚きがありますが、この1は思わ初心者のために十分に噛み付くほど十分です。
サンプルプロジェクト:https://github.com/wpostma/fhir-net-api - ブランチdnxcore50。
私に奇妙な音。好奇心のために、あなたが 'if(!value.HasValue)...'と言うとうまくいくでしょうか? –
「==」のバグや演算子のオーバーロードがありません。こちらの問題(https://github.com/dotnet/corefx/issues)にご記入の上、.NETコアの開発者が何を言っているのかをご覧ください。 – Tseng
GitHubのcorefx課題トラッカーに問題を追加しました。 https://github.com/dotnet/corefx/issues/9859 – Tseng