[System.Data] Remove some win32-specific p/invokes for the mobile profile
authorSebastien Pouliot <sebastien@xamarin.com>
Sat, 21 Nov 2015 02:33:49 +0000 (21:33 -0500)
committerSebastien Pouliot <sebastien@xamarin.com>
Sat, 21 Nov 2015 02:33:49 +0000 (21:33 -0500)
This reduce the size of System.dll and also removes some Win32 specific
p/invokes.

They cause native linking issues for tvOS as Xcode 7.1 does not allow
`-u` in bitcode-enabled builds so we have to call directly the symbols
and it must exists at (native) link time.

**Incomplete** (some remains) but enough so we can run LinkSDK and
System.Data unit tests apps (the managed linker can remove the rest)

mcs/class/System.Data/MobileStubs.cs [new file with mode: 0644]
mcs/class/System.Data/mobile_referencesource.sources

diff --git a/mcs/class/System.Data/MobileStubs.cs b/mcs/class/System.Data/MobileStubs.cs
new file mode 100644 (file)
index 0000000..10a235e
--- /dev/null
@@ -0,0 +1,94 @@
+// help building System.Data without win32-specific p/invokes
+
+using System;
+using System.Diagnostics;
+
+internal static partial class Bid {
+    internal enum ApiGroup : uint {
+               Pooling     = 0x00001000,
+               Correlation = 0x00040000,
+       }
+       
+    internal static bool AdvancedOn {
+        get { return false; }
+    }
+
+    internal static bool IsOn (ApiGroup flag)
+       {
+        return false;
+    }
+
+       [Conditional ("BID")]
+       internal static void Trace (params object[] a)
+       {
+       }
+
+       [Conditional ("BID")]
+       internal static void PoolerTrace (params object[] a)
+       {
+       }
+
+       // out method can't be conditional
+       internal static void ScopeEnter (out IntPtr p, params object[] a)
+       {
+               p = IntPtr.Zero;
+       }
+       
+       [Conditional ("BID")]
+       internal static void ScopeLeave (ref IntPtr a)
+       {
+       }
+       
+       // out method can't be conditional
+       internal static void PoolerScopeEnter (out IntPtr p, string a, System.Int32 b)
+       {
+               p = IntPtr.Zero;
+       }
+}
+
+[ConditionalAttribute ("CODE_ANALYSIS")]
+[AttributeUsage (AttributeTargets.Method)]
+internal sealed class BidMethodAttribute : Attribute {
+}
+
+[ConditionalAttribute ("CODE_ANALYSIS")]
+[AttributeUsage (AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple=true)]
+internal sealed class BidArgumentTypeAttribute : Attribute {
+       internal BidArgumentTypeAttribute (Type bidArgumentType)
+       {
+       }
+}
+
+namespace System.Data.Common {
+
+       internal static class UnsafeNativeMethods {
+               
+               // note: likely unreachable code - as this never worked on mono
+               internal static int lstrlenW (IntPtr p)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               static internal int CreateWellKnownSid (int sidType, byte[] domainSid, byte[] resultSid, ref uint resultSidLength )
+               {
+                       return -1;
+               }
+               
+               static internal bool CheckTokenMembership (IntPtr tokenHandle, byte[] sidToCheck, out bool isMember)
+               {
+                       isMember = false;
+                       return false;
+               }
+               
+               static internal bool GetTokenInformation (IntPtr tokenHandle, uint token_class, IntPtr tokenStruct, uint tokenInformationLength, ref uint tokenString)
+               {
+                       return false;
+               }
+               
+               static internal bool ConvertSidToStringSidW (IntPtr sid, out IntPtr stringSid)
+               {
+                       stringSid = IntPtr.Zero;
+                       return false;
+               }
+       }
+}
index b4d03c4acffdc346505876175bd609ec47bf44d2..7dcb976cd391fd405eac966586b8c188adbd63fc 100644 (file)
@@ -1,4 +1,4 @@
-../../../external/referencesource/System.Data/bid/inc/cs/bidPrivateBase.cs
+MobileStubs.cs
 
 ../../../external/referencesource/System.Data/Microsoft/SqlServer/Server/SqlTriggerContext.cs
 
 ../../../external/referencesource/System.Data/System/Data/Common/SQLTypes/SqlXmlStorage.cs
 ../../../external/referencesource/System.Data/System/Data/Common/StringStorage.cs
 ../../../external/referencesource/System.Data/System/Data/Common/SupportedJoinOperators.cs
-../../../external/referencesource/System.Data/System/Data/Common/System.Data_BID.cs
 ../../../external/referencesource/System.Data/System/Data/Common/TimeSpanStorage.cs
 ../../../external/referencesource/System.Data/System/Data/Common/UInt16Storage.cs
 ../../../external/referencesource/System.Data/System/Data/Common/UInt32Storage.cs
 ../../../external/referencesource/System.Data/System/Data/Common/UInt64Storage.cs
-../../../external/referencesource/System.Data/System/Data/Common/UnsafeNativeMethods.cs
 ../../../external/referencesource/System.Data/System/Data/ConflictOptions.cs
 ../../../external/referencesource/System.Data/System/Data/ConnectionState.cs
 ../../../external/referencesource/System.Data/System/Data/ConstraintCollection.cs