Skip to content
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

Add a common definition for sub-resource #20524

Merged
merged 3 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace Azure.ResourceManager.Core
/// <typeparam name="TOperations"> The type of the class containing operations for the underlying resource. </typeparam>
/// <typeparam name="TResource"> The type of the class containing properties for the underlying resource. </typeparam>
public abstract class ResourceContainerBase<TIdentifier, TOperations, TResource> : ContainerBase<TIdentifier, TOperations>
where TOperations : ResourceOperationsBase<TIdentifier, TOperations>
where TResource : Resource<TIdentifier>
where TIdentifier : TenantResourceIdentifier
where TOperations : ResourceOperationsBase<TIdentifier, TOperations>
where TResource : class
{
private static readonly object _parentLock = new object();
private object _parentResource;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.ResourceManager.Core
{
/// <summary>
/// A class representing a sub-resource that contains only the ID.
/// </summary>
[ReferenceType]
public abstract class SubResource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing corresponding SubResource.Serialization.cs file to serialize / deserialize this class

{
/// <summary>
/// ARM resource identifier.
/// </summary>
/// <value></value>
public virtual ResourceIdentifier Id { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be get only with a protected constructor that takes in the id and sets it.

This is for deserialization scenarios

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put a todo in this file for us to consider how to make SubResource/SubResourceReadOnly to follow the current pattern (in Resource and TrackedResource) that the read-only one should be the default.
And I added serilization code. Thanks for the comments!

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.ResourceManager.Core
{
/// <summary>
/// A class representing a sub-resource that contains only the read-only ID.
/// </summary>
[ReferenceType]
public abstract class SubResourceReadOnly
{
/// <summary>
/// ARM resource identifier (read-only).
/// </summary>
/// <value></value>
public virtual ResourceIdentifier Id { get; }
}
}