Skip to content

Commit

Permalink
Merge branch 'main' into merge-tdsenums
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Pham committed Apr 5, 2022
2 parents 1a503a5 + 4db3f97 commit 1d4a9ca
Show file tree
Hide file tree
Showing 91 changed files with 4,215 additions and 4,223 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Preview Release 5.0.0-preview1.22069.1] - 2022-03-09

### Added

- Added SqlDataSourceEnumerator. [#1430](https://github.com/dotnet/SqlClient/pull/1430)
- Added new attestation protocol `None` option to forgo enclave attestation when using VBS enclaves. [#1425](https://github.com/dotnet/SqlClient/pull/1425) and [#1419](https://github.com/dotnet/SqlClient/pull/1419)
- Added a new AppContext switch to suppress insecure TLS warnings. [#1457](https://github.com/dotnet/SqlClient/pull/1457)

### Fixed

- Fixed all documentation paths to Unix format path. [#1442](https://github.com/dotnet/SqlClient/pull/1442)
- Fixed thread safety issue for `GetEnclaveProvider` by converting dictionary to concurrent dictionary. [#1451](https://github.com/dotnet/SqlClient/pull/1451)

### Changed
- Updated `Microsoft.Data.SqlClient.SNI` (.NET Framework dependency) and `Microsoft.Data.SqlClient.SNI.runtime` (.NET Core/Standard dependency) version to `v5.0.0-preview1.22062.1`. [#1537](https://github.com/dotnet/SqlClient/pull/1537)
- Modernized style in ValueUtilSmi. [#1351](https://github.com/dotnet/SqlClient/pull/1351)
- Changed SQL server codenames to version names. [#1439](https://github.com/dotnet/SqlClient/pull/1439)
- Prevented subtype generation in project files. [#1452](https://github.com/dotnet/SqlClient/pull/1452)
- Changed `Array.Copy` to `Buffer.BlockCopy` for byte arrays. [#1366](https://github.com/dotnet/SqlClient/pull/1366)
- Changed files in csproj to be alphabetically sorted in netfx and netcore. [#1364](https://github.com/dotnet/SqlClient/pull/1364)
- Sqlstream, SqlInternalTransaction and MetaDataUtilsSmi are moved to shared folder. [#1337](https://github.com/dotnet/SqlClient/pull/1337), [#1346](https://github.com/dotnet/SqlClient/pull/1346) and [#1339](https://github.com/dotnet/SqlClient/pull/1339)
- Various code improvements: [#1197](https://github.com/dotnet/SqlClient/pull/1197), [#1313](https://github.com/dotnet/SqlClient/pull/1313),[#1330](https://github.com/dotnet/SqlClient/pull/1330),[#1366](https://github.com/dotnet/SqlClient/pull/1366), [#1435](https://github.com/dotnet/SqlClient/pull/1435),[#1478](https://github.com/dotnet/SqlClient/pull/1478)

## [Stable release 4.1.0] - 2022-01-31

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.IO;
using Microsoft.SqlServer.Server;

namespace test
{
public class Class1 : IBinarySerialize
{
[STAThread]
static void Main(string[] args)
{
string fileName = "info.dat";
Class1 temp = new Class1();

FileStream fs = new FileStream(fileName, FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);

temp.Write(w);

w.Close();
fs.Close();

fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);

temp.Read(r);

Console.WriteLine("String value: " + temp.StringValue);
Console.WriteLine("Double value: " + temp.DoubleValue);

r.Close();
fs.Close();
}

public string StringValue;
public double DoubleValue;

//<Snippet1>
// The binary layout is as follows:
// Bytes 0 - 19: string text, padded to the right with null characters
// Bytes 20+: Double value

// using Microsoft.SqlServer.Server;
public void Read(System.IO.BinaryReader r)
{

int maxStringSize = 20;
char[] chars;
int stringEnd;
string stringValue;
double doubleValue;

// Read the characters from the binary stream.
chars = r.ReadChars(maxStringSize);

// Find the start of the null character padding.
stringEnd = Array.IndexOf(chars, '\0');

if (stringEnd == 0)
{
stringValue = null;
return;
}

// Build the string from the array of characters.
stringValue = new String(chars, 0, stringEnd);

// Read the double value from the binary stream.
doubleValue = r.ReadDouble();

// Set the object's properties equal to the values.
this.StringValue = stringValue;
this.DoubleValue = doubleValue;
}
//</Snippet1>

//<Snippet2>
// The binary layout is as follows:
// Bytes 0 - 19: string text, padded to the right with null characters
// Bytes 20+: Double value

// using Microsoft.SqlServer.Server;
public void Write(System.IO.BinaryWriter w)
{
int maxStringSize = 20;
string stringValue = "The value of PI: ";
string paddedString;
double value = 3.14159;

// Pad the string from the right with null characters.
paddedString = stringValue.PadRight(maxStringSize, '\0');

// Write the string value one byte at a time.
for (int i = 0; i < paddedString.Length; i++)
{
w.Write(paddedString[i]);
}

// Write the double value.
w.Write(value);
}
//</Snippet2>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.IO;
using System.Collections;
using Microsoft.SqlServer.Server;

public class Class1
{

//<Snippet1>
[SqlFunctionAttribute(FillRowMethodName = "FillFileRow")]
public static IEnumerable GetFileDetails(string directoryPath)
{
try
{
DirectoryInfo di = new DirectoryInfo(directoryPath);
return di.GetFiles();
}
catch (DirectoryNotFoundException dnf)
{
return new string[1] { dnf.ToString() };
}
}
//</Snippet1>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//<Snippet1>
using System;
using System.IO;
using Microsoft.SqlServer.Server;

[Serializable]
[SqlUserDefinedAggregate(Microsoft.SqlServer.Server.Format.UserDefined,
IsInvariantToNulls = true,
IsInvariantToDuplicates = false,
IsInvariantToOrder = false,
MaxByteSize = 8000)
]
public class Concatenate : Microsoft.SqlServer.Server.IBinarySerialize
{
public void Read(BinaryReader r)
{
}

public void Write(BinaryWriter w)
{
}
}
//</Snippet1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text;

// <Snippet1>
[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.Native,
IsByteOrdered=true,
Name="Point",ValidationMethodName = "ValidatePoint")]
public struct Point : INullable
{
//</Snippet1>
private bool is_Null;
private int _x;
private int _y;

public bool IsNull
{
get
{
return (is_Null);
}
}

public static Point Null
{
get
{
Point pt = new Point();
pt.is_Null = true;
return pt;
}
}

// Use StringBuilder to provide string representation of UDT.
public override string ToString()
{
// Since InvokeIfReceiverIsNull defaults to 'true'
// this test is unnecessary if Point is only being called
// from SQL.
if (this.IsNull)
{
return "NULL";
}
else
{
StringBuilder builder = new StringBuilder();
builder.Append(_x);
builder.Append(",");
builder.Append(_y);
return builder.ToString();
}
}

[SqlMethod(OnNullCall = false)]
public static Point Parse(SqlString s)
{
// With OnNullCall=false, this check is unnecessary if
// Point only called from SQL.
if (s.IsNull)
return Null;

// Parse input string to separate out points.
Point pt = new Point();
string[] xy = s.Value.Split(",".ToCharArray());
pt.X = int.Parse(xy[0]);
pt.Y = int.Parse(xy[1]);

// Call ValidatePoint to enforce validation
// for string conversions.
if (!pt.ValidatePoint())
throw new ArgumentException("Invalid XY coordinate values.");
return pt;
}

// X and Y coordinates exposed as properties.
public int X
{
get
{
return this._x;
}
// Call ValidatePoint to ensure valid range of Point values.
set
{
int temp = _x;
_x = value;
if (!ValidatePoint())
{
_x = temp;
throw new ArgumentException("Invalid X coordinate value.");
}
}
}

public int Y
{
get
{
return this._y;
}
set
{
int temp = _y;
_y = value;
if (!ValidatePoint())
{
_y = temp;
throw new ArgumentException("Invalid Y coordinate value.");
}
}
}

// Validation method to enforce valid X and Y values.
private bool ValidatePoint()
{
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections;
//-----------------------------------------------------------------------------
//<Snippet4>
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class UserDefinedFunctions
{
public const double SALES_TAX = .086;

[SqlFunction()]
public static SqlDouble addTax(SqlDouble originalAmount)
{
SqlDouble taxAmount = originalAmount * SALES_TAX;

return originalAmount + taxAmount;
}
}
//</Snippet4>

//-----------------------------------------------------------------------------
//<Snippet10>
public partial class UserDefinedFunctions
{
[SqlFunction(Name="sp_scalarFunc")]
public static SqlString SampleScalarFunction(SqlString s)
{
//...
return "";
}
}
//</Snippet10>

//-----------------------------------------------------------------------------
//<Snippet11>
public partial class UserDefinedFunctions
{
[SqlFunction(Name="sp_tableFunc", TableDefinition="letter nchar(1)")]
public static IEnumerable SampleTableFunction(SqlString s)
{
//...
return new ArrayList(new char[3] {'a', 'b', 'c'});
}
}
//</Snippet11>
Loading

0 comments on commit 1d4a9ca

Please sign in to comment.