Skip to content

Obsolete unused "xml" type methods #1771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
7 changes: 1 addition & 6 deletions src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,9 @@ public override void Set(DbCommand cmd, object value, int index, ISessionImpleme
}
}

public override object FromStringValue(string xml)
{
return NullableInt32.Parse(xml);
}

public override bool[] ToColumnNullness(object value, Engine.IMapping mapping)
{
return value == null || NullableInt32.Default.Equals(value) ? new bool[] { false } : new bool[] { true };
}
}
}
}
7 changes: 1 addition & 6 deletions src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public override object Get(DbDataReader rs, string name, ISessionImplementor ses
return Get(rs, rs.GetOrdinal(name), session);
}

public override string ToString(object value)
{
return value.ToString();
}

public override string Name
{
get { return ReturnedClass.Name; }
Expand All @@ -52,4 +47,4 @@ public override bool IsEqual(object x, object y)

public abstract object NullValue { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public virtual void QueryUseExpectedSqlType()
[TestCase("2011-01-27T15:50:59.6220000+02:00")]
[TestCase("2011-01-27T14:50:59.6220000+01:00")]
[TestCase("2011-01-27T13:50:59.6220000Z")]
[Obsolete]
public void FromStringValue_ParseValidValues(string timestampValue)
{
var timestamp = DateTime.Parse(timestampValue);
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/ByteType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/EnumStringType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ public override Task<object> DisassembleAsync(object value, ISessionImplementor
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/Int16Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/Int64Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
3 changes: 1 addition & 2 deletions src/NHibernate/Async/Type/SerializableType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Runtime.Serialization.Formatters.Binary;
using NHibernate.Engine;
using NHibernate.SqlTypes;
using NHibernate.Util;

namespace NHibernate.Type
{
Expand Down Expand Up @@ -57,4 +56,4 @@ public override Task<object> DisassembleAsync(object value, ISessionImplementor
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/TicksType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/TimeSpanType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/UInt16Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/UInt32Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Async/Type/UInt64Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public virtual Task<object> SeedAsync(ISessionImplementor session, CancellationT

#endregion
}
}
}
20 changes: 19 additions & 1 deletion src/NHibernate/Type/AbstractBinaryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ public override int Compare(object x, object y)
return 0;
}

/// <inheritdoc />
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
{
return (value == null) ? null :
// 6.0 TODO: inline this call.
#pragma warning disable 618
ToString(value);
#pragma warning restore 618
}

// Since 5.2
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
public override string ToString(object val)
{
// convert to HEX string
Expand All @@ -150,12 +162,18 @@ public override object DeepCopyNotNull(object value)
return ToExternalFormat(result);
}

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

byte[] bytes = new byte[xml.Length / 2];
for (int i = 0; i < bytes.Length; i++)
Expand Down
7 changes: 6 additions & 1 deletion src/NHibernate/Type/AbstractCharType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
return '\'' + value.ToString() + '\'';
}

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

// Since 5.2
[Obsolete("This method has no more usages and will be removed in a future version.")]
public override object FromStringValue(string xml)
{
return xml[0];
}
}
}
}
29 changes: 26 additions & 3 deletions src/NHibernate/Type/AbstractDateTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,38 @@ public override bool IsEqual(object x, object y) =>
(Kind == DateTimeKind.Unspecified || x == null || ((DateTime) x).Kind == ((DateTime) y).Kind);

/// <inheritdoc />
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
{
return (value == null) ? null :
// 6.0 TODO: inline this call.
#pragma warning disable 618
ToString(value);
#pragma warning restore 618
}

// Since 5.2
/// <inheritdoc />
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
public override string ToString(object val) =>
((DateTime) val).ToString(CultureInfo.CurrentCulture);

// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
// attribute value is irrelevant to the method behavior.
/// <inheritdoc />
public object StringToObject(string xml) =>
string.IsNullOrEmpty(xml) ? null : FromStringValue(xml);

/// <inheritdoc />
string.IsNullOrEmpty(xml) ? null :
// 6.0 TODO: remove warning disable/restore
#pragma warning disable 618
FromStringValue(xml);
#pragma warning restore 618

// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
// attribute value is irrelevant to the method behavior. Replace override keyword by virtual after having
// removed the obsoleted base.
/// <inheritdoc cref="IVersionType.FromStringValue"/>
#pragma warning disable 672
public override object FromStringValue(string xml)
#pragma warning restore 672
{
// Parsing with .Net always yield a Local date.
var date = DateTime.Parse(xml);
Expand Down
9 changes: 5 additions & 4 deletions src/NHibernate/Type/AbstractEnumType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.SqlTypes;

namespace NHibernate.Type
Expand Down Expand Up @@ -34,17 +32,20 @@ public override System.Type ReturnedClass
get { return enumType; }
}


#region IIdentifierType Members

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

#endregion


// Since 5.2
[Obsolete("This method has no more usages and will be removed in a future version.")]
public override object FromStringValue(string xml)
{
return StringToObject(xml);
Expand Down
19 changes: 18 additions & 1 deletion src/NHibernate/Type/AbstractStringType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@ public override object Get(DbDataReader rs, string name, ISessionImplementor ses
return Convert.ToString(rs[name]);
}

/// <inheritdoc />
public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
{
return (value == null) ? null :
// 6.0 TODO: inline this call.
#pragma warning disable 618
ToString(value);
#pragma warning restore 618
}

// Since 5.2
[Obsolete("This method has no more usages and will be removed in a future version. Override ToLoggableString instead.")]
public override string ToString(object val)
{
return (string)val;
}

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

#region IIdentifierType Members

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

#endregion
}
}
}
10 changes: 9 additions & 1 deletion src/NHibernate/Type/BooleanType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,22 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
return dialect.ToBooleanValueString((bool)value);
}

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

// Since 5.2
[Obsolete("This method has no more usages and will be removed in a future version.")]
public override object FromStringValue(string xml)
{
return bool.Parse(xml);
}
}
}
}
11 changes: 10 additions & 1 deletion src/NHibernate/Type/ByteType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,21 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
return value.ToString();
}

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

// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
// attribute value is irrelevant to the method behavior. Replace override keyword by virtual after having
// removed the obsoleted base.
/// <inheritdoc cref="IVersionType.FromStringValue"/>
#pragma warning disable 672
public override object FromStringValue(string xml)
#pragma warning restore 672
{
return byte.Parse(xml);
}
Expand All @@ -86,4 +95,4 @@ public override object DefaultValue
get { return ZERO; }
}
}
}
}
8 changes: 3 additions & 5 deletions src/NHibernate/Type/CharBooleanType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
return "'" + ToCharacter(value) + "'";
}

/// <summary>
///
/// </summary>
/// <param name="xml"></param>
/// <returns></returns>
// 6.0 TODO: rename "xml" parameter as "value": it is not a xml string. The fact it generally comes from a xml
// attribute value is irrelevant to the method behavior.
/// <inheritdoc />
public override object StringToObject(String xml)
{
if (string.Equals(TrueString, xml, StringComparison.InvariantCultureIgnoreCase))
Expand Down
Loading