Skip to content

Commit

Permalink
Fixing IncludeNonePublicMembers everywhere
Browse files Browse the repository at this point in the history
* Fixing build
* Fix IncludeNonePublicMembers everywhere
  • Loading branch information
MoaidHathot committed Feb 17, 2024
1 parent f9e5661 commit eb40478
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class AdditionValue
}


new AdditionValue(1, 2).Dump(members: new MembersConfig { IncludeFields = true, IncludeNonPublicMembers = true });
new AdditionValue(1, 2).Dump(members: new MembersConfig { IncludeFields = true, IncludeNonePublicMembers = true });
```
![image](https://user-images.githubusercontent.com/8770486/232252840-c5b0ea4c-eae9-4dc2-bd6c-d42ee58505eb.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/readme/nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class AdditionValue
}


new AdditionValue(1, 2).Dump(members: new MembersConfig { IncludeFields = true, IncludeNonPublicMembers = true });
new AdditionValue(1, 2).Dump(members: new MembersConfig { IncludeFields = true, IncludeNonePublicMembers = true });
```
![image](https://user-images.githubusercontent.com/8770486/232252840-c5b0ea4c-eae9-4dc2-bd6c-d42ee58505eb.png)

Expand Down
27 changes: 18 additions & 9 deletions src/Dumpify.Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Dumpify;

using System.Buffers;
using System.Collections;
using System.ComponentModel;
using System.Data;
Expand All @@ -26,14 +26,23 @@

#pragma warning disable CS8321
#pragma warning disable CS0168

void TestSpecific()
{
((nuint)5).Dump();
((nint)5).Dump();
'a'.Dump();
Enumerable.Range(0, 10).Select(i => (char)(i + 'a')).Dump();
Enumerable.Range(0, 10).Select(i => (char)(i + 'a')).ToArray().Dump();
"this is a string".Dump();
var moaid = new Person { FirstName = "Moaid", LastName = "Hathot", Profession = Profession.Software };
var moaid2 = new Person { FirstName = "Moaid", LastName = "Hathot", Profession = Profession.Software };

Person[] arr = [moaid, moaid];
arr.Dump();

//var value = SearchValues.Create("a");
//value.Dump();
// ((nuint)5).Dump();
// ((nint)5).Dump();
//'a'.Dump(typeNames: new TypeNamingConfig { });
// Enumerable.Range(0, 10).Select(i => (char)(i + 'a')).Dump();
// Enumerable.Range(0, 10).Select(i => (char)(i + 'a')).ToArray().Dump();
// "this is a string".Dump();
//new TestVirtual().Dump();
// DumpConfig.Default.TypeRenderingConfig.StringQuotationChar = '`';
//
Expand Down Expand Up @@ -405,8 +414,8 @@ void ShowEverything()

new Exception("This is an exception", new ArgumentNullException("blaParam", "This is inner exception")).Dump();

new AdditionValue(1, 10).Dump(members: new() { IncludeFields = true, IncludeNonPublicMembers = true, IncludeProperties = false });
new AdditionValue(1, 10).Dump(members: new() { IncludeFields = true, IncludeNonPublicMembers = true });
new AdditionValue(1, 10).Dump(members: new() { IncludeFields = true, IncludeNonePublicMembers = true, IncludeProperties = false });
new AdditionValue(1, 10).Dump(members: new() { IncludeFields = true, IncludeNonePublicMembers = true });

//arr.Dump();
//moaid.Dump();
Expand Down
12 changes: 6 additions & 6 deletions src/Dumpify/Descriptors/ValueProviders/MemberProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ internal sealed record MemberProvider : IMemberProvider
private readonly bool _includeProperties;
private readonly bool _includeFields;
private readonly bool _includePublicMembers;
private readonly bool _includeNonPublicMembers;
private readonly bool _includeNonePublicMembers;

public MemberProvider()
: this(true, false, true, false)
{

}

public MemberProvider(bool includeProperties, bool includeFields, bool includePublicMembers, bool includeNonPublicMembers)
public MemberProvider(bool includeProperties, bool includeFields, bool includePublicMembers, bool includeNonePublicMembers)
{
_includeProperties = includeProperties;
_includeFields = includeFields;
_includePublicMembers = includePublicMembers;
_includeNonPublicMembers = includeNonPublicMembers;
_includeNonePublicMembers = includeNonePublicMembers;
}

public IEnumerable<IValueProvider> GetMembers(Type type)
{
var flags = BindingFlags.Instance;

flags |= _includePublicMembers ? BindingFlags.Public : BindingFlags.Default;
flags |= _includeNonPublicMembers ? BindingFlags.NonPublic : BindingFlags.Default;
flags |= _includeNonePublicMembers ? BindingFlags.NonPublic : BindingFlags.Default;

var members = Enumerable.Empty<IValueProvider>();

Expand Down Expand Up @@ -60,9 +60,9 @@ public bool Equals(IMemberProvider? provider)
return false;
}

return _includeProperties == other._includeProperties && _includeFields == other._includeFields && _includePublicMembers == other._includePublicMembers && _includeNonPublicMembers == other._includeNonPublicMembers;
return _includeProperties == other._includeProperties && _includeFields == other._includeFields && _includePublicMembers == other._includePublicMembers && _includeNonePublicMembers == other._includeNonePublicMembers;
}

public override int GetHashCode()
=> (_includeProperties, _includeFields, _includePublicMembers, _includeNonPublicMembers).GetHashCode();
=> (_includeProperties, _includeFields, _includePublicMembers, _includeNonePublicMembers).GetHashCode();
}

0 comments on commit eb40478

Please sign in to comment.