Skip to main content
deleted 1 character in body
Source Link
t3chb0t
  • 44.7k
  • 9
  • 85
  • 191

I find it is not obvious to the user what happens when he sets the HttpContent and that he needs to actually wait while setting it.

I prefer to have a method like

public async Task<string> GetSerializedHttpContent()
{
    return _httpContent.ReadAsStringAsync();
}

reather a property that does more then I might actually need. What if I never use thenthe _httpContentSerialized but need the HttpContent for other purposes? You might say that you use it but hay, the example contains only a single property so we can only guess about its real usage and the backing field. Nevertheless, it should not do any work but setting a field.

I find it is not obvious to the user what happens when he sets the HttpContent and that he needs to actually wait while setting it.

I prefer to have a method like

public async Task<string> GetSerializedHttpContent()
{
    return _httpContent.ReadAsStringAsync();
}

reather a property that does more then I might actually need. What if I never use then _httpContentSerialized but need the HttpContent for other purposes? You might say that you use it but hay, the example contains only a single property so we can only guess about its real usage and the backing field. Nevertheless, it should not do any work but setting a field.

I find it is not obvious to the user what happens when he sets the HttpContent and that he needs to actually wait while setting it.

I prefer to have a method like

public async Task<string> GetSerializedHttpContent()
{
    return _httpContent.ReadAsStringAsync();
}

reather a property that does more then I might actually need. What if I never use the _httpContentSerialized but need the HttpContent for other purposes? You might say that you use it but hay, the example contains only a single property so we can only guess about its real usage and the backing field. Nevertheless, it should not do any work but setting a field.

Source Link
t3chb0t
  • 44.7k
  • 9
  • 85
  • 191

I find it is not obvious to the user what happens when he sets the HttpContent and that he needs to actually wait while setting it.

I prefer to have a method like

public async Task<string> GetSerializedHttpContent()
{
    return _httpContent.ReadAsStringAsync();
}

reather a property that does more then I might actually need. What if I never use then _httpContentSerialized but need the HttpContent for other purposes? You might say that you use it but hay, the example contains only a single property so we can only guess about its real usage and the backing field. Nevertheless, it should not do any work but setting a field.