Skip to content

Commit f30a1d7

Browse files
committed
DapperTypeHandler Up
1 parent cfa53fa commit f30a1d7

File tree

431 files changed

+41543
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+41543
-419
lines changed

src/StronglyTypedIds/Templates/Guid/Guid_DapperTypeHandler.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public override TESTID Parse(object value)
1616
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
1717
};
1818
}
19+
}
1920

20-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
21-
public static void AddTypeHandler()
22-
{
23-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
24-
}
25-
#pragma warning restore CA2255
26-
21+
#pragma warning disable CA2255
22+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
23+
public static void AddTypeHandler()
24+
{
25+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
2726
}
27+
#pragma warning restore CA2255

src/StronglyTypedIds/Templates/Int/Int_DapperTypeHandler.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ public override TESTID Parse(object value)
1717
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
1818
};
1919
}
20+
}
2021

2122
#pragma warning disable CA2255
22-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
23-
public static void AddTypeHandler()
24-
{
25-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
26-
}
27-
#pragma warning restore CA2255
28-
23+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
24+
public static void AddTypeHandler()
25+
{
26+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
2927
}
28+
#pragma warning restore CA2255

src/StronglyTypedIds/Templates/Long/Long_DapperTypeHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public override TESTID Parse(object value)
1919
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
2020
};
2121
}
22+
}
2223

2324
#pragma warning disable CA2255
24-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
25-
public static void AddTypeHandler()
26-
{
27-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
28-
}
29-
#pragma warning restore CA2255
25+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
26+
public static void AddTypeHandler()
27+
{
28+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
3029
}
30+
#pragma warning restore CA2255

src/StronglyTypedIds/Templates/NewId/NewId_DapperTypeHandler.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ public override TESTID Parse(object value)
1515
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
1616
};
1717
}
18+
}
19+
1820

1921
#pragma warning disable CA2255
20-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
21-
public static void AddTypeHandler()
22-
{
23-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
24-
}
25-
#pragma warning restore CA2255
22+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
23+
public static void AddTypeHandler()
24+
{
25+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
2626
}
27+
#pragma warning restore CA2255

src/StronglyTypedIds/Templates/NullableString/NullableString_DapperTypeHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public override TESTID Parse(object value)
1717
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
1818
};
1919
}
20+
}
2021

2122
#pragma warning disable CA2255
22-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
23-
public static void AddTypeHandler()
24-
{
25-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
26-
}
27-
#pragma warning restore CA2255
23+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
24+
public static void AddTypeHandler()
25+
{
26+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
2827
}
28+
#pragma warning restore CA2255

src/StronglyTypedIds/Templates/String/String_DapperTypeHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public override TESTID Parse(object value)
1515
_ => throw new System.InvalidCastException($"Unable to cast object of type {value.GetType()} to TESTID"),
1616
};
1717
}
18+
}
1819

1920
#pragma warning disable CA2255
20-
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
21-
public static void AddTypeHandler()
22-
{
23-
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
24-
}
25-
#pragma warning restore CA2255
21+
[System.Runtime.CompilerServices.ModuleInitializerAttribute]
22+
public static void AddTypeHandler()
23+
{
24+
Dapper.SqlMapper.AddTypeHandler(new DapperTypeHandler());
2625
}
26+
#pragma warning restore CA2255
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by the StronglyTypedId source generator
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#pragma warning disable 1591 // publicly visible type or member must be documented
11+
12+
#if STRONGLY_TYPED_ID_EMBED_ATTRIBUTES
13+
14+
using System;
15+
16+
namespace StronglyTypedIds
17+
{
18+
/// <summary>
19+
/// Place on partial structs to make the type a strongly-typed ID
20+
/// </summary>
21+
[AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
22+
[System.Diagnostics.Conditional("STRONGLY_TYPED_ID_USAGES")]
23+
internal sealed class StronglyTypedIdAttribute : Attribute
24+
{
25+
/// <summary>
26+
/// Make the struct a strongly typed ID
27+
/// </summary>
28+
/// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value.
29+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.BackingType"/>, which defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param>
30+
/// <param name="converters">Converters to create for serializing/deserializing the strongly-typed ID value.
31+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Converters"/>, which defaults to <see cref="StronglyTypedIdConverter.NewtonsoftJson"/>
32+
/// and <see cref="StronglyTypedIdConverter.TypeConverter"/></param>
33+
/// <param name="implementations">Interfaces and patterns the strongly typed id should implement
34+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Implementations"/>, which defaults to <see cref="StronglyTypedIdImplementations.IEquatable"/>
35+
/// and <see cref="StronglyTypedIdImplementations.IComparable"/></param>
36+
public StronglyTypedIdAttribute(
37+
StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Default,
38+
StronglyTypedIdConverter converters = StronglyTypedIdConverter.Default,
39+
StronglyTypedIdImplementations implementations = StronglyTypedIdImplementations.Default)
40+
{
41+
BackingType = backingType;
42+
Converters = converters;
43+
Implementations = implementations;
44+
}
45+
46+
/// <summary>
47+
/// The <see cref="Type"/> to use to store the strongly-typed ID value
48+
/// </summary>
49+
public StronglyTypedIdBackingType BackingType { get; }
50+
51+
/// <summary>
52+
/// JSON library used to serialize/deserialize strongly-typed ID value
53+
/// </summary>
54+
public StronglyTypedIdConverter Converters { get; }
55+
56+
/// <summary>
57+
/// Interfaces and patterns the strongly typed id should implement
58+
/// </summary>
59+
public StronglyTypedIdImplementations Implementations { get; }
60+
}
61+
}
62+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by the StronglyTypedId source generator
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#pragma warning disable 1591 // publicly visible type or member must be documented
11+
12+
#if STRONGLY_TYPED_ID_EMBED_ATTRIBUTES
13+
14+
using System;
15+
16+
namespace StronglyTypedIds
17+
{
18+
/// <summary>
19+
/// Place on partial structs to make the type a strongly-typed ID
20+
/// </summary>
21+
[AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
22+
[System.Diagnostics.Conditional("STRONGLY_TYPED_ID_USAGES")]
23+
internal sealed class StronglyTypedIdAttribute : Attribute
24+
{
25+
/// <summary>
26+
/// Make the struct a strongly typed ID
27+
/// </summary>
28+
/// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value.
29+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.BackingType"/>, which defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param>
30+
/// <param name="converters">Converters to create for serializing/deserializing the strongly-typed ID value.
31+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Converters"/>, which defaults to <see cref="StronglyTypedIdConverter.NewtonsoftJson"/>
32+
/// and <see cref="StronglyTypedIdConverter.TypeConverter"/></param>
33+
/// <param name="implementations">Interfaces and patterns the strongly typed id should implement
34+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Implementations"/>, which defaults to <see cref="StronglyTypedIdImplementations.IEquatable"/>
35+
/// and <see cref="StronglyTypedIdImplementations.IComparable"/></param>
36+
public StronglyTypedIdAttribute(
37+
StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Default,
38+
StronglyTypedIdConverter converters = StronglyTypedIdConverter.Default,
39+
StronglyTypedIdImplementations implementations = StronglyTypedIdImplementations.Default)
40+
{
41+
BackingType = backingType;
42+
Converters = converters;
43+
Implementations = implementations;
44+
}
45+
46+
/// <summary>
47+
/// The <see cref="Type"/> to use to store the strongly-typed ID value
48+
/// </summary>
49+
public StronglyTypedIdBackingType BackingType { get; }
50+
51+
/// <summary>
52+
/// JSON library used to serialize/deserialize strongly-typed ID value
53+
/// </summary>
54+
public StronglyTypedIdConverter Converters { get; }
55+
56+
/// <summary>
57+
/// Interfaces and patterns the strongly typed id should implement
58+
/// </summary>
59+
public StronglyTypedIdImplementations Implementations { get; }
60+
}
61+
}
62+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by the StronglyTypedId source generator
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#pragma warning disable 1591 // publicly visible type or member must be documented
11+
12+
#if STRONGLY_TYPED_ID_EMBED_ATTRIBUTES
13+
14+
using System;
15+
16+
namespace StronglyTypedIds
17+
{
18+
/// <summary>
19+
/// Place on partial structs to make the type a strongly-typed ID
20+
/// </summary>
21+
[AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
22+
[System.Diagnostics.Conditional("STRONGLY_TYPED_ID_USAGES")]
23+
internal sealed class StronglyTypedIdAttribute : Attribute
24+
{
25+
/// <summary>
26+
/// Make the struct a strongly typed ID
27+
/// </summary>
28+
/// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value.
29+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.BackingType"/>, which defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param>
30+
/// <param name="converters">Converters to create for serializing/deserializing the strongly-typed ID value.
31+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Converters"/>, which defaults to <see cref="StronglyTypedIdConverter.NewtonsoftJson"/>
32+
/// and <see cref="StronglyTypedIdConverter.TypeConverter"/></param>
33+
/// <param name="implementations">Interfaces and patterns the strongly typed id should implement
34+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Implementations"/>, which defaults to <see cref="StronglyTypedIdImplementations.IEquatable"/>
35+
/// and <see cref="StronglyTypedIdImplementations.IComparable"/></param>
36+
public StronglyTypedIdAttribute(
37+
StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Default,
38+
StronglyTypedIdConverter converters = StronglyTypedIdConverter.Default,
39+
StronglyTypedIdImplementations implementations = StronglyTypedIdImplementations.Default)
40+
{
41+
BackingType = backingType;
42+
Converters = converters;
43+
Implementations = implementations;
44+
}
45+
46+
/// <summary>
47+
/// The <see cref="Type"/> to use to store the strongly-typed ID value
48+
/// </summary>
49+
public StronglyTypedIdBackingType BackingType { get; }
50+
51+
/// <summary>
52+
/// JSON library used to serialize/deserialize strongly-typed ID value
53+
/// </summary>
54+
public StronglyTypedIdConverter Converters { get; }
55+
56+
/// <summary>
57+
/// Interfaces and patterns the strongly typed id should implement
58+
/// </summary>
59+
public StronglyTypedIdImplementations Implementations { get; }
60+
}
61+
}
62+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by the StronglyTypedId source generator
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#pragma warning disable 1591 // publicly visible type or member must be documented
11+
12+
#if STRONGLY_TYPED_ID_EMBED_ATTRIBUTES
13+
14+
using System;
15+
16+
namespace StronglyTypedIds
17+
{
18+
/// <summary>
19+
/// Place on partial structs to make the type a strongly-typed ID
20+
/// </summary>
21+
[AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
22+
[System.Diagnostics.Conditional("STRONGLY_TYPED_ID_USAGES")]
23+
internal sealed class StronglyTypedIdAttribute : Attribute
24+
{
25+
/// <summary>
26+
/// Make the struct a strongly typed ID
27+
/// </summary>
28+
/// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value.
29+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.BackingType"/>, which defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param>
30+
/// <param name="converters">Converters to create for serializing/deserializing the strongly-typed ID value.
31+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Converters"/>, which defaults to <see cref="StronglyTypedIdConverter.NewtonsoftJson"/>
32+
/// and <see cref="StronglyTypedIdConverter.TypeConverter"/></param>
33+
/// <param name="implementations">Interfaces and patterns the strongly typed id should implement
34+
/// If not set, uses <see cref="StronglyTypedIdDefaultsAttribute.Implementations"/>, which defaults to <see cref="StronglyTypedIdImplementations.IEquatable"/>
35+
/// and <see cref="StronglyTypedIdImplementations.IComparable"/></param>
36+
public StronglyTypedIdAttribute(
37+
StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Default,
38+
StronglyTypedIdConverter converters = StronglyTypedIdConverter.Default,
39+
StronglyTypedIdImplementations implementations = StronglyTypedIdImplementations.Default)
40+
{
41+
BackingType = backingType;
42+
Converters = converters;
43+
Implementations = implementations;
44+
}
45+
46+
/// <summary>
47+
/// The <see cref="Type"/> to use to store the strongly-typed ID value
48+
/// </summary>
49+
public StronglyTypedIdBackingType BackingType { get; }
50+
51+
/// <summary>
52+
/// JSON library used to serialize/deserialize strongly-typed ID value
53+
/// </summary>
54+
public StronglyTypedIdConverter Converters { get; }
55+
56+
/// <summary>
57+
/// Interfaces and patterns the strongly typed id should implement
58+
/// </summary>
59+
public StronglyTypedIdImplementations Implementations { get; }
60+
}
61+
}
62+
#endif

0 commit comments

Comments
 (0)