-
-
Notifications
You must be signed in to change notification settings - Fork 42
A new JsonConverterOptions attribute for new converter management #97
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
7546d5d
bae9f9c
5aca2ee
3b01bf2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace Newtonsoft.Json.UnityConverters.Tests | ||
{ | ||
public class HiddenConverterTests | ||
{ | ||
[Test] | ||
public void AssertNotRegistered() | ||
{ | ||
var hiddenConverterRegistered = UnityConverterInitializer.defaultUnityConvertersSettings.Converters | ||
.Any(x => x.GetType() == typeof(HiddenConverter)); | ||
|
||
Assert.IsFalse(hiddenConverterRegistered, "HiddenConverter registered, but should not."); | ||
} | ||
|
||
|
||
[HideInJsonConverterSettings] | ||
internal class HiddenConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => false; | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System; | ||
|
||
namespace Newtonsoft.Json.UnityConverters | ||
{ | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | ||
public class HideInJsonConverterSettings : Attribute { } | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a doc comment on this type to explain how it works and why you would use it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try. But I'm not good at English))) Maybe you'll want to do it yourself later. |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure this works, could you also add a converter like
VisibleConverter
that doesn't have the attribute?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy. Just give me a couple of minutes)