When evolving APIs, maintain backward compatibility to prevent breaking changes for existing consumers. Key approaches: 1. **Retain removed members with obsolete attributes**: When removing or replacing public methods, mark the original as obsolete but maintain its functionality.
When evolving APIs, maintain backward compatibility to prevent breaking changes for existing consumers.
Key approaches:
// Old method
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Use UpdateAsync(WaitUntil, ConnectorPatch) instead")]
public virtual Response<ConnectorResource> Update(ConnectorPatch patch,
CancellationToken cancellationToken = default)
{
// Call the new implementation
return UpdateAsync(WaitUntil.Completed, patch, cancellationToken).EnsureCompleted();
}
// New method
public virtual ArmOperation<ConnectorResource> Update(WaitUntil waitUntil,
ConnectorPatch patch, CancellationToken cancellationToken = default)
// Old constructor required publisherId
public MarketplaceDetails(string planId, string offerId, string publisherId)
: this(planId, offerId)
{
PublisherId = publisherId;
}
// New constructor makes publisherId optional
public MarketplaceDetails(string planId, string offerId) { }
[CodeGenSerialization(nameof(BlockResponseCode), "blockResponseCode")]
public partial class DnsSecurityRuleAction
{
[EditorBrowsable(EditorBrowsableState.Never)]
public BlockResponseCode? BlockResponseCode { get; set; }
}
These approaches ensure that existing code continues to work while allowing APIs to evolve with improved designs.
Enter the URL of a public GitHub repository