System.Data.SQLite
Check-in [02695316e9]
Not logged in

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

Overview
Comment:Enhance the target framework abbreviation handling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 02695316e9c4526464130c8e3b5f8f54a8dae104
User & Date: mistachkin 2019-08-01 01:25:19
Context
2019-08-01
01:30
Minor coding style cleanup. Leaf check-in: d90a4098ca user: mistachkin tags: trunk
01:25
Enhance the target framework abbreviation handling. check-in: 02695316e9 user: mistachkin tags: trunk
2019-07-27
01:48
Add SQLITE_USER_DEFINES and INTEROP_USER_DEFINES placeholders to the native project files. check-in: 7324638166 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

1516
1517
1518
1519
1520
1521
1522








1523
1524
1525
1526
1527
1528
1529
....
1612
1613
1614
1615
1616
1617
1618
1619

1620
1621
1622




















































1623
1624
1625
1626
1627
1628
1629
....
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050










2051
2052














2053


2054
2055
2056
2057
2058
2059


2060



2061
2062
2063
2064
2065
2066
2067
2068
      /// This lock is used to protect the static _SQLiteNativeModuleFileName,
      /// _SQLiteNativeModuleHandle, and processorArchitecturePlatforms fields.
      /// </summary>
      private static readonly object staticSyncRoot = new object();

      /////////////////////////////////////////////////////////////////////////
      /// <summary>








      /// This dictionary stores the mappings between processor architecture
      /// names and platform names.  These mappings are now used for two
      /// purposes.  First, they are used to determine if the assembly code
      /// base should be used instead of the location, based upon whether one
      /// or more of the named sub-directories exist within the assembly code
      /// base.  Second, they are used to assist in loading the appropriate
      /// SQLite interop assembly into the current process.
................................................................................
              return;
#endif
#endif

          lock (staticSyncRoot)
          {
              //
              // TODO: Make sure this list is updated if the supported

              //       processor architecture names and/or platform names
              //       changes.
              //




















































              if (processorArchitecturePlatforms == null)
              {
                  //
                  // NOTE: Create the map of processor architecture names
                  //       to platform names using a case-insensitive string
                  //       comparer.
                  //
................................................................................

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// Accepts a long target framework attribute value and makes it into a
      /// much shorter version, suitable for use with NuGet packages.
      /// </summary>
      /// <param name="value">
      /// The long target framework attribute value to convert.
      /// </param>
      /// <returns>
      /// The short target framework attribute value -OR- null if it cannot
      /// be determined or converted.
      /// </returns>
      private static string AbbreviateTargetFramework(
          string value
          )
      {
          if (String.IsNullOrEmpty(value))










              return value;















          value = value.Replace(".NETFramework,Version=v", "net");


          value = value.Replace(".", String.Empty);

          int index = value.IndexOf(',');

          if (index != -1)
              value = value.Substring(0, index);






          return value;
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// If necessary, replaces all supported environment variable tokens
      /// with their associated values.







>
>
>
>
>
>
>
>







 







|
>
|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







|


|
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|

|

|
|
>
>
|
>
>
>
|







1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
....
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
....
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
      /// This lock is used to protect the static _SQLiteNativeModuleFileName,
      /// _SQLiteNativeModuleHandle, and processorArchitecturePlatforms fields.
      /// </summary>
      private static readonly object staticSyncRoot = new object();

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// This dictionary stores the mappings between target framework names
      /// and their associated (NuGet) abbreviations.  These mappings are only
      /// used by the <see cref="AbbreviateTargetFramework" /> method.
      /// </summary>
      private static Dictionary<string, string> targetFrameworkAbbreviations;

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// This dictionary stores the mappings between processor architecture
      /// names and platform names.  These mappings are now used for two
      /// purposes.  First, they are used to determine if the assembly code
      /// base should be used instead of the location, based upon whether one
      /// or more of the named sub-directories exist within the assembly code
      /// base.  Second, they are used to assist in loading the appropriate
      /// SQLite interop assembly into the current process.
................................................................................
              return;
#endif
#endif

          lock (staticSyncRoot)
          {
              //
              // TODO: Make sure to keep these lists updated when the
              //       target framework names (or their abbreviations)
              //       -OR- the processor architecture names (or their
              //       platform names) change.
              //
              if (targetFrameworkAbbreviations == null)
              {
                  targetFrameworkAbbreviations =
                      new Dictionary<string, string>(
                          StringComparer.OrdinalIgnoreCase);

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v2.0", "net20");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v3.5", "net35");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.0", "net40");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.5", "net45");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.5.1", "net451");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.5.2", "net452");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.6", "net46");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.6.1", "net461");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.6.2", "net462");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.7", "net47");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.7.1", "net471");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.7.2", "net472");

                  targetFrameworkAbbreviations.Add(
                      ".NETFramework,Version=v4.8", "net48");

                  targetFrameworkAbbreviations.Add(
                      ".NETStandard,Version=v2.0", "netstandard2.0");

                  targetFrameworkAbbreviations.Add(
                      ".NETStandard,Version=v2.1", "netstandard2.1");
              }

              if (processorArchitecturePlatforms == null)
              {
                  //
                  // NOTE: Create the map of processor architecture names
                  //       to platform names using a case-insensitive string
                  //       comparer.
                  //
................................................................................

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// Accepts a long target framework attribute value and makes it into a
      /// much shorter version, suitable for use with NuGet packages.
      /// </summary>
      /// <param name="targetFramework">
      /// The long target framework attribute value to convert.
      /// </param>
      /// <returns>
      /// The short target framework attribute value -OR- null if it cannot
      /// be determined or converted.
      /// </returns>
      private static string AbbreviateTargetFramework(
          string targetFramework
          )
      {
          if (!String.IsNullOrEmpty(targetFramework))
          {
              lock (staticSyncRoot)
              {
                  string abbreviation;

                  if (targetFrameworkAbbreviations != null)
                  {
                      if (targetFrameworkAbbreviations.TryGetValue(
                              targetFramework, out abbreviation))
                      {
                          return abbreviation;
                      }
                  }

                  //
                  // HACK: *LEGACY* Fallback to the old method of
                  //       abbreviating target framework names.
                  //
                  int index = targetFramework.IndexOf(
                      ".NETFramework,Version=v");

                  if (index != -1)
                  {
                      abbreviation = targetFramework;

                      abbreviation = abbreviation.Replace(
                          ".NETFramework,Version=v", "net");

                      abbreviation = abbreviation.Replace(
                          ".", String.Empty);

                      index = abbreviation.IndexOf(',');

                      if (index != -1)
                          return abbreviation.Substring(0, index);
                      else
                          return abbreviation;
                  }
              }
          }

          return targetFramework;
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// If necessary, replaces all supported environment variable tokens
      /// with their associated values.

Changes to Tests/basic.eagle.

5429
5430
5431
5432
5433
5434
5435






























































5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
  catch {object removecallback threadStart}

  unset -nocomplain thread i count

  rename threadStart ""
} -constraints {eagle command.object SQLite System.Data.SQLite} -result \
{20000 0 0}}































































###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
  catch {object removecallback threadStart}

  unset -nocomplain thread i count

  rename threadStart ""
} -constraints {eagle command.object SQLite System.Data.SQLite} -result \
{20000 0 0}}

###############################################################################

runTest {test data-1.102 {Target Framework Abbreviations} -body {
  set targetFrameworkNames [list \
      null "" bad 1.0 2.0 3.0 X.X \
      .NETFramework,Version=v2.0 \
      .NETFramework,Version=v3.5 \
      .NETFramework,Version=v4.0 \
      .NETFramework,Version=v4.5 \
      .NETFramework,Version=v4.5.1 \
      .NETFramework,Version=v4.5.2 \
      .NETFramework,Version=v4.6 \
      .NETFramework,Version=v4.6.1 \
      .NETFramework,Version=v4.6.2 \
      .NETFramework,Version=v4.7 \
      .NETFramework,Version=v4.7.1 \
      .NETFramework,Version=v4.7.2 \
      .NETFramework,Version=v4.8 \
      .NETFramework,Version=vX.X \
      .NETStandard,Version=v2.0 \
      .NETStandard,Version=v2.1 \
      .NETStandard,Version=vX.X]

  set targetFrameworkAbbreviations [list]

  foreach targetFrameworkName $targetFrameworkNames {
    set targetFrameworkAbbreviation [object invoke -flags +NonPublic \
        System.Data.SQLite.UnsafeNativeMethods AbbreviateTargetFramework \
        $targetFrameworkName]

    lappend targetFrameworkAbbreviations $targetFrameworkAbbreviation
  }

  appendArgs ( [join $targetFrameworkAbbreviations )\n(] )
} -cleanup {
  unset -nocomplain targetFrameworkName targetFrameworkAbbreviation
  unset -nocomplain targetFrameworkNames targetFrameworkAbbreviations
} -constraints {eagle command.object System.Data.SQLite} -result {()
()
(bad)
(1.0)
(2.0)
(3.0)
(X.X)
(net20)
(net35)
(net40)
(net45)
(net451)
(net452)
(net46)
(net461)
(net462)
(net47)
(net471)
(net472)
(net48)
(netXX)
(netstandard2.0)
(netstandard2.1)
(.NETStandard,Version=vX.X)}}

###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue