Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Jan 23, 2024
1 parent 82d6dd6 commit d4473e8
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 217 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
[![Prerelease](https://img.shields.io/nuget/vpre/dbup-sqlce?color=orange&label=prerelease)](https://www.nuget.org/packages/dbup-sqlce)

# DbUp SQL CE Support
DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been run already, and runs the change scripts that are needed to get your database up to date.

DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been
run already, and runs the change scripts that are needed to get your database up to date.

## Getting Help

To learn more about DbUp check out the [documentation](https://dbup.readthedocs.io/en/latest/)

Please only log issue related to SQL CE Support in this repo. For cross cutting issues, please use our [main issue list](https://github.com/DbUp/DbUp/issues).
Please only log issue related to SQL CE Support in this repo. For cross cutting issues, please use
our [main issue list](https://github.com/DbUp/DbUp/issues).

# Contributing

See the [readme in our main repo](https://github.com/DbUp/DbUp/blob/master/README.md) for how to get started and contribute.
See the [readme in our main repo](https://github.com/DbUp/DbUp/blob/master/README.md) for how to get started and
contribute.
16 changes: 8 additions & 8 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
###############################
# C# Coding Conventions #
###############################
Expand All @@ -78,7 +78,7 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:suggestion
# Expression-level preferences
csharp_prefer_braces = when_multiline:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
Expand Down Expand Up @@ -120,4 +120,4 @@ csharp_preserve_single_line_blocks = true
###############################
[*.vb]
# Modifier preferences
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
visual_basic_preferred_modifier_order = Partial, Default, Private, Protected, Public, Friend, NotOverridable, Overridable, MustOverride, Overloads, Overrides, MustInherit, NotInheritable, Static, Shared, Shadows, ReadOnly, WriteOnly, Dim, Const, WithEvents, Widening, Narrowing, Custom, Async:suggestion
34 changes: 17 additions & 17 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<PropertyGroup>
<Authors>https://github.com/orgs/DbUp/people</Authors>
<PackageReleaseNotes>https://github.com/DbUp/dbup-sqlce/releases</PackageReleaseNotes>
<PackageProjectUrl>https://dbup.github.io</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/dbup-sqlce/dbup-sqlce.git</RepositoryUrl>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<Authors>https://github.com/orgs/DbUp/people</Authors>
<PackageReleaseNotes>https://github.com/DbUp/dbup-sqlce/releases</PackageReleaseNotes>
<PackageProjectUrl>https://dbup.github.io</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/dbup-sqlce/dbup-sqlce.git</RepositoryUrl>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">

<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
<DebugType>embedded</DebugType>
<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
<DebugType>embedded</DebugType>

</PropertyGroup>
</PropertyGroup>

</Project>
3 changes: 1 addition & 2 deletions src/Tests/DatabaseSupportTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#if !NETCORE
using DbUp.Builder;
using DbUp.SqlCe;
using DbUp.Tests.Common;

namespace DbUp.Tests.Providers.SqlCe;
namespace DbUp.SqlCe.Tests;

public class DatabaseSupportTests : DatabaseSupportTestsBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/NoPublicApiChanges.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if !NETCORE
using DbUp.Tests.Common;

namespace DbUp.Tests.Providers.SqlCe;
namespace DbUp.SqlCe.Tests;

public class NoPublicApiChanges : NoPublicApiChangesBase
{
Expand Down
38 changes: 18 additions & 20 deletions src/Tests/SqlCeSupportTests.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
#if !NETCORE
using System;
using System.Data.SqlServerCe;
using System.IO;
using Shouldly;
using Xunit;

namespace DbUp.Tests.Support.SqlCe
namespace DbUp.SqlCe.Tests;

public class SqlCeSupportTests
{
public class SqlCeSupportTests
[Fact]
public void CanUseSqlCe4()
{
[Fact]
public void CanUseSqlCe4()
{
const string connectionString = "Data Source=test.sdf; Persist Security Info=False";
const string connectionString = "Data Source=test.sdf; Persist Security Info=False";

if (!File.Exists("test.sdf"))
{
var engine = new SqlCeEngine(connectionString);
engine.CreateDatabase();
}
if (!File.Exists("test.sdf"))
{
var engine = new SqlCeEngine(connectionString);
engine.CreateDatabase();

Check failure on line 19 in src/Tests/SqlCeSupportTests.cs

View workflow job for this annotation

GitHub Actions / Tests

DbUp.SqlCe.Tests.SqlCeSupportTests ► CanUseSqlCe4

Failed test found in: artifacts/runneradmin_fv-az980-863_2024-01-23_04_57_56.trx Error: System.Data.SqlServerCe.SqlCeException : Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8876. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
Raw output
System.Data.SqlServerCe.SqlCeException : Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8876. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
   at System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries()
   at System.Data.SqlServerCe.SqlCeEngine..ctor()
   at System.Data.SqlServerCe.SqlCeEngine..ctor(String connectionString)
   at DbUp.SqlCe.Tests.SqlCeSupportTests.CanUseSqlCe4() in D:\a\dbup-sqlce\dbup-sqlce\src\Tests\SqlCeSupportTests.cs:line 19
}

//Verify supports scripts which specify schema (To Support SqlCe and Sql with Schemas)
var upgrader = DeployChanges.To
.SqlCeDatabase(connectionString)
.WithScript("Script0001", "create table $schema$.Foo (Id int)")
.Build();
//Verify supports scripts which specify schema (To Support SqlCe and Sql with Schemas)
var upgrader = DeployChanges.To
.SqlCeDatabase(connectionString)
.WithScript("Script0001", "create table $schema$.Foo (Id int)")
.Build();

var result = upgrader.PerformUpgrade();
var result = upgrader.PerformUpgrade();

result.Successful.ShouldBe(true);
}
result.Successful.ShouldBe(true);
}
}
#endif
50 changes: 25 additions & 25 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<AssemblyName>Tests</AssemblyName>
<RootNamespace>DbUp.SqlCe.Tests</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- <ImplicitUsings>enable</ImplicitUsings> Can't use implict usings with net46 -->
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn> <!-- Purposefully leaving an old version of netcoreapp to ensure we have compatibility. This never gets published -->
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<AssemblyName>Tests</AssemblyName>
<RootNamespace>DbUp.SqlCe.Tests</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- <ImplicitUsings>enable</ImplicitUsings> Can't use implict usings with net46 -->
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn> <!-- Purposefully leaving an old version of netcoreapp to ensure we have compatibility. This never gets published -->
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\dbup-sqlce\dbup-sqlce.csproj" />
<PackageReference Include="DbUp.Tests.Common" Version="5.0.37" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\dbup-sqlce\dbup-sqlce.csproj"/>
<PackageReference Include="DbUp.Tests.Common" Version="5.0.37"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.6.6"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Compile Remove="ApprovalFiles\*.cs"/>
<None Include="ApprovalFiles\*.cs"/>
</ItemGroup>

<ItemGroup>
<Compile Remove="ApprovalFiles\*.cs" />
<None Include="ApprovalFiles\*.cs" />
</ItemGroup>

</Project>
25 changes: 16 additions & 9 deletions src/dbup-sqlce.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassWithVirtualMembersNeverInherited_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQ/@EntryIndexedValue">SQ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve">
<s:String
x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassWithVirtualMembersNeverInherited_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String
x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
<s:String
x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQ/@EntryIndexedValue">SQ</s:String>
<s:String
x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String
x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
29 changes: 14 additions & 15 deletions src/dbup-sqlce/SqlCeConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
using DbUp.Engine.Transactions;
using DbUp.Support;

namespace DbUp.SqlCe
namespace DbUp.SqlCe;

/// <summary>
/// Manages SqlCe Database Connections
/// </summary>
public class SqlCeConnectionManager : DatabaseConnectionManager
{
/// <summary>
/// Manages SqlCe Database Connections
/// </summary>
public class SqlCeConnectionManager : DatabaseConnectionManager
/// <param name="connectionString"></param>
public SqlCeConnectionManager(string connectionString) : base(l => new SqlCeConnection(connectionString))
{
/// <summary>
/// Manages SqlCe Database Connections
/// </summary>
/// <param name="connectionString"></param>
public SqlCeConnectionManager(string connectionString) : base(l => new SqlCeConnection(connectionString))
{
}
}

public override IEnumerable<string> SplitScriptIntoCommands(string scriptContents)
{
var commandSplitter = new SqlCommandSplitter();
var scriptStatements = commandSplitter.SplitScriptIntoCommands(scriptContents);
return scriptStatements;
}
public override IEnumerable<string> SplitScriptIntoCommands(string scriptContents)
{
var commandSplitter = new SqlCommandSplitter();
var scriptStatements = commandSplitter.SplitScriptIntoCommands(scriptContents);
return scriptStatements;
}
}
17 changes: 8 additions & 9 deletions src/dbup-sqlce/SqlCeObjectParser.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using DbUp.Support;

namespace DbUp.SqlCe
namespace DbUp.SqlCe;

/// <summary>
/// Parses Sql Objects and performs quoting functions.
/// </summary>
public class SqlCeObjectParser : SqlObjectParser
{
/// <summary>
/// Parses Sql Objects and performs quoting functions.
/// </summary>
public class SqlCeObjectParser : SqlObjectParser
public SqlCeObjectParser() : base("[", "]")
{
public SqlCeObjectParser() : base("[", "]")
{
}
}
}
}
19 changes: 9 additions & 10 deletions src/dbup-sqlce/SqlCePreprocessor.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System.Text.RegularExpressions;
using DbUp.Engine;

namespace DbUp.SqlCe
namespace DbUp.SqlCe;

/// <summary>
/// This preprocessor makes minor adjustments to your sql to make it compatible with SqlCe.
/// </summary>
public class SqlCePreprocessor : IScriptPreprocessor
{
/// <summary>
/// This preprocessor makes minor adjustments to your sql to make it compatible with SqlCe.
/// Performs some preprocessing step on a script
/// </summary>
public class SqlCePreprocessor : IScriptPreprocessor
public string Process(string contents)
{
/// <summary>
/// Performs some preprocessing step on a script
/// </summary>
public string Process(string contents)
{
return Regex.Replace(contents, @"nvarchar\s?\(max\)", "ntext", RegexOptions.IgnoreCase);
}
return Regex.Replace(contents, @"nvarchar\s?\(max\)", "ntext", RegexOptions.IgnoreCase);
}
}
Loading

0 comments on commit d4473e8

Please sign in to comment.