Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This test:
```cs
await Verify(connection);
```
<sup><a href='/src/Tests/Tests.cs#L316-L320' title='Snippet source file'>snippet source</a> | <a href='#snippet-SqlServerSchema' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L317-L321' title='Snippet source file'>snippet source</a> | <a href='#snippet-SqlServerSchema' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Will result in the following verified file:
Expand All @@ -69,7 +69,7 @@ await Verify(connection)
// include only tables and views
.SchemaIncludes(DbObjects.Tables | DbObjects.Views);
```
<sup><a href='/src/Tests/Tests.cs#L682-L688' title='Snippet source file'>snippet source</a> | <a href='#snippet-SchemaInclude' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L683-L689' title='Snippet source file'>snippet source</a> | <a href='#snippet-SchemaInclude' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Available values:
Expand Down Expand Up @@ -107,7 +107,7 @@ await Verify(connection)
_ => _ is TableViewBase ||
_.Name == "MyTrigger");
```
<sup><a href='/src/Tests/Tests.cs#L707-L715' title='Snippet source file'>snippet source</a> | <a href='#snippet-SchemaFilter' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L708-L716' title='Snippet source file'>snippet source</a> | <a href='#snippet-SchemaFilter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -129,7 +129,7 @@ command.CommandText = "select Value from MyTable";
var value = await command.ExecuteScalarAsync();
await Verify(value!);
```
<sup><a href='/src/Tests/Tests.cs#L491-L501' title='Snippet source file'>snippet source</a> | <a href='#snippet-Recording' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L492-L502' title='Snippet source file'>snippet source</a> | <a href='#snippet-Recording' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Will result in the following verified file:
Expand Down Expand Up @@ -184,7 +184,7 @@ await Verify(
sqlEntries = entries
});
```
<sup><a href='/src/Tests/Tests.cs#L568-L598' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSpecific' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L569-L599' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSpecific' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -212,7 +212,7 @@ var sqlErrorsViaType = entries
.Select(_ => _.Data)
.OfType<ErrorEntry>();
```
<sup><a href='/src/Tests/Tests.cs#L624-L643' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingReadingResults' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Tests.cs#L625-L644' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingReadingResults' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;CS8632;NU1608;NU1109</NoWarn>
<Version>12.1.0</Version>
<Version>12.1.1</Version>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>SqlServer, Verify</PackageTags>
Expand Down
7 changes: 4 additions & 3 deletions src/Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ static Tests() =>
"VerifySqlServer",
connection =>
{
var serverConnection = new ServerConnection();
SqlScriptBuilder.SqlConnectionObjectField.SetValue(serverConnection, connection);
serverConnection.NonPooledConnection = true;
var serverConnection = new ServerConnection
{
ConnectionString = connection.ConnectionString,
};
var server = new Server(serverConnection);
server.ConnectionContext.ExecuteNonQuery(
"""
Expand Down
16 changes: 0 additions & 16 deletions src/Verify.SqlServer/SchemaValidation/SqlScriptBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
class SqlScriptBuilder(SchemaSettings settings)
{
// TODO: when Microsoft.Data.SqlClient 7.0.1 adds TypeForwardedTo for SqlAuthenticationMethod,
// revert to using new ServerConnection(SqlConnection) and remove this reflection workaround.
//
// SMO 181.15.0 ServerConnection(SqlConnection) constructor calls InitFromSqlConnection
// which references SqlAuthenticationMethod — a type moved from Microsoft.Data.SqlClient
// to Microsoft.Data.SqlClient.Extensions.Abstractions in SqlClient 7.0. The CLR can't
// resolve the type in the original assembly, causing a TypeLoadException.
//
// Workaround: construct ServerConnection() with default constructor (no InitFromSqlConnection),
// then set the internal m_SqlConnectionObject field via reflection to reuse the open connection.
// SMO detects the connection is already open and uses it directly.
internal static readonly FieldInfo SqlConnectionObjectField =
typeof(ConnectionManager).GetField("m_SqlConnectionObject", BindingFlags.NonPublic | BindingFlags.Instance) ??
throw new("Could not find field m_SqlConnectionObject on ConnectionManager. The SMO internals may have changed.");

static Dictionary<string, string> tableSettingsToScrubLookup;

static SqlScriptBuilder()
Expand Down Expand Up @@ -50,7 +35,6 @@ public string BuildContent(SqlConnection connection)
};
try
{
SqlConnectionObjectField.SetValue(serverConnection, connection);
var server = new Server(serverConnection);
return BuildContent(server, builder);
}
Expand Down
Loading