Skip to content

Purge test warnings #671

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
merged 3 commits into from
Aug 15, 2017
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: 5 additions & 0 deletions src/NHibernate.DomainModel/NHibernate.DomainModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good to treat warnings as errors for all configurations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to give it a try with only the release build checking that. If that generates frequently PR failing at this but detected a bit too late (especially already merged), it would be easy and fast to change that.

<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<None Remove="**\*.hbm.xml" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ namespace NHibernate.Test.Generatedkeys.Identity
{
public class MyEntityIdentity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private int id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely most of those cases could have been fixed by using a setter instead. But this would require analyzing each test case for ensuring their current way of mapping the property was not having any bound with the tested feature.

private string name;

public virtual int Id
Expand Down
3 changes: 3 additions & 0 deletions src/NHibernate.Test/Generatedkeys/Select/MyEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ namespace NHibernate.Test.Generatedkeys.Select
{
public class MyEntity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private int id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
private string name;
protected MyEntity() {}

Expand Down
3 changes: 3 additions & 0 deletions src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ namespace NHibernate.Test.Generatedkeys.Seqidentity
{
public class MyEntity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private int id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
private string name;

public virtual int Id
Expand Down
3 changes: 3 additions & 0 deletions src/NHibernate.Test/Hql/Ast/KeyManyToOneEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ namespace NHibernate.Test.Hql.Ast
{
public class KeyManyToOneEntity
{
// Used by reflection
#pragma warning disable CS0169 // The field is never used
private Id id;
#pragma warning restore CS0169 // The field is never used
private string name;

public virtual string Name
Expand Down
3 changes: 3 additions & 0 deletions src/NHibernate.Test/Hql/Ast/KeyManyToOneKeyEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ namespace NHibernate.Test.Hql.Ast
{
public class KeyManyToOneKeyEntity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private long id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
private string name;
private int? requestedHash;

Expand Down
5 changes: 3 additions & 2 deletions src/NHibernate.Test/IdGen/Enhanced/Forcedtable/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
public class Entity
{

#pragma warning disable 0414 // unassigned variable
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private long _id;
#pragma warning restore 0414
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value

public virtual long Id
{
Expand Down
6 changes: 3 additions & 3 deletions src/NHibernate.Test/IdGen/Enhanced/Sequence/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
public class Entity
{

#pragma warning disable 0414 // unassigned variable
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value 0
private long _id;
#pragma warning restore 0414
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value 0

public virtual long Id
{
Expand Down
6 changes: 3 additions & 3 deletions src/NHibernate.Test/IdGen/Enhanced/Table/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace NHibernate.Test.IdGen.Enhanced.Table
{
public class Entity
{

#pragma warning disable 0414 // unassigned variable
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private long _id;
#pragma warning restore 0414
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value

public virtual long Id
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public class ComponetsAccessorTests
private class MyClass
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private MyCompo compo;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public MyCompo Compo
{
get { return compo; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ private class MyClass

private class MyCompo
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private MyClass parent;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value

public MyClass Parent
{
get { return parent; }
Expand All @@ -28,7 +32,10 @@ public MyClass Parent

private class MyNestedCompo
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private MyCompo owner;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public MyCompo Owner
{
get { return owner; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public class PropertyToFieldAccessorTest
private class MyClass
{
public int Id { get; set; }
// Used by reflection
#pragma warning disable CS0169 // The field is never used
private string aField;
#pragma warning restore CS0169 // The field is never used
public int AProp { get; set; }

private ICollection<int> withDifferentBackField;
Expand All @@ -21,7 +24,10 @@ public IEnumerable<int> WithDifferentBackField
set { withDifferentBackField = value as ICollection<int>; }
}

// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private string readOnlyWithSameBackField;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public string ReadOnlyWithSameBackField
{
get { return readOnlyWithSameBackField; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ private class MyClassWithoutPoid

private class MyClass
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private int _id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public int Id
{
get { return _id; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class IdBagMappingTest
private class Animal
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private ICollection<Animal> children;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public ICollection<Animal> Children
{
get { return children; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ public class MappingOfPrivateMembersOnRootEntity
{
public class MyClass
{
// Used by reflection.
#pragma warning disable CS0169 // The field is never used
private int id;
private int version;
private string something;
#pragma warning disable CS0169 // The field is never used
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ private class PersonId

private class Person
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private PersonId id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public PersonId Id
{
get { return id; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ private class PersonId

private class Person
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private PersonId id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public PersonId Id
{
get { return id; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class AnyPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class BagPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class ComponentPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class DynComponentPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class IdBagPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class ListPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class ManyToOnePropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class MapPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class OneToOnePropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class SetPropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class SimplePropertyOnDynamicCompoTests
private class Person
{
public int Id { get; set; }
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private IDictionary info;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IDictionary Info
{
get { return info; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ public void CanSetGeneratorEnhancedTable()
}
private class BaseEntity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private int id;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value

public int Id
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public class MyType : IUserType
{
#region Implementation of IUserType

public bool Equals(object x, object y)
public new bool Equals(object x, object y)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -394,7 +394,7 @@ public void SetPropertyValue(object component, int property, object value)
throw new NotImplementedException();
}

public bool Equals(object x, object y)
public new bool Equals(object x, object y)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public class ArrayCollectionTests
{
private class Entity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private ICollection<string> others;
private string[] emails;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public string[] NickNames { get; set; }
public byte[] Photo { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class BagCollectionTests
// match any IEnumerable
private class Entity
{
// Assigned by reflection
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
private ICollection<string> emails;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
public IEnumerable<string> NickNames { get; set; }
public byte[] Bytes { get; set; }
public object Emails
Expand Down
Loading