Comments (7)
I spent some time thinking about this. It seems to me like the most tricky case is a virtual get-set property on an existing subtype. For example, the Request.Uri property. It seems to me that we can make everything work correctly, if we: a) have just ome source of truth (a filed in the subclass), b) seal Core property/methods in the subclass. For example:
public abstract class PipelineRequest
{
public Uri Uri {
get => UriCore;
set => UriCore = value;
}
protected abstract Uri UriCore { get; set; }
}
public abstract class Request : PipelineRequest
{
RequestUriBuilder? _uri;
public new virtual RequestUriBuilder Uri {
get => _uri ??= new RequestUriBuilder();
set => _uri = value;
}
protected sealed override Uri UriCore {
get => Uri.ToUri();
set => Uri.Reset(value);
}
}
public class RequestUriBuilder
{
public Uri ToUri() => throw new NotImplementedException();
public void Reset(Uri value) => throw new NotImplementedException();
}
from azure-sdk-for-net.
In the case of get-only properties (e.g. Response.Content) where the type of the property does not change in the subclass, we should do what the notes say, i.e. make the property virtual.
In the case of get-only properties (e.g. Response.Content) where the type of the property does change in the subclass, we should do what the notes say, i.e. use protected Core method.
from azure-sdk-for-net.
Let's implement the combinations of the recommendations (from the table) and the one I added for get-set properties (Request.Uri). Hopefully these will cover all the cases. if you run into another case that is not discussed in the issue, let me know
from azure-sdk-for-net.
- We will change the GetXxCore and SetXxCore methods on PipelineRequest and PipelineResponse to XxCore properties.
- Unfortunately, I don't think we are able to seal the XxCore properties as described above, because of the way we use adapters for ClientModel-internal types in the Azure.Core integration. However, since the XxCore methods are new, no one is currently overriding them in a subtype. Since it would be quite advanced to provide derived types of Azure.Core Request and Response, I think we are safe to say that if you override one of the XxCore methods and make it not call through to the template property (the Xx property itself), this is a bug due to not following intended usage patterns. I would prefer if we could have the compiler enforce this for us, but I think this would require making request and response transport implementations in ClientModel public, and I don't think that would be a good trade-off.
from azure-sdk-for-net.
Could you link to adapter code that illustrates how the adapter overrides (or has to override) the UriCore property?
from azure-sdk-for-net.
Could you link to adapter code that illustrates how the adapter overrides (or has to override) the UriCore property?
I put a simplification of the problem as I understand it in this gist:
The adapter implementation in the Azure.Core 2.0 integration PR branch is here:
- Azure.Core Request newslots Uri
- Azure.Core Request overrides UriCore -- calling through to the virtual public property on Request
- Azure.Core internal Request sutype HttpClientTransportRequest UriCore implementation -- the internal implementation must keep the RequestUriBuilder property on the Azure.Core Request and the Uri property on the ClientModel pipeline request in sync with each other so the same value for Uri is available in both the Azure.Core type and the ClientModel type.
from azure-sdk-for-net.
Completed with #42010
from azure-sdk-for-net.
Related Issues (20)
- [BUG] Service Bus is not annotated for nullability HOT 5
- Support role assignment
- [QUERY] Get the Url of a Search Service HOT 5
- Decide whether or not env vars should be supported for subscriptionId
- [FEATURE REQ] Support GetMessageSessions HOT 18
- [BUG] async Task<T> is not defined in QueryAsync method in TableClient class HOT 4
- [BUG] Error when upgrading Azure.Extensions.AspNetCore.DataProtection.Keys HOT 3
- [QUERY] How to authenticate as a specific user assigned managed identity with a client secret. HOT 6
- Support anonymous resource group bicep
- [BUG] Enabling Embedded web view for InteractiveBrowserCredential causes runtime exception on some machines HOT 3
- Users can batch multiple `ChatRequestUserMessage`s into a single request and receive multiple corresponding `ChatCompletion`s HOT 2
- Support gluing infrastructures together HOT 1
- No clear indication of class attributes for DocumentField class HOT 1
- [QUERY] Initializes EventGridEvent object HOT 2
- [QUERY] Missing documentation and sample use of GetUsagesCollections HOT 4
- [QUERY] Canadian Personal Health Numbers not being detected by Text Analytics RecognizePiiEntitiesAsync method HOT 1
- Azure.Core: Optimize RequestContent.Create from IPersistableModel<T>
- [BUG] Microsoft.Azure.Functions.Worker.Extensions.ServiceBus generates references to NuGet packages with known vulnerablities HOT 1
- [FEATURE REQ] Add option to opt out of Check Pointing
- [FEATURE REQ] When in prompt mode, Infrastructure pre-adds `param location string = resourceGroup().location`. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-net.