回答編集履歴
1
理由究明
answer
CHANGED
|
@@ -23,12 +23,47 @@
|
|
|
23
23
|
|
|
24
24
|
確かに全然情報がないですね(`dynamic`でやってる人が珍しいのか?
|
|
25
25
|
|
|
26
|
-
`IDynamicMetaObjectProvider`と`TypeDescriptionProvider`両方適用してしまい、2重になってしまうのかもしれません(特に検証したわけではないが^^;
|
|
26
|
+
~~`IDynamicMetaObjectProvider`と`TypeDescriptionProvider`両方適用してしまい、2重になってしまうのかもしれません(特に検証したわけではないが^^;~~
|
|
27
|
-
[support the descriptor (component-model) API by mgravell · Pull Request #1216 · DapperLib/Dapper](https://github.com/DapperLib/Dapper/pull/1216)
|
|
27
|
+
~~[support the descriptor (component-model) API by mgravell · Pull Request #1216 · DapperLib/Dapper](https://github.com/DapperLib/Dapper/pull/1216)~~
|
|
28
28
|
|
|
29
|
-
どちらかを簡単につぶせればいいんですが思いつきませんでした...
|
|
29
|
+
~~どちらかを簡単につぶせればいいんですが思いつきませんでした...~~
|
|
30
30
|
|
|
31
|
+
`GetTypeDescriptor`と`GetExtendedTypeDescriptor`で、同じものを返しているのが原因でした。
|
|
32
|
+
[Dapper/Dapper/SqlMapper.DapperRow.Descriptor.cs#L14 · DapperLib/Dapper](https://github.com/DapperLib/Dapper/blob/00b1023f292c436eb9830b3383fde68e177a13bf/Dapper/SqlMapper.DapperRow.Descriptor.cs#L14)
|
|
31
33
|
|
|
34
|
+
[TypeDescriptionProvider.GetExtendedTypeDescriptor(Object) メソッド (System.ComponentModel) | Microsoft Learn](https://learn.microsoft.com/ja-jp/dotnet/api/system.componentmodel.typedescriptionprovider.getextendedtypedescriptor)
|
|
35
|
+
|
|
36
|
+
`TypeDescriptionProvider`を上書きすることも可能ですがあまりに胡散臭いですね^^;
|
|
37
|
+
```cs
|
|
38
|
+
public partial class MainWindow : Window
|
|
39
|
+
{
|
|
40
|
+
class DapperRowTypeDescriptionProvider : TypeDescriptionProvider
|
|
41
|
+
{
|
|
42
|
+
public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
|
|
43
|
+
{
|
|
44
|
+
var assembly = Assembly.GetAssembly(typeof(SqlMapper));
|
|
45
|
+
var type = assembly.GetType("Dapper.SqlMapper+DapperRow+DapperRowTypeDescriptor");
|
|
46
|
+
return (ICustomTypeDescriptor)Activator.CreateInstance(type, instance);
|
|
47
|
+
}
|
|
48
|
+
// これがあると2重が再現(どちらを生かすべきかはよくわからんが)
|
|
49
|
+
//public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
|
|
50
|
+
// => GetExtendedTypeDescriptor(instance);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public MainWindow()
|
|
54
|
+
{
|
|
55
|
+
InitializeComponent();
|
|
56
|
+
|
|
57
|
+
var assembly = Assembly.GetAssembly(typeof(SqlMapper));
|
|
58
|
+
var type = assembly.GetType("Dapper.SqlMapper+DapperRow");
|
|
59
|
+
TypeDescriptor.AddProvider(new DapperRowTypeDescriptionProvider(), type);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
[TypeDescriptor.AddProvider メソッド (System.ComponentModel) | Microsoft Learn](https://learn.microsoft.com/ja-jp/dotnet/api/system.componentmodel.typedescriptor.addprovider)
|
|
64
|
+
|
|
65
|
+
個人的には間違っていると思うので、Issueを上げれば修正されるとは思います(が、私は使わないのでやる気はないです^^;
|
|
66
|
+
|
|
32
67
|
> 「CS0206 参照を返さないプロパティまたはインデクサーを out 値または ref 値として使用することはできません」
|
|
33
68
|
> とエラーが表示される
|
|
34
69
|
|