Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<IsDesktopFacade>true</IsDesktopFacade>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyKey>Open</AssemblyKey>
</PropertyGroup>
</Project>

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<BuildConfigurations>
netstandard;
netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -3,11 +3,19 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{D589374B-3331-4660-8DFB-512D66F8EC63}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Data.Odbc.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Data" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -1,58 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Data.Common
{
// DbConnectionPoolKey: Base class implementation of a key to connection pool groups
// Only connection string is used as a key
internal class DbConnectionPoolKey : ICloneable
{
private string _connectionString;
internal DbConnectionPoolKey(string connectionString)
{
_connectionString = connectionString;
}
protected DbConnectionPoolKey(DbConnectionPoolKey key)
{
_connectionString = key.ConnectionString;
}
object ICloneable.Clone()
{
return new DbConnectionPoolKey(this);
}
internal virtual string ConnectionString
{
get
{
return _connectionString;
}
set
{
_connectionString = value;
}
}
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != typeof(DbConnectionPoolKey))
{
return false;
}
DbConnectionPoolKey key = obj as DbConnectionPoolKey;
return (key != null && _connectionString == key._connectionString);
}
public override int GetHashCode()
{
return _connectionString == null ? 0 : _connectionString.GetHashCode();
}
}
}

View File

@@ -1,291 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text;
namespace System.Data.Common
{
internal class MultipartIdentifier
{
private const int MaxParts = 4;
internal const int ServerIndex = 0;
internal const int CatalogIndex = 1;
internal const int SchemaIndex = 2;
internal const int TableIndex = 3;
/*
Left quote strings need to correspond 1 to 1 with the right quote strings
example: "ab" "cd", passed in for the left and the right quote
would set a or b as a starting quote character.
If a is the starting quote char then c would be the ending quote char
otherwise if b is the starting quote char then d would be the ending quote character.
*/
internal static string[] ParseMultipartIdentifier(string name, string leftQuote, string rightQuote, string property, bool ThrowOnEmptyMultipartName)
{
return ParseMultipartIdentifier(name, leftQuote, rightQuote, '.', MaxParts, true, property, ThrowOnEmptyMultipartName);
}
private enum MPIState
{
MPI_Value,
MPI_ParseNonQuote,
MPI_LookForSeparator,
MPI_LookForNextCharOrSeparator,
MPI_ParseQuote,
MPI_RightQuote,
}
/* Core function for parsing the multipart identifier string.
* parameters: name - string to parse
* leftquote: set of characters which are valid quoting characters to initiate a quote
* rightquote: set of characters which are valid to stop a quote, array index's correspond to the leftquote array.
* separator: separator to use
* limit: number of names to parse out
* removequote:to remove the quotes on the returned string
*/
private static void IncrementStringCount(string name, string[] ary, ref int position, string property)
{
++position;
int limit = ary.Length;
if (position >= limit)
{
throw ADP.InvalidMultipartNameToManyParts(property, name, limit);
}
ary[position] = string.Empty;
}
private static bool IsWhitespace(char ch)
{
return Char.IsWhiteSpace(ch);
}
internal static string[] ParseMultipartIdentifier(string name, string leftQuote, string rightQuote, char separator, int limit, bool removequotes, string property, bool ThrowOnEmptyMultipartName)
{
if (limit <= 0)
{
throw ADP.InvalidMultipartNameToManyParts(property, name, limit);
}
if (-1 != leftQuote.IndexOf(separator) || -1 != rightQuote.IndexOf(separator) || leftQuote.Length != rightQuote.Length)
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
string[] parsedNames = new string[limit]; // return string array
int stringCount = 0; // index of current string in the buffer
MPIState state = MPIState.MPI_Value; // Initialize the starting state
StringBuilder sb = new StringBuilder(name.Length); // String buffer to hold the string being currently built, init the string builder so it will never be resized
StringBuilder whitespaceSB = null; // String buffer to hold white space used when parsing nonquoted strings 'a b . c d' = 'a b' and 'c d'
char rightQuoteChar = ' '; // Right quote character to use given the left quote character found.
for (int index = 0; index < name.Length; ++index)
{
char testchar = name[index];
switch (state)
{
case MPIState.MPI_Value:
{
int quoteIndex;
if (IsWhitespace(testchar))
{ // Is White Space then skip the whitespace
continue;
}
else
if (testchar == separator)
{ // If we found a separator, no string was found, initialize the string we are parsing to Empty and the next one to Empty.
// This is NOT a redundant setting of string.Empty it solves the case where we are parsing ".foo" and we should be returning null, null, empty, foo
parsedNames[stringCount] = string.Empty;
IncrementStringCount(name, parsedNames, ref stringCount, property);
}
else
if (-1 != (quoteIndex = leftQuote.IndexOf(testchar)))
{ // If we are a left quote
rightQuoteChar = rightQuote[quoteIndex]; // record the corresponding right quote for the left quote
sb.Length = 0;
if (!removequotes)
{
sb.Append(testchar);
}
state = MPIState.MPI_ParseQuote;
}
else
if (-1 != rightQuote.IndexOf(testchar))
{ // If we shouldn't see a right quote
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
else
{
sb.Length = 0;
sb.Append(testchar);
state = MPIState.MPI_ParseNonQuote;
}
break;
}
case MPIState.MPI_ParseNonQuote:
{
if (testchar == separator)
{
parsedNames[stringCount] = sb.ToString(); // set the currently parsed string
IncrementStringCount(name, parsedNames, ref stringCount, property);
state = MPIState.MPI_Value;
}
else // Quotes are not valid inside a non-quoted name
if (-1 != rightQuote.IndexOf(testchar))
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
else
if (-1 != leftQuote.IndexOf(testchar))
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
else
if (IsWhitespace(testchar))
{ // If it is Whitespace
parsedNames[stringCount] = sb.ToString(); // Set the currently parsed string
if (null == whitespaceSB)
{
whitespaceSB = new StringBuilder();
}
whitespaceSB.Length = 0;
whitespaceSB.Append(testchar); // start to record the white space, if we are parsing a name like "foo bar" we should return "foo bar"
state = MPIState.MPI_LookForNextCharOrSeparator;
}
else
{
sb.Append(testchar);
}
break;
}
case MPIState.MPI_LookForNextCharOrSeparator:
{
if (!IsWhitespace(testchar))
{ // If it is not whitespace
if (testchar == separator)
{
IncrementStringCount(name, parsedNames, ref stringCount, property);
state = MPIState.MPI_Value;
}
else
{ // If its not a separator and not whitespace
sb.Append(whitespaceSB);
sb.Append(testchar);
parsedNames[stringCount] = sb.ToString(); // Need to set the name here in case the string ends here.
state = MPIState.MPI_ParseNonQuote;
}
}
else
{
whitespaceSB.Append(testchar);
}
break;
}
case MPIState.MPI_ParseQuote:
{
if (testchar == rightQuoteChar)
{ // if se are on a right quote see if we are escaping the right quote or ending the quoted string
if (!removequotes)
{
sb.Append(testchar);
}
state = MPIState.MPI_RightQuote;
}
else
{
sb.Append(testchar); // Append what we are currently parsing
}
break;
}
case MPIState.MPI_RightQuote:
{
if (testchar == rightQuoteChar)
{ // If the next char is a another right quote then we were escaping the right quote
sb.Append(testchar);
state = MPIState.MPI_ParseQuote;
}
else
if (testchar == separator)
{ // If its a separator then record what we've parsed
parsedNames[stringCount] = sb.ToString();
IncrementStringCount(name, parsedNames, ref stringCount, property);
state = MPIState.MPI_Value;
}
else
if (!IsWhitespace(testchar))
{ // If it is not white space we got problems
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
else
{ // It is a whitespace character so the following char should be whitespace, separator, or end of string anything else is bad
parsedNames[stringCount] = sb.ToString();
state = MPIState.MPI_LookForSeparator;
}
break;
}
case MPIState.MPI_LookForSeparator:
{
if (!IsWhitespace(testchar))
{ // If it is not whitespace
if (testchar == separator)
{ // If it is a separator
IncrementStringCount(name, parsedNames, ref stringCount, property);
state = MPIState.MPI_Value;
}
else
{ // Otherwise not a separator
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
}
break;
}
}
}
// Resolve final states after parsing the string
switch (state)
{
case MPIState.MPI_Value: // These states require no extra action
case MPIState.MPI_LookForSeparator:
case MPIState.MPI_LookForNextCharOrSeparator:
break;
case MPIState.MPI_ParseNonQuote: // Dump what ever was parsed
case MPIState.MPI_RightQuote:
parsedNames[stringCount] = sb.ToString();
break;
case MPIState.MPI_ParseQuote: // Invalid Ending States
default:
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
if (parsedNames[0] == null)
{
if (ThrowOnEmptyMultipartName)
{
throw ADP.InvalidMultipartName(property, name); // Name is entirely made up of whitespace
}
}
else
{
// Shuffle the parsed name, from left justification to right justification, i.e. [a][b][null][null] goes to [null][null][a][b]
int offset = limit - stringCount - 1;
if (offset > 0)
{
for (int x = limit - 1; x >= offset; --x)
{
parsedNames[x] = parsedNames[x - offset];
parsedNames[x - offset] = null;
}
}
}
return parsedNames;
}
}
}

View File

@@ -1,69 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.Runtime.Serialization;
namespace System.Data.Common
{
[Serializable] // MDAC 83147
internal sealed class NameValuePair
{
private readonly string _name;
private readonly string _value;
[OptionalField(VersionAdded = 2)]
private readonly int _length;
private NameValuePair _next;
internal NameValuePair(string name, string value, int length)
{
System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(name), "empty keyname");
_name = name;
_value = value;
_length = length;
}
internal int Length
{
get
{
// this property won't exist when deserialized from Everett to Whidbey
// it shouldn't matter for DbConnectionString/DbDataPermission
// which should only use Length during construction
// not deserialization or post-ctor runtime
Debug.Assert(0 < _length, "NameValuePair zero Length usage");
return _length;
}
}
internal string Name
{
get
{
return _name;
}
}
internal NameValuePair Next
{
get
{
return _next;
}
set
{
if ((null != _next) || (null == value))
{
throw ADP.InternalError(ADP.InternalErrorCode.NameValuePairNext);
}
_next = value;
}
}
internal string Value
{
get
{
return _value;
}
}
}
}

View File

@@ -4,7 +4,7 @@
namespace System
{
internal static class HResults
internal static partial class HResults
{
internal const int OdbcException = unchecked((int)0x80131937);
}

View File

@@ -276,6 +276,30 @@
<data name="ADP_InvalidMultipartNameToManyParts" xml:space="preserve">
<value>{0} '{1}', the current limit of '{2}' is insufficient.</value>
</data>
<data name="ADP_NotSupportedEnumerationValue" xml:space="preserve">
<value>The {0} enumeration value, {1}, is not supported by the {2} method.</value>
</data>
<data name="ADP_StreamClosed" xml:space="preserve">
<value>Invalid attempt to {0} when stream is closed.</value>
</data>
<data name="ADP_InvalidSourceBufferIndex" xml:space="preserve">
<value>Invalid source buffer (size of {0}) offset: {1}</value>
</data>
<data name="ADP_InvalidDestinationBufferIndex" xml:space="preserve">
<value>Invalid destination buffer (size of {0}) offset: {1}</value>
</data>
<data name="SQL_InvalidBufferSizeOrIndex" xml:space="preserve">
<value>Buffer offset '{1}' plus the bytes available '{0}' is greater than the length of the passed in buffer.</value>
</data>
<data name="SQL_InvalidDataLength" xml:space="preserve">
<value>Data length '{0}' is less than 0.</value>
</data>
<data name="ADP_InvalidSeekOrigin" xml:space="preserve">
<value>Specified SeekOrigin value is invalid.</value>
</data>
<data name="SQL_WrongType" xml:space="preserve">
<value>Expecting argument of type {1}, but received type {0}.</value>
</data>
<data name="ODBC_ODBCCommandText" xml:space="preserve">
<value>OdbcCommandBuilder.DeriveParameters failed because the OdbcCommand.CommandText property value is an invalid multipart name</value>
</data>

View File

@@ -16,12 +16,19 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="Common\System\Data\Common\AdapterUtil.cs" />
<Compile Include="$(CommonPath)\System\Data\Common\AdapterUtil.cs">
<Link>Common\System\Data\Common\AdapterUtil.cs</Link>
</Compile>
<Compile Include="Common\System\Data\Common\AdapterUtil.Odbc.cs" />
<Compile Include="Common\System\Data\Common\DbConnectionOptions.cs" />
<Compile Include="Common\System\Data\Common\DbConnectionPoolKey.cs" />
<Compile Include="$(CommonPath)\System\Data\Common\DbConnectionPoolKey.cs">
<Link>System\Data\Common\DbConnectionPoolKey.cs</Link>
</Compile>
<Compile Include="Common\System\Data\Common\DBConnectionString.cs" />
<Compile Include="Common\System\Data\Common\DbConnectionStringCommon.cs" />
<Compile Include="Common\System\Data\Common\NameValuePair.cs" />
<Compile Include="$(CommonPath)\System\Data\Common\NameValuePair.cs">
<Link>Common\System\Data\Common\NameValuePair.cs</Link>
</Compile>
<Compile Include="Common\System\Data\Common\NameValuePermission.cs" />
<Compile Include="Common\System\Data\Common\SafeNativeMethods.cs" />
<Compile Include="Common\System\Data\DataStorage.cs" />
@@ -94,7 +101,9 @@
<Link>Common\System\NotImplemented.cs</Link>
</Compile>
<Compile Include="Common\System\HResults.cs" />
<Compile Include="Common\System\Data\Common\MultipartIdentifier.cs" />
<Compile Include="$(CommonPath)\System\Data\Common\MultipartIdentifier.cs">
<Link>Common\System\Data\Common\MultipartIdentifier.cs</Link>
</Compile>
<Compile Include="Common\System\Data\Common\ReadOnlyCollection.cs" />
<Compile Include="Common\System\Data\Common\UnsafeNativeMethods.cs" />
</ItemGroup>
@@ -111,7 +120,7 @@
<Reference Include="mscorlib" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Reference Include="Microsoft.Win32.Registry" />
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Concurrent" />

View File

@@ -136,7 +136,6 @@ namespace System.Data.Odbc
// from .\public\sdk\inc\sqlext.h: and .\public\sdk\inc\sql.h
// must be public because it is serialized by OdbcException
[Serializable]
public enum RETCODE : int
{ // must be int instead of short for Everett OdbcException Serializablity.
SUCCESS = 0,

View File

@@ -13,8 +13,6 @@ namespace System.Data.Odbc
{
private OdbcErrorCollection _odbcErrors = new OdbcErrorCollection();
private ODBC32.RETCODE _retcode; // DO NOT REMOVE! only needed for serialization purposes, because Everett had it.
internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode)
{
StringBuilder builder = new StringBuilder();
@@ -37,14 +35,6 @@ namespace System.Data.Odbc
HResult = HResults.OdbcException;
}
// runtime will call even if private...
private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc)
{
_retcode = (ODBC32.RETCODE)si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE));
_odbcErrors = (OdbcErrorCollection)si.GetValue("odbcErrors", typeof(OdbcErrorCollection));
HResult = HResults.OdbcException;
}
public OdbcErrorCollection Errors
{
get
@@ -53,16 +43,8 @@ namespace System.Data.Odbc
}
}
[System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo si, StreamingContext context)
{
// MDAC 72003
if (null == si)
{
throw new ArgumentNullException("si");
}
si.AddValue("odbcRetcode", _retcode, typeof(ODBC32.RETCODE));
si.AddValue("odbcErrors", _odbcErrors, typeof(OdbcErrorCollection));
base.GetObjectData(si, context);
}