Skip to content

Commit

Permalink
Make the Reference type generic (#20358)
Browse files Browse the repository at this point in the history
* Change the accessbility to virtual for Resource.Id

* Make the reference type generic

Co-authored-by: m-nash <prognash@microsoft.com>
Co-authored-by: m-nash <prognash@gmail.com>
  • Loading branch information
3 people authored Apr 13, 2021
1 parent 430b07c commit 5e40926
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,25 @@ namespace Azure.ResourceManager.Core
[AttributeUsage(AttributeTargets.Class)]
public class ReferenceTypeAttribute : Attribute
{
/// <summary>
/// Instatiate a new reference type attribute.
/// </summary>
/// <param name="genericType"> The generic type for this reference type. </param>
public ReferenceTypeAttribute(Type genericType)
{
GenericType = genericType;
}

/// <summary>
/// Instatiate a new reference type attribute.
/// </summary>
public ReferenceTypeAttribute() : this(null)
{
}

/// <summary>
/// Get the generic type for this reference type.
/// </summary>
public Type GenericType { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Azure.ResourceManager.Core
/// <summary>
/// A class representing the base resource used by all azure resources.
/// </summary>
[ReferenceType]
[ReferenceType(typeof(TenantResourceIdentifier))]
public abstract class Resource<TIdentifier> : IEquatable<Resource<TIdentifier>>, IEquatable<string>,
IComparable<Resource<TIdentifier>>, IComparable<string> where TIdentifier : TenantResourceIdentifier
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Azure.ResourceManager.Core
/// <summary>
/// Generic representation of a tracked resource. All tracked resources should extend this class
/// </summary>
[ReferenceType]
[ReferenceType(typeof(TenantResourceIdentifier))]
public abstract partial class TrackedResource<TIdentifier> : Resource<TIdentifier> where TIdentifier : TenantResourceIdentifier
{
private IDictionary<string, string> _tag = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
Expand Down

0 comments on commit 5e40926

Please sign in to comment.