2017-05-04 6 views
3

ネットコアのxsdからクラスを生成する必要があります。 dotnet標準で私はコマンドラインを使用しましたxsd filename.xsd /c. しかし、このクラスをネットコアに作成する方法。 誰でもこれを行う方法を知っていますか?ネットコアのxsdファイルからクラスを生成する

xsd.exeで生成されたクラスを追加すると、いくつかのエラーが発生します。

例AUTOGENファイル内のクラスから

Error CS0234 The type or namespace name 'SerializableAttributeAttribute' does not exist in the namespace 'System' (are you missing an assembly reference?) 


Error CS0234 The type or namespace name 'DesignerCategoryAttribute' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) 

Error CS0234 The type or namespace name 'XmlTypeAttributeAttribute' does not exist in the namespace 'System.Xml.Serialization' (are you missing an assembly reference?) 

Error CS0246 The type or namespace name 'AnonymousType' could not be found (are you missing a using directive or an assembly reference?) 

属性

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 
+0

あなたの質問をさらに詳しく指定する必要があります。生成されたクラスを.NET Coreで動作させるものではないものはありますか? xsdは、max(xmlとdatacontract属性は.NET Coreですでに利用可能である必要があります)の属性を持つ通常のpocoクラスを生成する必要があります。 – Tseng

答えて

5

私は今、プロジェクトにナゲットを追加することでこの問題を解決しました。

  • System.Xml.XmlSerializer

ソリューション:シリアル化はDesignerCategoryAttribute

  • Newtonsoft.json

ソリューション以外の問題を属性削除:DesignerCategoryAttribute

を削除します。

これで、xsd.exeで生成されたクラスをコンパイルし、ネットコアで使用することができます

1

ありactualyない方法はありませんが、あなたはthisを見れば、それは将来のネットコアリリース(.NETのコアの部分ですQ2 2017の1.2リリース)。

詳細については、discussと特にこのpointを参照してください。

+0

OK、Q2 2017 xsdサポートを提供しています。 Q2 2017以上の日付はありますか? – joakimja

関連する問題