cosullivan/Hypermedia

IField.Is bug?

Closed this issue · 5 comments

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.

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

Hi @gdarussian,

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

Thanks,
Cain

        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;

Ok, I think the latest commit should fix it;

Let me know if that works for you?

Looks good, thanks.