Skip to content
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

Use expression bodied properties #653

Merged
merged 2 commits into from
Mar 11, 2024
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
5 changes: 1 addition & 4 deletions src/FluentNHibernate.Specs.ExternalFixtures/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public class Entity

public enum TestEnum {}

public EntityChild ReadOnlyChild
{
get { return readOnlyChild; }
}
public EntityChild ReadOnlyChild => readOnlyChild;
}

public class EntityChild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ class ReadOnlyEnumerableEntity

public int Id { get; set; }
public IEnumerable<EntityChild> AutoPropertyCollection { get; private set; }
public IEnumerable<EntityChild> BackingFieldCollection
{
get { return backingFieldCollection; }
}
public IEnumerable<EntityChild> BackingFieldCollection => backingFieldCollection;
}
12 changes: 3 additions & 9 deletions src/FluentNHibernate.Specs/Automapping/Fixtures/UserTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,9 @@ public SqlType[] SqlTypes
get { return new[] { new SqlType(DbType.String) }; }
}

public Type ReturnedType
{
get { return typeof(CustomUserType); }
}
public Type ReturnedType => typeof(CustomUserType);

public bool IsMutable
{
get { return true; }
}
public bool IsMutable => true;
}

public struct UserValueType : IUserType
Expand Down Expand Up @@ -169,6 +163,6 @@ public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplemen
}

public SqlType[] SqlTypes { get; private set; }
public Type ReturnedType { get { return typeof(UserValueType); } }
public Type ReturnedType => typeof(UserValueType);
public bool IsMutable { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class when_class_map_is_told_to_map_an_id_without_a_property_or_column :

static ClassMapping mapping;

static IdMapping Id { get { return mapping.Id as IdMapping; }}
static IdMapping Id => mapping.Id as IdMapping;
}

public class when_class_map_has_a_composite_id_with_a_key_reference_with_multiple_columns : ProviderSpec
Expand Down
36 changes: 6 additions & 30 deletions src/FluentNHibernate.Testing/AutoMapping/TestFixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ public class ExampleCustomColumn
{
public int Id { get; set; }
public int ExampleCustomColumnId { get; set; }
public int CustomColumn
{
get
{
return 12;
}
}
public int CustomColumn => 12;
}

public class ExampleInheritedClass : ExampleClass
Expand Down Expand Up @@ -306,26 +300,17 @@ public SqlType[] SqlTypes
get { return new[] {new SqlType(DbType.String)}; }
}

public Type ReturnedType
{
get { return typeof(Custom); }
}
public Type ReturnedType => typeof(Custom);

public bool IsMutable
{
get { return true; }
}
public bool IsMutable => true;
}
}

namespace FluentNHibernate.Automapping.TestFixtures.CustomCompositeTypes
{
public class DoubleStringType : ICompositeUserType
{
public System.Type ReturnedClass
{
get { return typeof(string[]); }
}
public System.Type ReturnedClass => typeof(string[]);

public new bool Equals(object x, object y)
{
Expand Down Expand Up @@ -357,10 +342,7 @@ public Object DeepCopy(Object x)
return result;
}

public bool IsMutable
{
get { return true; }
}
public bool IsMutable => true;

public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner)
{
Expand Down Expand Up @@ -431,13 +413,7 @@ public class SuperType
public class ExampleCustomColumn : SuperType
{
public int ExampleCustomColumnId { get; set; }
public int CustomColumn
{
get
{
return 12;
}
}
public int CustomColumn => 12;
}

public class ExampleInheritedClass : ExampleClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ private void HasProperty(string key, string value)

private class CacheSettingsBuilderDouble : CacheSettingsBuilder
{
public IDictionary<string, string> Properties
{
get { return Create(); }
}
public IDictionary<string, string> Properties => Create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public void ConnectionStringSetFromConnectionStrings()

private class ConnectionStringBuilderDouble : ConnectionStringBuilder
{
public string ConnectionString
{
get { return Create(); }
}
public string ConnectionString => Create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -692,18 +692,11 @@ public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplemen
throw new NotImplementedException();
}

public SqlType[] SqlTypes
{
get { return null; }
}
public Type ReturnedType
{
get { return typeof(OtherObject); }
}
public bool IsMutable
{
get { return false; }
}
public SqlType[] SqlTypes => null;

public Type ReturnedType => typeof(OtherObject);

public bool IsMutable => false;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,11 @@ public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplemen
throw new NotImplementedException();
}

public SqlType[] SqlTypes
{
get { return null; }
}
public SqlType[] SqlTypes => null;

public Type ReturnedType
{
get { return null; }
}
public Type ReturnedType => null;

public bool IsMutable
{
get { return false; }
}
public bool IsMutable => false;
}
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public class OneToManyTarget
public virtual IList<ChildObject> GetOtherChildren() { return otherChildren; }

private IList<ChildObject> listToArrayChild = new List<ChildObject>();
public virtual ChildObject[] ListToArrayChild { get { return listToArrayChild.ToArray(); } }

public virtual ChildObject[] ListToArrayChild => listToArrayChild.ToArray();
}

public class ValueObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ private class UserLoginInfo : IUserLoginInfo { }
private class User
{
public int Id { get; set; }
public IUserLoginInfo LoginInfo
{
get { return null; }
}
public IUserLoginInfo LoginInfo => null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,20 +506,11 @@ public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplemen
throw new NotImplementedException();
}

public SqlType[] SqlTypes
{
get { return null; }
}
public SqlType[] SqlTypes => null;

public Type ReturnedType
{
get { return null; }
}
public Type ReturnedType => null;

public bool IsMutable
{
get { return false; }
}
public bool IsMutable => false;
}

public class CustomGenericTypeForTesting<T> : IUserType
Expand Down Expand Up @@ -576,14 +567,9 @@ public SqlType[] SqlTypes
{
get { return new SqlType[] {}; }
}
public Type ReturnedType
{
get { return null; }
}
public bool IsMutable
{
get { return false; }
}
public Type ReturnedType => null;

public bool IsMutable => false;
}
#endregion
}
Expand Down Expand Up @@ -664,8 +650,5 @@ public ISetter GetSetter(Type theClass, string propertyName)
return null;
}

public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
public bool CanAccessThroughReflectionOptimizer => false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,17 @@ class Example

public string Property
{
get { return property; }
set { property = value; }
get => property;
set => property = value;
}

public string PropertyPrivateSetter
{
get { return propertyPrivateSetter; }
private set { propertyPrivateSetter = value; }
get => propertyPrivateSetter;
private set => propertyPrivateSetter = value;
}

public string PropertyNoSetter
{
get { return propertyNoSetter; }
}
public string PropertyNoSetter => propertyNoSetter;

public IEnumerable<Example> GetViaMethod()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,13 @@ class Example
IEnumerable<Example> lowercasemethod;
IEnumerable<Example> _UnderscorePascalCaseMethod;

public string PropertyWithCamelCaseField
{
get { return propertyWithCamelCaseField; }
}
public string PropertyWithCamelCaseField => propertyWithCamelCaseField;

public string PropertyWithLowerCaseField
{
get { return propertywithlowercasefield; }
}
public string PropertyWithLowerCaseField => propertywithlowercasefield;

public string PropertyWithUnderscoreCamelCaseField
{
get { return _propertyWithUnderscoreCamelCaseField; }
}
public string PropertyWithUnderscoreCamelCaseField => _propertyWithUnderscoreCamelCaseField;

public string PropertyWithUnderscorePascalCaseField
{
get { return _PropertyWithUnderscorePascalCaseField; }
}
public string PropertyWithUnderscorePascalCaseField => _PropertyWithUnderscorePascalCaseField;

public IEnumerable<Example> CamelCaseMethod()
{
Expand Down
Loading