Uh oh!
There was an error while loading. Please reload this page.
First round of converting System.Data.OleDb to COMWrappers - #54822
Conversation
This change just remove warning from ILLink and do not make attempt to convert other COM object creation to use ComWrappers Also I have to add target net5.0-windows where ComWrappers would be used. Same concerns regarding testing as in dotnet#54636 Two calls inside OleDbDataAdapter call GetErrorInfo but do not do anything with results. That's probably mistake from previous refactoring. These parts does not touched and left as is. Need advice on that specific parts how to proceed.
ghost
commented
Jun 28, 2021
Tagging subscribers to this area: @roji, @ajcvickers Issue DetailsThis change just remove warning from ILLink and do not make attempt Also I have to add target net5.0-windows where ComWrappers would be Two calls inside OleDbDataAdapter call GetErrorInfo but do not do anything with results. That's probably mistake from previous refactoring. These parts does not touched and left as is. Need advice on that specific parts how to proceed.
|
jkotas
commented
Jun 28, 2021
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| [DllImport(Interop.Libraries.OleAut32, CharSet = CharSet.Unicode, PreserveSig = true)] | ||
| internal static extern System.Data.OleDb.OleDbHResult GetErrorInfo( | ||
| [In] int dwReserved, | ||
| [Out] out System.IntPtr ppIErrorInfo); |
There was a problem hiding this comment.
Don't use out in P/Invokes, but instead use pointers. This matches the native signatures as close as possible, and allows for the native marshalling to do less work. In this case, the native marshalling needs to pin the managed reference out IntPtr ppIErrorInfo. But it doesn't if the signature is a pointer.
| [Out]outSystem.IntPtr ppIErrorInfo); | |
| [Out]System.IntPtr* ppIErrorInfo); |
There was a problem hiding this comment.
Please also drop the [Out] attribute.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
| <Compile Include="OleDbConnection.COMWrappers.cs" /> | ||
| <Compile Include="OleDbException.COMWrappers.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'"> |
There was a problem hiding this comment.
Is this right? Don't you want the ! of the above condition on line 102?
Or maybe even just not on TargetFramework net5.0 compatible, but still on Windows:
<ItemGroupCondition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0')) and '$(TargetsWindows)' == 'true'">There was a problem hiding this comment.
This would include net461-windows which is wrong as that's facade assembly. The condition is probably missing a '$(TargetsWindows)' == 'true'.
There was a problem hiding this comment.
I guess I would use
<ItemGroupCondition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0')) and'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true'">to be symmetrical with the first ItemGroup condition above.
There was a problem hiding this comment.
@ViktorHofer and @eerhardt I made changes, but I'm not sure if this is proper way. All I can say, not it does not fails during build.
There was a problem hiding this comment.
Looks pretty good. My only comments would be to make the ItemGroup conditions in the same order, to help with readability:
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true'">
...
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', $(NetCoreAppCurrent))) and '$(TargetsWindows)' == 'true'">
...
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', $(NetCoreAppCurrent))) and '$(TargetsWindows)' == 'true'">would become
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true'">
...
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', $(NetCoreAppCurrent)))">
...
<ItemGroupCondition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetsWindows)' == 'true' and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', $(NetCoreAppCurrent)))">And then change the IsTargetFrameworkCompatible to use net5.0, since COMWrappers were introduced in net5.0. This helps with maintainability in the long term, when we update NetCoreAppCurrent to be net7.0 in the future.
| { | ||
| internal static partial class ODB | ||
| { | ||
| internal static OleDbHResult GetErrorDescription(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult hresult, out string message) |
There was a problem hiding this comment.
The code here between COMWrappers and NoCOMWrappers looks duplicated. Can it be folded back together?
| public sealed partial class OleDbConnection | ||
| { | ||
| internal static Exception? ProcessResults(OleDbHResult hresult, OleDbConnection? connection, object? src) |
There was a problem hiding this comment.
Can we share the bulk of this code, and only pull out the differences into COMWrappers vs. NoCOMWrappers files? i.e. create new private methods on the partial classes.
| namespace System.Data.OleDb | ||
| { | ||
| public sealed class OleDbException : System.Data.Common.DbException | ||
| public sealed partial class OleDbException : System.Data.Common.DbException |
There was a problem hiding this comment.
Does this need to be partial? I don't see the other side of the partial class.
| string? source = null; | ||
| OleDbHResult hr = 0; | ||
| if (null != errorInfo) |
There was a problem hiding this comment.
Why don't we need a null check here?
There was a problem hiding this comment.
There discussion about that #54822 (comment)
| namespace System.Data.OleDb | ||
| { | ||
| using SysTx = Transactions; |
kant2002
commented
Sep 17, 2021
@eerhardt can you take a look? Also do I need to pursue creation of fake OleDbProvider to test for error condition which you notice? |
eerhardt
left a comment
There was a problem hiding this comment.
This is looking really good. I just had a few final comments. After these are addressed, I won't have anymore concerns. Would also be good to get @AaronRobinsonMSFT to sign off.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| return e; | ||
| } | ||
| internal void OnInfoMessage(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode) |
There was a problem hiding this comment.
I don't see a difference in the code of OnInfoMessage between the COMWrappers file and the NoCOMWrappers file. Why do we need them split?
Uh oh!
There was an error while loading. Please reload this page.
| OleDbHResult hr = UnsafeNativeMethods.GetErrorInfo(0, &pErrorInfo); // 0 - IErrorInfo exists, 1 - no IErrorInfo | ||
| if ((OleDbHResult.S_OK == hr) && (IntPtr.Zero != pErrorInfo)) | ||
| { | ||
| UnsafeNativeMethods.IErrorInfo errorInfo = (UnsafeNativeMethods.IErrorInfo)OleDbComWrappers.Instance |
There was a problem hiding this comment.
Can we just split this line out into separate partial methods between the two? That way we don't need to duplicate this whole method?
…s.cs Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| [In] int dwReserved, | ||
| [Out, MarshalAs(UnmanagedType.Interface)] out UnsafeNativeMethods.IErrorInfo? ppIErrorInfo); |
There was a problem hiding this comment.
| [In]int dwReserved, | |
| [Out,MarshalAs(UnmanagedType.Interface)]out UnsafeNativeMethods.IErrorInfo? ppIErrorInfo); | |
| intdwReserved, | |
| [MarshalAs(UnmanagedType.Interface)]out UnsafeNativeMethods.IErrorInfo? ppIErrorInfo); |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
kant2002
commented
Sep 21, 2021
Yeah, @eerhardt your proposal to consolidate files was excellent. I remove 4 not needed files and that was great. |
eerhardt
commented
Sep 21, 2021
@lewing@radical - is this a known issue? I can't see how this change could have caused this failure in the browser wasm staging leg.
|
radical
commented
Sep 21, 2021
This failed because emsdk could not be activated: @radekdoulik the |
eerhardt
commented
Sep 21, 2021
It must have been a network issue. I ran it for the 3rd time, and it looks like it is further than it was before. I'll merge this once that leg goes green. |
This change just remove warning from ILLink and do not make attempt
to convert other COM object creation to use ComWrappers
Also I have to add target net5.0-windows where ComWrappers would be
used. Same concerns regarding testing as in
#54636
Two calls inside OleDbDataAdapter call GetErrorInfo but do not do anything with results. That's probably mistake from previous refactoring. These parts does not touched and left as is. Need advice on that specific parts how to proceed.