Skip to content

Commit ba4147c

Browse files
Obsolete unused "xml" type methods (#1771)
1 parent 52e3798 commit ba4147c

Some content is hidden

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

54 files changed

+622
-129
lines changed

src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,9 @@ public override void Set(DbCommand cmd, object value, int index, ISessionImpleme
4646
}
4747
}
4848

49-
public override object FromStringValue(string xml)
50-
{
51-
return NullableInt32.Parse(xml);
52-
}
53-
5449
public override bool[] ToColumnNullness(object value, Engine.IMapping mapping)
5550
{
5651
return value == null || NullableInt32.Default.Equals(value) ? new bool[] { false } : new bool[] { true };
5752
}
5853
}
59-
}
54+
}

src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public override object Get(DbDataReader rs, string name, ISessionImplementor ses
3535
return Get(rs, rs.GetOrdinal(name), session);
3636
}
3737

38-
public override string ToString(object value)
39-
{
40-
return value.ToString();
41-
}
42-
4338
public override string Name
4439
{
4540
get { return ReturnedClass.Name; }
@@ -52,4 +47,4 @@ public override bool IsEqual(object x, object y)
5247

5348
public abstract object NullValue { get; }
5449
}
55-
}
50+
}

src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ public virtual void QueryUseExpectedSqlType()
368368
[TestCase("2011-01-27T15:50:59.6220000+02:00")]
369369
[TestCase("2011-01-27T14:50:59.6220000+01:00")]
370370
[TestCase("2011-01-27T13:50:59.6220000Z")]
371+
[Obsolete]
371372
public void FromStringValue_ParseValidValues(string timestampValue)
372373
{
373374
var timestamp = DateTime.Parse(timestampValue);

src/NHibernate/Async/Type/ByteType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5454
}
5555
}
5656
}
57-
}
57+
}

src/NHibernate/Async/Type/EnumStringType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ public override Task<object> DisassembleAsync(object value, ISessionImplementor
6161
}
6262
}
6363
}
64-
}
64+
}

src/NHibernate/Async/Type/Int16Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5959

6060
#endregion
6161
}
62-
}
62+
}

src/NHibernate/Async/Type/Int64Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5959

6060
#endregion
6161
}
62-
}
62+
}

src/NHibernate/Async/Type/SerializableType.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Runtime.Serialization.Formatters.Binary;
1717
using NHibernate.Engine;
1818
using NHibernate.SqlTypes;
19-
using NHibernate.Util;
2019

2120
namespace NHibernate.Type
2221
{
@@ -57,4 +56,4 @@ public override Task<object> DisassembleAsync(object value, ISessionImplementor
5756
}
5857
}
5958
}
60-
}
59+
}

src/NHibernate/Async/Type/TicksType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5252

5353
#endregion
5454
}
55-
}
55+
}

src/NHibernate/Async/Type/TimeSpanType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5353

5454
#endregion
5555
}
56-
}
56+
}

src/NHibernate/Async/Type/UInt16Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5959

6060
#endregion
6161
}
62-
}
62+
}

src/NHibernate/Async/Type/UInt32Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5959

6060
#endregion
6161
}
62-
}
62+
}

src/NHibernate/Async/Type/UInt64Type.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
5959

6060
#endregion
6161
}
62-
}
62+
}

src/NHibernate/Type/AbstractBinaryType.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ public override int Compare(object x, object y)
127127
return 0;
128128
}
129129

130+
/// <inheritdoc />
131+
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
132+
{
133+
return (value == null) ? null :
134+
// 6.0 TODO: inline this call.
135+
#pragma warning disable 618
136+
ToString(value);
137+
#pragma warning restore 618
138+
}
139+
140+
// Since 5.2
141+
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
130142
public override string ToString(object val)
131143
{
132144
// convert to HEX string
@@ -150,12 +162,18 @@ public override object DeepCopyNotNull(object value)
150162
return ToExternalFormat(result);
151163
}
152164

165+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
166+
// attribute value is irrelevant to the method behavior. Replace override keyword by virtual after having
167+
// removed the obsoleted base.
168+
/// <inheritdoc cref="IVersionType.FromStringValue"/>
169+
#pragma warning disable 672
153170
public override object FromStringValue(string xml)
171+
#pragma warning restore 672
154172
{
155173
if (xml == null)
156174
return null;
157175
if (xml.Length % 2 != 0)
158-
throw new ArgumentException("The string is not a valid xml representation of a binary content.");
176+
throw new ArgumentException("The string is not a valid representation of a binary content.");
159177

160178
byte[] bytes = new byte[xml.Length / 2];
161179
for (int i = 0; i < bytes.Length; i++)

src/NHibernate/Type/AbstractCharType.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
5555
return '\'' + value.ToString() + '\'';
5656
}
5757

58+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
59+
// attribute value is irrelevant to the method behavior.
60+
/// <inheritdoc />
5861
public virtual object StringToObject(string xml)
5962
{
6063
if (xml.Length != 1)
@@ -63,9 +66,11 @@ public virtual object StringToObject(string xml)
6366
return xml[0];
6467
}
6568

69+
// Since 5.2
70+
[Obsolete("This method has no more usages and will be removed in a future version.")]
6671
public override object FromStringValue(string xml)
6772
{
6873
return xml[0];
6974
}
7075
}
71-
}
76+
}

src/NHibernate/Type/AbstractDateTimeType.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,38 @@ public override bool IsEqual(object x, object y) =>
129129
(Kind == DateTimeKind.Unspecified || x == null || ((DateTime) x).Kind == ((DateTime) y).Kind);
130130

131131
/// <inheritdoc />
132+
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
133+
{
134+
return (value == null) ? null :
135+
// 6.0 TODO: inline this call.
136+
#pragma warning disable 618
137+
ToString(value);
138+
#pragma warning restore 618
139+
}
140+
141+
// Since 5.2
142+
/// <inheritdoc />
143+
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
132144
public override string ToString(object val) =>
133145
((DateTime) val).ToString(CultureInfo.CurrentCulture);
134146

147+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
148+
// attribute value is irrelevant to the method behavior.
135149
/// <inheritdoc />
136150
public object StringToObject(string xml) =>
137-
string.IsNullOrEmpty(xml) ? null : FromStringValue(xml);
138-
139-
/// <inheritdoc />
151+
string.IsNullOrEmpty(xml) ? null :
152+
// 6.0 TODO: remove warning disable/restore
153+
#pragma warning disable 618
154+
FromStringValue(xml);
155+
#pragma warning restore 618
156+
157+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
158+
// attribute value is irrelevant to the method behavior. Replace override keyword by virtual after having
159+
// removed the obsoleted base.
160+
/// <inheritdoc cref="IVersionType.FromStringValue"/>
161+
#pragma warning disable 672
140162
public override object FromStringValue(string xml)
163+
#pragma warning restore 672
141164
{
142165
// Parsing with .Net always yield a Local date.
143166
var date = DateTime.Parse(xml);

src/NHibernate/Type/AbstractEnumType.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42
using NHibernate.SqlTypes;
53

64
namespace NHibernate.Type
@@ -34,17 +32,20 @@ public override System.Type ReturnedClass
3432
get { return enumType; }
3533
}
3634

37-
3835
#region IIdentifierType Members
3936

37+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
38+
// attribute value is irrelevant to the method behavior.
39+
/// <inheritdoc />
4040
public object StringToObject(string xml)
4141
{
4242
return Enum.Parse(enumType, xml);
4343
}
4444

4545
#endregion
4646

47-
47+
// Since 5.2
48+
[Obsolete("This method has no more usages and will be removed in a future version.")]
4849
public override object FromStringValue(string xml)
4950
{
5051
return StringToObject(xml);

src/NHibernate/Type/AbstractStringType.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,25 @@ public override object Get(DbDataReader rs, string name, ISessionImplementor ses
3434
return Convert.ToString(rs[name]);
3535
}
3636

37+
/// <inheritdoc />
38+
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
39+
{
40+
return (value == null) ? null :
41+
// 6.0 TODO: inline this call.
42+
#pragma warning disable 618
43+
ToString(value);
44+
#pragma warning restore 618
45+
}
46+
47+
// Since 5.2
48+
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
3749
public override string ToString(object val)
3850
{
3951
return (string)val;
4052
}
4153

54+
// Since 5.2
55+
[Obsolete("This method has no more usages and will be removed in a future version.")]
4256
public override object FromStringValue(string xml)
4357
{
4458
return xml;
@@ -51,6 +65,9 @@ public override System.Type ReturnedClass
5165

5266
#region IIdentifierType Members
5367

68+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
69+
// attribute value is irrelevant to the method behavior.
70+
/// <inheritdoc />
5471
public object StringToObject(string xml)
5572
{
5673
return xml;
@@ -67,4 +84,4 @@ public string ObjectToSQLString(object value, Dialect.Dialect dialect)
6784

6885
#endregion
6986
}
70-
}
87+
}

src/NHibernate/Type/BooleanType.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,22 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
7474
return dialect.ToBooleanValueString((bool)value);
7575
}
7676

77+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
78+
// attribute value is irrelevant to the method behavior.
79+
/// <inheritdoc />
7780
public virtual object StringToObject(string xml)
7881
{
82+
// 6.0 TODO: inline the call
83+
#pragma warning disable 618
7984
return FromStringValue(xml);
85+
#pragma warning restore 618
8086
}
8187

88+
// Since 5.2
89+
[Obsolete("This method has no more usages and will be removed in a future version.")]
8290
public override object FromStringValue(string xml)
8391
{
8492
return bool.Parse(xml);
8593
}
8694
}
87-
}
95+
}

src/NHibernate/Type/ByteType.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,21 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
5656
return value.ToString();
5757
}
5858

59+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
60+
// attribute value is irrelevant to the method behavior.
61+
/// <inheritdoc />
5962
public virtual object StringToObject(string xml)
6063
{
6164
return Byte.Parse(xml);
6265
}
6366

67+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
68+
// attribute value is irrelevant to the method behavior. Replace override keyword by virtual after having
69+
// removed the obsoleted base.
70+
/// <inheritdoc cref="IVersionType.FromStringValue"/>
71+
#pragma warning disable 672
6472
public override object FromStringValue(string xml)
73+
#pragma warning restore 672
6574
{
6675
return byte.Parse(xml);
6776
}
@@ -86,4 +95,4 @@ public override object DefaultValue
8695
get { return ZERO; }
8796
}
8897
}
89-
}
98+
}

src/NHibernate/Type/CharBooleanType.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
6161
return "'" + ToCharacter(value) + "'";
6262
}
6363

64-
/// <summary>
65-
///
66-
/// </summary>
67-
/// <param name="xml"></param>
68-
/// <returns></returns>
64+
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
65+
// attribute value is irrelevant to the method behavior.
66+
/// <inheritdoc />
6967
public override object StringToObject(String xml)
7068
{
7169
if (string.Equals(TrueString, xml, StringComparison.InvariantCultureIgnoreCase))

0 commit comments

Comments
 (0)