C#
C#

help

Root Question Message

bobgoblin
bobgoblin11/30/2022
❔ Issue With Code

I have this code
        public T Deserialize<T>(IRestResponse response)
        {
            try
            {
                return JsonConvert.DeserializeObject<T>(response.Content, _settings);
            }
            catch
            {
            }

            return default(T);

        }
and the IRestResponse should resolve to interface IRestResponse but I'm getting an error even tho I have added using RestSharp; What do I need to change/alter so this code works correctly?
Ero
Ero11/30/2022
what error
bobgoblin
bobgoblin11/30/2022
interesting...I was using the most recent Rest Sharp nuget package, I downgraded it to 106.12.0 and the issue is resolved.
bobgoblin
bobgoblin11/30/2022
ohhh, i didn't realize i forgot the error
Ero
Ero11/30/2022
IRestResponse appears to be deprecated
Ero
Ero11/30/2022
The IRestResponse interface is deprecated. You get an instance of RestResponse or RestResponse<T> in return.
bobgoblin
bobgoblin11/30/2022
ah - that would explain it
tebeco
tebeco11/30/2022
i'd rather have a TryDeserialize + out var
tebeco
tebeco11/30/2022
can't trust default
bobgoblin
bobgoblin11/30/2022
lol - certainly not. One of those things to change, but just trying to get this puppy into GitHub atm
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy