Skip to content

Commit

Permalink
Lowered req to .Net4, upgraded dapper & T4Include
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Dec 1, 2014
1 parent 57f9292 commit f9c1c42
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 48 deletions.
6 changes: 3 additions & 3 deletions src/SqlBulkSync/SqlBulkSync/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
</configuration>
71 changes: 33 additions & 38 deletions src/SqlBulkSync/SqlBulkSync/Include_T4Include.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// # #
// # This means that any edits to the .cs file will be lost when its #
// # regenerated. Changes should instead be applied to the corresponding #
// # text template file (.tt) #
// # text template file (.tt) #
// ############################################################################


Expand Down Expand Up @@ -59,6 +59,9 @@
// Certains directives such as #define and // Resharper comments has to be
// moved to top in order to work properly
// ############################################################################
#pragma warning disable 0618
#pragma warning disable 612, 618
#pragma warning disable 618
// ReSharper disable InconsistentNaming
// ReSharper disable PartialMethodWithSinglePart
// ReSharper disable PartialTypeWithSinglePart
Expand Down Expand Up @@ -3369,7 +3372,7 @@ internal sealed class AssemblyNeutralAttribute : Attribute { }
public enum CommandFlags
{
/// <summary>
/// No additonal flags
/// No additional flags
/// </summary>
None = 0,
/// <summary>
Expand Down Expand Up @@ -3599,7 +3602,7 @@ public interface IParameterLookup : IDynamicParameters
}

/// <summary>
/// Extends IDynamicParameters with facitilies for executing callbacks after commands have completed
/// Extends IDynamicParameters with facilities for executing callbacks after commands have completed
/// </summary>
public partial interface IParameterCallbacks : IDynamicParameters
{
Expand Down Expand Up @@ -3713,7 +3716,7 @@ object ITypeHandler.Parse(Type destinationType, object value)
}

/// <summary>
/// Implement this interface to change default mapping of reader columns to type memebers
/// Implement this interface to change default mapping of reader columns to type members
/// </summary>
public interface ITypeMap
{
Expand All @@ -3730,7 +3733,7 @@ public interface ITypeMap
///
/// Parameters will be default values, nulls for reference types and zero'd for value types.
///
/// Use this class to force object creation away from parameterless constructors you dn't control.
/// Use this class to force object creation away from parameterless constructors you don't control.
/// </summary>
ConstructorInfo FindExplicitConstructor();

Expand Down Expand Up @@ -4071,7 +4074,7 @@ public static void ResetTypeHandlers()
AddTypeHandlerImpl(typeof(DataTable), new DataTableHandler(), true);
}
/// <summary>
/// Configire the specified type to be mapped to a given db-type
/// Configure the specified type to be mapped to a given db-type
/// </summary>
public static void AddTypeMap(Type type, DbType dbType)
{
Expand All @@ -4087,15 +4090,15 @@ public static void AddTypeMap(Type type, DbType dbType)
}

/// <summary>
/// Configire the specified type to be processed by a custom handler
/// Configure the specified type to be processed by a custom handler
/// </summary>
public static void AddTypeHandler(Type type, ITypeHandler handler)
{
AddTypeHandlerImpl(type, handler, true);
}

/// <summary>
/// Configire the specified type to be processed by a custom handler
/// Configure the specified type to be processed by a custom handler
/// </summary>
public static void AddTypeHandlerImpl(Type type, ITypeHandler handler, bool clone)
{
Expand Down Expand Up @@ -4123,13 +4126,11 @@ public static void AddTypeHandlerImpl(Type type, ITypeHandler handler, bool clon

var newCopy = clone ? new Dictionary<Type, ITypeHandler>(snapshot) : snapshot;

#pragma warning disable 618
typeof(TypeHandlerCache<>).MakeGenericType(type).GetMethod("SetHandler", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { handler });
if(secondary != null)
{
typeof(TypeHandlerCache<>).MakeGenericType(secondary).GetMethod("SetHandler", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { handler });
}
#pragma warning restore 618
if (handler == null)
{
newCopy.Remove(type);
Expand All @@ -4144,7 +4145,7 @@ public static void AddTypeHandlerImpl(Type type, ITypeHandler handler, bool clon
}

/// <summary>
/// Configire the specified type to be processed by a custom handler
/// Configure the specified type to be processed by a custom handler
/// </summary>
public static void AddTypeHandler<T>(TypeHandler<T> handler)
{
Expand Down Expand Up @@ -4179,9 +4180,7 @@ public static void SetValue(IDbDataParameter parameter, object value)

internal static void SetHandler(ITypeHandler handler)
{
#pragma warning disable 618
TypeHandlerCache<T>.handler = handler;
#pragma warning restore 618
}

private static ITypeHandler handler;
Expand Down Expand Up @@ -4249,7 +4248,7 @@ internal static DbType LookupDbType(Type type, string name, bool demand, out ITy
}

/// <summary>
/// Identity of a cached query in Dapper, used for extensability
/// Identity of a cached query in Dapper, used for extensibility
/// </summary>
public partial class Identity : IEquatable<Identity>
{
Expand Down Expand Up @@ -4936,8 +4935,8 @@ private static IEnumerable<T> QueryImpl<T>(this IDbConnection cnn, CommandDefini
/// <summary>
/// Maps a query to objects
/// </summary>
/// <typeparam name="TFirst">The first type in the recordset</typeparam>
/// <typeparam name="TSecond">The second type in the recordset</typeparam>
/// <typeparam name="TFirst">The first type in the record set</typeparam>
/// <typeparam name="TSecond">The second type in the record set</typeparam>
/// <typeparam name="TReturn">The return type</typeparam>
/// <param name="cnn"></param>
/// <param name="sql"></param>
Expand Down Expand Up @@ -5104,7 +5103,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFift
/// <typeparam name="TReturn">The return type</typeparam>
/// <param name="cnn"></param>
/// <param name="sql"></param>
/// <param name="types">array of types in the recordset</param>
/// <param name="types">array of types in the record set</param>
/// <param name="map"></param>
/// <param name="param"></param>
/// <param name="transaction"></param>
Expand Down Expand Up @@ -6243,9 +6242,7 @@ internal static void ReplaceLiterals(IParameterLookup parameters, IDbCommand com
foreach (var token in tokens)
{
object value = parameters[token.Member];
#pragma warning disable 0618
string text = Format(value);
#pragma warning restore 0618
sql = sql.Replace(token.Token, text);
}
command.CommandText = sql;
Expand Down Expand Up @@ -6494,9 +6491,7 @@ internal static Action<IDbCommand, object> CreateParamInfoGenerator(Identity ide

if (handler != null)
{
#pragma warning disable 618
il.Emit(OpCodes.Call, typeof(TypeHandlerCache<>).MakeGenericType(prop.PropertyType).GetMethod("SetValue")); // stack is now [parameters] [[parameters]] [parameter]
#pragma warning restore 618
}
else
{
Expand Down Expand Up @@ -6582,7 +6577,7 @@ internal static Action<IDbCommand, object> CreateParamInfoGenerator(Identity ide
case TypeCode.Single:
case TypeCode.Double:
case TypeCode.Decimal:
// neeed to stloc, ldloca, call
// need to stloc, ldloca, call
// re-use existing locals (both the last known, and via a dictionary)
var convert = GetToString(typeCode);
if (local == null || local.LocalType != propType)
Expand Down Expand Up @@ -6729,7 +6724,6 @@ private static Action<IDbCommand, object> GetParameterReader(IDbConnection cnn,
private static Func<IDataReader, object> GetStructDeserializer(Type type, Type effectiveType, int index)
{
// no point using special per-type handling here; it boils down to the same, plus not all are supported anyway (see: SqlDataReader.GetChar - not supported!)
#pragma warning disable 618
if (type == typeof(char))
{ // this *does* need special handling, though
return r => SqlMapper.ReadChar(r.GetValue(index));
Expand All @@ -6742,7 +6736,6 @@ private static Func<IDataReader, object> GetStructDeserializer(Type type, Type e
{
return r => Activator.CreateInstance(type, r.GetValue(index));
}
#pragma warning restore 618

if (effectiveType.IsEnum)
{ // assume the value is returned as the correct type (int/byte/etc), but box back to the typed enum
Expand Down Expand Up @@ -7070,9 +7063,7 @@ public static Func<IDataReader, object> GetTypeDeserializer(
{
if (hasTypeHandler)
{
#pragma warning disable 618
il.EmitCall(OpCodes.Call, typeof(TypeHandlerCache<>).MakeGenericType(unboxType).GetMethod("Parse"), null); // stack is now [target][target][typed-value]
#pragma warning restore 618
}
else
{
Expand Down Expand Up @@ -7416,7 +7407,7 @@ private static void EmitInt32(ILGenerator il, int value)
/// <summary>
/// How should connection strings be compared for equivalence? Defaults to StringComparer.Ordinal.
/// Providing a custom implementation can be useful for allowing multi-tenancy databases with identical
/// schema to share startegies. Note that usual equivalence rules apply: any equivalent connection strings
/// schema to share strategies. Note that usual equivalence rules apply: any equivalent connection strings
/// <b>MUST</b> yield the same hash-code.
/// </summary>
public static IEqualityComparer<string> ConnectionStringComparer
Expand Down Expand Up @@ -7536,15 +7527,15 @@ private IEnumerable<TReturn> MultiReadInternal<TFirst, TSecond, TThird, TFourth,

#if CSHARP30
/// <summary>
/// Read multiple objects from a single recordset on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
public IEnumerable<TReturn> Read<TFirst, TSecond, TReturn>(Func<TFirst, TSecond, TReturn> func, string splitOn)
{
return Read<TFirst, TSecond, TReturn>(func, splitOn, true);
}
#endif
/// <summary>
/// Read multiple objects from a single recordset on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
#if CSHARP30
public IEnumerable<TReturn> Read<TFirst, TSecond, TReturn>(Func<TFirst, TSecond, TReturn> func, string splitOn, bool buffered)
Expand All @@ -7558,15 +7549,15 @@ public IEnumerable<TReturn> Read<TFirst, TSecond, TReturn>(Func<TFirst, TSecond,

#if CSHARP30
/// <summary>
/// Read multiple objects from a single recordset on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
public IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TReturn>(Func<TFirst, TSecond, TThird, TReturn> func, string splitOn)
{
return Read<TFirst, TSecond, TThird, TReturn>(func, splitOn, true);
}
#endif
/// <summary>
/// Read multiple objects from a single recordset on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
#if CSHARP30
public IEnumerable<TReturn> Read<TFirst, TSecond, TThird, TReturn>(Func<TFirst, TSecond, TThird, TReturn> func, string splitOn, bool buffered)
Expand Down Expand Up @@ -7978,9 +7969,7 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
if (dbType == null && val != null && !isCustomQueryParameter) dbType = SqlMapper.LookupDbType(val.GetType(), name, true, out handler);
if (dbType == DynamicParameters.EnumerableMultiParameter)
{
#pragma warning disable 612, 618
SqlMapper.PackListParameters(command, name, val);
#pragma warning restore 612, 618
}
else if (isCustomQueryParameter)
{
Expand Down Expand Up @@ -8392,7 +8381,7 @@ private static readonly FeatureSupport
postgres = new FeatureSupport(true);

/// <summary>
/// Gets the featureset based on the passed connection
/// Gets the feature set based on the passed connection
/// </summary>
public static FeatureSupport Get(IDbConnection connection)
{
Expand All @@ -8411,7 +8400,7 @@ private FeatureSupport(bool arrays)
}

/// <summary>
/// Represents simple memeber map for one of target parameter or property or field to source DataReader column
/// Represents simple member map for one of target parameter or property or field to source DataReader column
/// </summary>
sealed partial class SimpleMemberMap : SqlMapper.IMemberMap
{
Expand Down Expand Up @@ -8728,7 +8717,7 @@ public ConstructorInfo FindExplicitConstructor()
}

/// <summary>
/// Not impelmeneted as far as default constructor used for all cases
/// Not implemented as far as default constructor used for all cases
/// </summary>
/// <param name="constructor"></param>
/// <param name="columnName"></param>
Expand Down Expand Up @@ -9176,14 +9165,20 @@ static string GetLevelMessage (Level level)
}
// @@@ END_INCLUDE: https://raw.github.com/mrange/T4Include/master/Common/Generated_Log.cs
// ############################################################################

// ############################################################################
// Certains directives such as #define and // Resharper comments has to be
// moved to bottom in order to work properly
// ############################################################################
#pragma warning restore 0618
#pragma warning restore 612, 618
#pragma warning restore 618
// ############################################################################
namespace WCOM.SqlBulkSync.Include
{
static partial class MetaData
{
public const string RootPath = @"https://raw.github.com/";
public const string IncludeDate = @"2014-11-12T23:39:56";
public const string IncludeDate = @"2014-12-02T00:34:15";

public const string Include_0 = @"https://raw.github.com/mrange/T4Include/master/Extensions/BasicExtensions.cs";
public const string Include_1 = @"https://raw.github.com/mrange/T4Include/master/Common/SubString.cs";
Expand Down
2 changes: 1 addition & 1 deletion src/SqlBulkSync/SqlBulkSync/Include_T4Include.tt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
};
#>

<#@ include file="$(SolutionDir)\packages\T4Include.1.1.2\T4\IncludeWebFile.ttinclude" #>
<#@ include file="$(SolutionDir)\packages\T4Include.1.1.4\T4\IncludeWebFile.ttinclude" #>
4 changes: 2 additions & 2 deletions src/SqlBulkSync/SqlBulkSync/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyVersion("1.0.2")]
[assembly: AssemblyFileVersion("1.0.2")]
6 changes: 5 additions & 1 deletion src/SqlBulkSync/SqlBulkSync/SqlBulkSync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WCOM.SqlBulkSync</RootNamespace>
<AssemblyName>SqlBulkSync</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -22,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -31,6 +34,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>wcom.ico</ApplicationIcon>
Expand Down
14 changes: 12 additions & 2 deletions src/SqlBulkSync/SqlBulkSync/SyncRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,25 @@ private static void ProcessSync(SyncJob syncJob)
sourceConn.Database
);
sourceConn.Open();
Log.Success("Connected {0}", sourceConn.ClientConnectionId);
Log.Success(
"Connected {0}.{1} ({2})",
sourceConn.DataSource,
sourceConn.Database,
sourceConn.ServerVersion
);

Log.Info(
"Connecting to target database {0}.{1}",
targetConn.DataSource,
targetConn.Database
);
targetConn.Open();
Log.Success("Connected {0}", targetConn.ClientConnectionId);
Log.Success(
"Connected {0}.{1} ({2})",
targetConn.DataSource,
targetConn.Database,
targetConn.ServerVersion
);

Log.Info("Fetching table schemas");
var schemaStopWatch = Stopwatch.StartNew();
Expand Down
2 changes: 1 addition & 1 deletion src/SqlBulkSync/SqlBulkSync/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="T4Include" version="1.1.2" targetFramework="net451" />
<package id="T4Include" version="1.1.4" targetFramework="net40" />
</packages>

0 comments on commit f9c1c42

Please sign in to comment.