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

IField.Is bug? #7

Closed
gdarussian opened this issue Apr 20, 2017 · 5 comments
Closed

IField.Is bug? #7

gdarussian opened this issue Apr 20, 2017 · 5 comments

Comments

@gdarussian
Copy link

Based on usage of the FieldOptions enum (e.g. in default resolver creator), it seems like IField.Is should return true if options == None, but it does not. Either need to add a check for None or make None 0xff instead of 0.

@gdarussian
Copy link
Author

Actually both of those ways seem to have other issues. What works for me is making the default be Serializable | Deserializable

@cosullivan
Copy link
Owner

Hi @gdarussian,

Are you able to send me an example of where you are seeing the issue?

Thanks,
Cain

@gdarussian
Copy link
Author

gdarussian commented Apr 20, 2017

        private static async Task<List<FteRequirements>> readAsync()
        {
            ResourceInflector.KnownPlurals.Add("fterequirements", "fterequirements");
            var strData = "{\"data\":[{\"type\":\"fterequirements\",\"id\":\"-1\",\"attributes\":{\"queueID\":1921,\"seriesValues\":[0.0,0.0,7.0,7.0,7.0,7.0,7.0,7.0],\"endDate\":\"2014-09-14T07:00:00.000Z\",\"id\":-1,\"startDate\":\"2014-08-31T07:00:00.000Z\"},\"links\":{\"self\":\"http://localhost:7001/json-api/fterequirements/-1\"}}],\"included\":[]}";
            var httpContent = new ByteArrayContent(strData.Select(c => (byte)c).ToArray());
            var data = await httpContent.ReadAsJsonApiManyAsync<FteRequirements>();
            Debug.Print(data.First().ToString());
            return data;
        }
        public class FteRequirements 
        {
            public int Id { get; set; }
            public int QueueId { get; set; }
            public int[] SeriesValues { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }

            public override string ToString()
            {
                string data = SeriesValues == null ? "(null)" : SeriesValues.Aggregate("", (acc, i) => i + ", " + acc);
                return string.Format("[{0}] SPQ{1}, {2} - {3}: {4}", Id, QueueId, StartDate, EndDate, data);
            }
        }

By default, it shows all default fields. Changing RuntimeField.CreateDefaultOptions makes it work:

            var options = FieldOptions.Serializable | FieldOptions.Deserializable;
            //var options = FieldOptions.None;

@cosullivan
Copy link
Owner

Ok, I think the latest commit should fix it;

Let me know if that works for you?

@gdarussian
Copy link
Author

Looks good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants