question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please add non generic base or interface to Response<T>.

See original GitHub issue

Is your feature request related to a problem? Please describe. I am trying to implement a common way to emit diagnostics data from cosmos response object, however it seems like I cannot do it without reflection.

Describe the solution you’d like If https://github.com/Azure/azure-cosmos-dotnet-v3/blob/c5a5b8836aa8ce2f8d93a863f4abdb2d2818fa5b/Microsoft.Azure.Cosmos/src/Resource/Response.cs had a non generic base with all the properties but Resource, I could cast the response I receive to Response object and access Diagnostics property without needing to use reflection in a generic method that wraps logging of diagnostics. An alternative would be to add an interface like IResponse or something like that.

Describe alternatives you’ve considered I considered alternative code design but none of it solved the situation as simple and straightforward as having non generic Response base class.

Additional context Add any other context or screenshots about the feature request here. I am running a method that takes a Func<TResult> to execute a cosmos request:

TResult result = await func();

In my use case, TResult is always Response<T>. Before I return the result I would like to dump some diagnostics and emit some metrics about usage etc… If the base was not Response<T> but something like IResponse then I could easily do something like this (IResponse)result.Diagnostics to access diagnostics without using reflection.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gouslucommented, Sep 1, 2020

You are right, they are virtual. It seems I was not paying enough attention there, my bad.

0reactions
msftbot[bot]commented, Dec 15, 2021

Closing due to in-activity, pease feel free to re-open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Are there drawbacks to the generic-implementing-non- ...
Actually I thought that my original answer implied that I found the whole solution has a design flaw. In summary, you're using interfaces...
Read more >
Non-generic Wrapper instead of Base Class or Interface
A common solution to treating a generic type as non-generic is to implement an interface or make the generic type extend from a...
Read more >
c# - Is there any advantage using generic type which ...
It is an advantage if you want to create a command processor for a specialized command type. E.g. you have an interface
Read more >
Java Generics Example Tutorial - Generic Method, Class ...
Generics was added in Java 5 to provide compile-time type ... A generic type is a class or interface that is parameterized over...
Read more >
Fun with C# generics: down-casting to a generic type
The problem occurs when we need to manipulate a generic class given a reference to its non-generic base class. For example, if a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found