System.Data.SQLite
Check-in [940f8b3976]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add ProviderFlags configuration property and associated handling to the design-time components installer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | designOptions
Files: files | file ages | folders
SHA1: 940f8b3976c0ca829fbb2d3077b82e2a7915e459
User & Date: mistachkin 2014-08-02 03:57:33
Context
2014-08-02
05:02
Fix missing call to SQLiteOptions.GetProviderName. check-in: f294bad7b4 user: mistachkin tags: designOptions
03:57
Add ProviderFlags configuration property and associated handling to the design-time components installer. check-in: 940f8b3976 user: mistachkin tags: designOptions
03:27
For the design-time components installer, remove ConfigInvariantName as a Package class property. check-in: fad33d0e23 user: mistachkin tags: designOptions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tools/install/Installer.cs.

    93     93   
    94     94       ///////////////////////////////////////////////////////////////////////////
    95     95   
    96     96       #region Public Enumerations
    97     97       [Flags()]
    98     98       public enum InstallFlags
    99     99       {
   100         -        #region Normal Flags
          100  +        #region Normal Values
   101    101           None = 0x0,
   102    102           GlobalAssemblyCache = 0x1,
   103    103           AssemblyFolders = 0x2,
   104    104           DbProviderFactory = 0x4,
   105    105           VsPackage = 0x8,
   106    106           VsPackageGlobalAssemblyCache = 0x10,
   107    107           VsDataSource = 0x20,
   108    108           VsDataProvider = 0x40,
   109    109           VsDevEnvSetup = 0x80,
   110    110           #endregion
   111    111   
   112    112           ///////////////////////////////////////////////////////////////////////
   113    113   
   114         -        #region Composite Flags
          114  +        #region Composite Values
   115    115           Framework = GlobalAssemblyCache | AssemblyFolders |
   116    116                       DbProviderFactory,
   117    117   
   118    118           ///////////////////////////////////////////////////////////////////////
   119    119   
   120    120           Vs = VsPackage | VsPackageGlobalAssemblyCache | VsDataSource |
   121    121                VsDataProvider | VsDevEnvSetup,
................................................................................
   128    128   
   129    129           AllExceptGlobalAssemblyCache = All & ~(GlobalAssemblyCache |
   130    130                                          VsPackageGlobalAssemblyCache),
   131    131           #endregion
   132    132   
   133    133           ///////////////////////////////////////////////////////////////////////
   134    134   
          135  +        #region Suggested Default Values
   135    136           Default = All
          137  +        #endregion
          138  +    }
          139  +
          140  +    ///////////////////////////////////////////////////////////////////////////
          141  +
          142  +    [Flags()]
          143  +    public enum ProviderFlags
          144  +    {
          145  +        #region Normal Values
          146  +        None = 0x0,
          147  +        SystemEf6MustBeGlobal = 0x1,
          148  +        DidLinqWarning = 0x2,
          149  +        DidEf6Warning = 0x4,
          150  +        ForceLinqEnabled = 0x8,
          151  +        ForceLinqDisabled = 0x10,
          152  +        ForceEf6Enabled = 0x20,
          153  +        ForceEf6Disabled = 0x40,
          154  +        #endregion
          155  +
          156  +        ///////////////////////////////////////////////////////////////////////
          157  +
          158  +        #region Suggested Default Values
          159  +        Default = None
          160  +        #endregion
   136    161       }
   137    162   
   138    163       ///////////////////////////////////////////////////////////////////////////
   139    164   
   140    165       [Flags()]
   141    166       public enum TracePriority
   142    167       {
          168  +        #region Normal Values
   143    169           None = 0x0,
   144    170           Lowest = 0x1,
   145    171           Lower = 0x2,
   146    172           Low = 0x4,
   147    173           MediumLow = 0x8,
   148    174           Medium = 0x10,
   149    175           MediumHigh = 0x20,
   150    176           High = 0x40,
   151    177           Higher = 0x80,
   152    178           Highest = 0x100,
          179  +        #endregion
          180  +
          181  +        ///////////////////////////////////////////////////////////////////////
          182  +
          183  +        #region Suggested Default Flags
   153    184           Default = Medium
          185  +        #endregion
   154    186       }
   155    187       #endregion
   156    188   
   157    189       ///////////////////////////////////////////////////////////////////////////
   158    190   
   159    191       #region Installer Class
   160    192   #if NET_40 || NET_45 || NET_451
................................................................................
  1974   2006                   string designerFileName,
  1975   2007                   string registryVersion,
  1976   2008                   string configVersion,
  1977   2009                   string vsVersionSuffix,
  1978   2010                   string debugFormat,
  1979   2011                   string traceFormat,
  1980   2012                   InstallFlags installFlags,
         2013  +                ProviderFlags providerFlags,
  1981   2014                   TracePriority debugPriority,
  1982   2015                   TracePriority tracePriority,
  1983   2016                   bool perUser,
  1984   2017                   bool install,
  1985   2018                   bool wow64,
  1986   2019                   bool noRuntimeVersion,
  1987   2020                   bool noDesktop,
................................................................................
  2015   2048                   this.designerFileName = designerFileName;
  2016   2049                   this.registryVersion = registryVersion;
  2017   2050                   this.configVersion = configVersion;
  2018   2051                   this.vsVersionSuffix = vsVersionSuffix;
  2019   2052                   this.debugFormat = debugFormat;
  2020   2053                   this.traceFormat = traceFormat;
  2021   2054                   this.installFlags = installFlags;
         2055  +                this.providerFlags = providerFlags;
  2022   2056                   this.debugPriority = debugPriority;
  2023   2057                   this.tracePriority = tracePriority;
  2024   2058                   this.perUser = perUser;
  2025   2059                   this.install = install;
  2026   2060                   this.wow64 = wow64;
  2027   2061                   this.noRuntimeVersion = noRuntimeVersion;
  2028   2062                   this.noDesktop = noDesktop;
................................................................................
  2209   2243                   TraceOps.DebugAndTrace(TracePriority.Highest,
  2210   2244                       debugCallback, traceCallback,
  2211   2245                       "Entity Framework 6 assembly was not resolved.",
  2212   2246                       traceCategory);
  2213   2247   
  2214   2248                   return false;
  2215   2249               }
         2250  +
         2251  +            ///////////////////////////////////////////////////////////////////
         2252  +
         2253  +            private static bool IsSystemEf6AssemblyGlobal()
         2254  +            {
         2255  +                if (systemEf6Assembly == null)
         2256  +                    return false;
         2257  +
         2258  +                return systemEf6Assembly.GlobalAssemblyCache;
         2259  +            }
  2216   2260               #endregion
  2217   2261   
  2218   2262               ///////////////////////////////////////////////////////////////////
  2219   2263   
  2220   2264               #region Public Static Methods
  2221   2265               public static void BreakIntoDebugger()
  2222   2266               {
  2223   2267                   Console.WriteLine(
  2224         -                    "Attach a debugger to process {0} and press any key to " +
  2225         -                    "continue.", (thisProcess != null) ?
         2268  +                    "Attach a debugger to process {0} and press " +
         2269  +                    "any key to continue.", (thisProcess != null) ?
  2226   2270                       thisProcess.Id.ToString() : "<unknown>");
  2227   2271   
  2228   2272                   try
  2229   2273                   {
  2230   2274                       Console.ReadKey(true); /* throw */
  2231   2275                   }
  2232   2276                   catch (InvalidOperationException) // Console.ReadKey
................................................................................
  2251   2295                       ref directory, ref coreFileName, ref linqFileName,
  2252   2296                       ref ef6FileName, ref designerFileName);
  2253   2297   
  2254   2298                   return new Configuration(
  2255   2299                       thisAssembly, null, directory, coreFileName, linqFileName,
  2256   2300                       ef6FileName, designerFileName, null, null, null,
  2257   2301                       TraceOps.DebugFormat, TraceOps.TraceFormat,
  2258         -                    InstallFlags.Default, TracePriority.Default,
  2259         -                    TracePriority.Default, false, true, false, false, false,
         2302  +                    InstallFlags.Default, ProviderFlags.Default,
         2303  +                    TracePriority.Default, TracePriority.Default, false, true,
         2304  +                    false, false, false, false, false, false, false, false,
  2260   2305                       false, false, false, false, false, false, false, false,
  2261         -                    false, false, false, false, false, false, true, true,
  2262         -                    false, false, false);
         2306  +                    false, true, true, false, false, false);
  2263   2307               }
  2264   2308   
  2265   2309               ///////////////////////////////////////////////////////////////////
  2266   2310   
  2267   2311               [MethodImpl(MethodImplOptions.NoInlining)]
  2268   2312               public static bool FromArgs(
  2269   2313                   string[] args,
................................................................................
  2920   2964                                       return false;
  2921   2965   
  2922   2966                                   continue;
  2923   2967                               }
  2924   2968   
  2925   2969                               configuration.perUser = (bool)value;
  2926   2970                           }
         2971  +                        else if (MatchOption(newArg, "providerFlags"))
         2972  +                        {
         2973  +                            object value = ParseEnum(
         2974  +                                typeof(ProviderFlags), text, true);
         2975  +
         2976  +                            if (value == null)
         2977  +                            {
         2978  +                                error = TraceOps.DebugAndTrace(
         2979  +                                    TracePriority.Lowest, debugCallback,
         2980  +                                    traceCallback, String.Format(
         2981  +                                    "Invalid provider flags value: {0}",
         2982  +                                    ForDisplay(text)), traceCategory);
         2983  +
         2984  +                                if (strict)
         2985  +                                    return false;
         2986  +
         2987  +                                continue;
         2988  +                            }
         2989  +
         2990  +                            configuration.providerFlags = (ProviderFlags)value;
         2991  +                        }
  2927   2992                           else if (MatchOption(newArg, "registryVersion"))
  2928   2993                           {
  2929   2994                               configuration.registryVersion = text;
  2930   2995                           }
  2931   2996                           else if (MatchOption(newArg, "strict"))
  2932   2997                           {
  2933   2998                               bool? value = ParseBoolean(text);
................................................................................
  3415   3480                       return ((installFlags & hasFlags) == hasFlags);
  3416   3481                   else
  3417   3482                       return ((installFlags & hasFlags) != InstallFlags.None);
  3418   3483               }
  3419   3484   
  3420   3485               ///////////////////////////////////////////////////////////////////
  3421   3486   
         3487  +            public bool HasFlags(
         3488  +                ProviderFlags hasFlags,
         3489  +                bool all
         3490  +                )
         3491  +            {
         3492  +                if (all)
         3493  +                    return ((providerFlags & hasFlags) == hasFlags);
         3494  +                else
         3495  +                    return ((providerFlags & hasFlags) != ProviderFlags.None);
         3496  +            }
         3497  +
         3498  +            ///////////////////////////////////////////////////////////////////
         3499  +
  3422   3500               public bool IsLinqSupported()
  3423   3501               {
         3502  +                //
         3503  +                // NOTE: Check to see if the caller has forced LINQ support to
         3504  +                //       be enabled -OR- disabled, thereby bypassing the need
         3505  +                //       for "automatic detection" by this method.
         3506  +                //
         3507  +                if (HasFlags(ProviderFlags.ForceLinqEnabled, true))
         3508  +                {
         3509  +                    if (!HasFlags(ProviderFlags.DidLinqWarning, true))
         3510  +                    {
         3511  +                        TraceOps.DebugAndTrace(TracePriority.MediumHigh,
         3512  +                            debugCallback, traceCallback,
         3513  +                            "Forced to enable support for \"Linq\".",
         3514  +                            traceCategory);
         3515  +
         3516  +                        providerFlags |= ProviderFlags.DidLinqWarning;
         3517  +                    }
         3518  +
         3519  +                    return true;
         3520  +                }
         3521  +                else if (HasFlags(ProviderFlags.ForceLinqDisabled, true))
         3522  +                {
         3523  +                    if (!HasFlags(ProviderFlags.DidLinqWarning, true))
         3524  +                    {
         3525  +                        TraceOps.DebugAndTrace(TracePriority.MediumHigh,
         3526  +                            debugCallback, traceCallback,
         3527  +                            "Forced to disable support for \"Linq\".",
         3528  +                            traceCategory);
         3529  +
         3530  +                        providerFlags |= ProviderFlags.DidLinqWarning;
         3531  +                    }
         3532  +
         3533  +                    return false;
         3534  +                }
         3535  +
  3424   3536                   //
  3425   3537                   // NOTE: Return non-zero if the System.Data.SQLite.Linq
  3426   3538                   //       assembly should be processed during the install.
  3427   3539                   //       If the target is Visual Studio 2005, this must
  3428   3540                   //       return zero.
  3429   3541                   //
  3430   3542                   return !noNetFx35 || !noNetFx40 || !noNetFx45 || !noNetFx451;
  3431   3543               }
  3432   3544   
  3433   3545               ///////////////////////////////////////////////////////////////////
  3434   3546   
  3435   3547               public bool IsEf6Supported()
  3436   3548               {
         3549  +                //
         3550  +                // NOTE: Check to see if the caller has forced EF6 support to
         3551  +                //       be enabled -OR- disabled, thereby bypassing the need
         3552  +                //       for "automatic detection" by this method.
         3553  +                //
         3554  +                if (HasFlags(ProviderFlags.ForceEf6Enabled, true))
         3555  +                {
         3556  +                    if (!HasFlags(ProviderFlags.DidEf6Warning, true))
         3557  +                    {
         3558  +                        TraceOps.DebugAndTrace(TracePriority.MediumHigh,
         3559  +                            debugCallback, traceCallback,
         3560  +                            "Forced to enable support for \"Ef6\".",
         3561  +                            traceCategory);
         3562  +
         3563  +                        providerFlags |= ProviderFlags.DidEf6Warning;
         3564  +                    }
         3565  +
         3566  +                    return true;
         3567  +                }
         3568  +                else if (HasFlags(ProviderFlags.ForceEf6Disabled, true))
         3569  +                {
         3570  +                    if (!HasFlags(ProviderFlags.DidEf6Warning, true))
         3571  +                    {
         3572  +                        TraceOps.DebugAndTrace(TracePriority.MediumHigh,
         3573  +                            debugCallback, traceCallback,
         3574  +                            "Forced to disable support for \"Ef6\".",
         3575  +                            traceCategory);
         3576  +
         3577  +                        providerFlags |= ProviderFlags.DidEf6Warning;
         3578  +                    }
         3579  +
         3580  +                    return false;
         3581  +                }
         3582  +
  3437   3583                   //
  3438   3584                   // NOTE: Return non-zero if the System.Data.SQLite.EF6
  3439   3585                   //       assembly should be processed during the install.
  3440         -                //       If the target is Visual Studio 2005 or Visual
  3441         -                //       Studio 2008, this must return zero.  Also, if
  3442         -                //       the EF6 core assembly is unavailable, this must
  3443         -                //       return zero.
         3586  +                //       If the target is Visual Studio 2005 or Visual Studio
         3587  +                //       2008, this must return zero.
  3444   3588                   //
  3445   3589                   if (noNetFx40 && noNetFx45 && noNetFx451)
  3446   3590                       return false;
  3447   3591   
  3448         -                return IsSystemEf6AssemblyAvailable();
         3592  +                //
         3593  +                // NOTE: Also, if the EF6 core assembly is unavailable, this
         3594  +                //       must return zero.
         3595  +                //
         3596  +                if (!IsSystemEf6AssemblyAvailable())
         3597  +                    return false;
         3598  +
         3599  +                //
         3600  +                // NOTE: Finally, if the EF6 core assembly is not available
         3601  +                //       globally [and this is a requirement for the current
         3602  +                //       install], return zero.
         3603  +                //
         3604  +                return HasFlags(ProviderFlags.SystemEf6MustBeGlobal, true) ?
         3605  +                    IsSystemEf6AssemblyGlobal() : true;
  3449   3606               }
  3450   3607   
  3451   3608               ///////////////////////////////////////////////////////////////////
  3452   3609   
  3453   3610               public AssemblyName GetCoreAssemblyName() /* REQUIRED */
  3454   3611               {
  3455   3612                   if (coreAssemblyName == null)
................................................................................
  3584   3741                       traceCallback(String.Format(NameAndValueFormat,
  3585   3742                           "TraceFormat", ForDisplay(traceFormat)),
  3586   3743                           traceCategory);
  3587   3744   
  3588   3745                       traceCallback(String.Format(NameAndValueFormat,
  3589   3746                           "InstallFlags", ForDisplay(installFlags)),
  3590   3747                           traceCategory);
         3748  +
         3749  +                    traceCallback(String.Format(NameAndValueFormat,
         3750  +                        "ProviderFlags", ForDisplay(providerFlags)),
         3751  +                        traceCategory);
  3591   3752   
  3592   3753                       traceCallback(String.Format(NameAndValueFormat,
  3593   3754                           "DebugPriority", ForDisplay(debugPriority)),
  3594   3755                           traceCategory);
  3595   3756   
  3596   3757                       traceCallback(String.Format(NameAndValueFormat,
  3597   3758                           "TracePriority", ForDisplay(tracePriority)),
................................................................................
  3703   3864                               traceCategory);
  3704   3865   
  3705   3866                           traceCallback(String.Format(NameAndValueFormat,
  3706   3867                               "AssemblyConfiguration",
  3707   3868                               ForDisplay(GetAssemblyConfiguration(assembly))),
  3708   3869                               traceCategory);
  3709   3870                       }
         3871  +
         3872  +                    ///////////////////////////////////////////////////////////
         3873  +
         3874  +                    traceCallback(String.Format(NameAndValueFormat,
         3875  +                        "IsSystemEf6AssemblyAvailable", ForDisplay(
         3876  +                        IsSystemEf6AssemblyAvailable())),
         3877  +                        traceCategory);
         3878  +
         3879  +                    traceCallback(String.Format(NameAndValueFormat,
         3880  +                        "IsSystemEf6AssemblyGlobal", ForDisplay(
         3881  +                        IsSystemEf6AssemblyGlobal())),
         3882  +                        traceCategory);
  3710   3883   
  3711   3884                       ///////////////////////////////////////////////////////////
  3712   3885   
  3713   3886                       traceCallback(String.Format(NameAndValueFormat,
  3714   3887                           "IsLinqSupported", ForDisplay(IsLinqSupported())),
  3715   3888                           traceCategory);
  3716   3889   
................................................................................
  3874   4047   
  3875   4048               private InstallFlags installFlags;
  3876   4049               public InstallFlags InstallFlags
  3877   4050               {
  3878   4051                   get { return installFlags; }
  3879   4052                   set { installFlags = value; }
  3880   4053               }
         4054  +
         4055  +            ///////////////////////////////////////////////////////////////////
         4056  +
         4057  +            private ProviderFlags providerFlags;
         4058  +            public ProviderFlags ProviderFlags
         4059  +            {
         4060  +                get { return providerFlags; }
         4061  +                set { providerFlags = value; }
         4062  +            }
  3881   4063   
  3882   4064               ///////////////////////////////////////////////////////////////////
  3883   4065   
  3884   4066               private TracePriority debugPriority;
  3885   4067               public TracePriority DebugPriority
  3886   4068               {
  3887   4069                   get { return debugPriority; }