-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive DPG ResponseClassifiers from CoreResponseClassifier #2006
Labels
v3
Version 3 of AutoRest C# generator.
Comments
In addition, we'll want to create the HttpMessage as follows: var message = _pipeline.CreateMessage(context, ResponseClassifier200404.Instance); // passing the appropriate classifier This should work for classifiers that don't derive from |
private static ResponseClassifier _responseClassifier200404;
private static ResponseClassifier ResponseClassifier200404 => _responseClassifier200404 ??= new CoreResponseClassifier(stackalloc int[]{ 200, 404 }); Usage: var message = _pipeline.CreateMessage(context, ResponseClassifier200404); |
private sealed class ResponseClassifierOverride200To300400To500 : ResponseClassifier
{
public override bool IsErrorResponse(HttpMessage message)
{
return message.Response.Status switch
{
>= 200 and < 300 => false,
>= 400 and < 500 => false,
_ => true
};
}
}
private static ResponseClassifier _responseClassifier200To300400To500;
private static ResponseClassifier ResponseClassifier200To300400To500 => _responseClassifier200To300400To500 ??= new ResponseClassifierOverride200To300400To500(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
The DPG implementation of per-operation response classifiers currently derives from the
ResponseClassifier
type. But, the baseResponseClassifier
cannot be directly modified in a way that allows us to efficiently compose a chain ofResponseClassificationHandlers
with aResponseClassifier
at the end of the chain.In PR 26547, we introduced a new
CoreResponseClassifier
type that allows us to both add status code classifiers and evaluate responses against them efficiently.What we'll do
We'll replace the old DPG per-operation ResponseClassifier implementation with the new one (below) deriving from
CoreResponseClassifier
.Old DPG Per-Operation ResponseClassifier
New DPG Per-Operation ResponseClassifier
The text was updated successfully, but these errors were encountered: