I am getting a below warning in visual studio 2022 for line (T)ser.Deserialize(sr) in the below code.
Warning:
Converting null literal or possible null value to non-nullable type.
Code:
public T Deserialize<T>(string input) where T : class
{
System.Xml.Serialization.XmlSerializer ser = new
System.Xml.Serialization.XmlSerializer(typeof(T));
using (StringReader sr = new StringReader(input))
{
return (T)ser.Deserialize(sr);
}
}
Is there a way to get rid of this warning?