-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking change attributes with target Az version (#394)
* deprecate methods to ensure version as a must (#383) Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * Hongtu/version must (#384) * deprecate methods to ensure version as a must * add GetAttributeSpecificVersion method in base breaking change attribute --------- Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * Hongtu/version must (#386) * deprecate methods to ensure version as a must * add GetAttributeSpecificVersion method in base breaking change attribute * change parameter type from string to Version --------- Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * create new attributes with version instead of modifying existing attributes * add resource of BreakingChangesAttributesInEffectByAzVersion * Hongtu/attribute0518 (#387) * Update Newtonsoft.Json from 10.0.3 to 13.0.2 (#385) * create new attributes with version instead of modifying existing attributes * add resource of BreakingChangesAttributesInEffectByAzVersion --------- Co-authored-by: Yeming Liu <[email protected]> Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * change internal to public * remove az version to string * Hongtu/attribute0518 (#388) * Update Newtonsoft.Json from 10.0.3 to 13.0.2 (#385) * create new attributes with version instead of modifying existing attributes * add resource of BreakingChangesAttributesInEffectByAzVersion * change internal to public * remove az version to string --------- Co-authored-by: Yeming Liu <[email protected]> Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * change internal to public * Hongtu/attribute0518 (#389) * Update Newtonsoft.Json from 10.0.3 to 13.0.2 (#385) * create new attributes with version instead of modifying existing attributes * add resource of BreakingChangesAttributesInEffectByAzVersion * change internal to public * remove az version to string * change internal to public --------- Co-authored-by: Yeming Liu <[email protected]> Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * add az version output when cmdlets are obsolate * Hongtu/attribute0518 (#391) * Update Newtonsoft.Json from 10.0.3 to 13.0.2 (#385) * create new attributes with version instead of modifying existing attributes * add resource of BreakingChangesAttributesInEffectByAzVersion * change internal to public * remove az version to string * change internal to public * add az version output when cmdlets are obsolate --------- Co-authored-by: Yeming Liu <[email protected]> Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> * add \n to terminal warning output of az version * change resources.resx * change back common.csproj * change to public resources * change generic * remove azversion from old attribute * change obsolete to class level * add comments --------- Co-authored-by: xtR0d666 <[email protected]> Co-authored-by: Hongtu Zhang (FA Talent) <[email protected]> Co-authored-by: Yeming Liu <[email protected]>
- Loading branch information
1 parent
8b55763
commit 210dd3d
Showing
11 changed files
with
499 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Common/CustomAttributes/CmdletDeprecationWithVersionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.WindowsAzure.Commands.Common.Properties; | ||
using System; | ||
|
||
namespace Microsoft.WindowsAzure.Commands.Common.CustomAttributes | ||
{ | ||
/// <summary> | ||
/// This attribute is used to mark cmdlets as deprecated. It provides information about the breaking change, including change description, the version from which the change is deprecated (DeprecateByVersion), the Azure version from which the change is deprecated (DeprecateByAzVersion). This class provides functionality to generate breaking change messages and display information about the breaking changes when needed. | ||
/// </summary> | ||
[AttributeUsage( | ||
AttributeTargets.Class, | ||
AllowMultiple = true)] | ||
public class CmdletDeprecationWithVersionAttribute : GenericBreakingChangeWithVersionAttribute | ||
{ | ||
public string ReplacementCmdletName { get; set; } | ||
|
||
public CmdletDeprecationWithVersionAttribute(string deprecateByAzVersion, string deprecateByVersion) : | ||
base(string.Empty, deprecateByAzVersion, deprecateByVersion) | ||
{ | ||
} | ||
|
||
public CmdletDeprecationWithVersionAttribute(string deprecateByAzVersion, string deprecateByVersion, string changeInEffectByDate) : | ||
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEffectByDate) | ||
{ | ||
} | ||
|
||
protected override string GetAttributeSpecificMessage() | ||
{ | ||
if (string.IsNullOrWhiteSpace(ReplacementCmdletName)) | ||
{ | ||
return Resources.BreakingChangesAttributesCmdLetDeprecationMessageNoReplacement; | ||
} | ||
else | ||
{ | ||
return string.Format(Resources.BreakingChangesAttributesCmdLetDeprecationMessageWithReplacement, ReplacementCmdletName); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/Common/CustomAttributes/CmdletOutputBreakingChangeWithVersionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.WindowsAzure.Commands.Common.Properties; | ||
using System; | ||
using System.Text; | ||
|
||
namespace Microsoft.WindowsAzure.Commands.Common.CustomAttributes | ||
{ | ||
/// <summary> | ||
/// This attribute is used to mark cmdlets output type has breaking changes. It provides information about the breaking change, including change description, the version from which the change is deprecated (DeprecateByVersion), the Azure version from which the change is deprecated (DeprecateByAzVersion). This class provides functionality to generate breaking change messages and display information about the breaking changes when needed. | ||
/// </summary> | ||
[AttributeUsage( | ||
AttributeTargets.Class, | ||
AllowMultiple = true)] | ||
public class CmdletOutputBreakingChangeWithVersionAttribute : GenericBreakingChangeWithVersionAttribute | ||
{ | ||
public Type DeprecatedCmdLetOutputType { get; } | ||
|
||
//This is still a String instead of a Type as this | ||
//might be undefined at the time of adding the attribute | ||
public string ReplacementCmdletOutputTypeName { get; set; } | ||
|
||
public string[] DeprecatedOutputProperties { get; set; } | ||
|
||
public string[] NewOutputProperties { get; set; } | ||
|
||
|
||
public CmdletOutputBreakingChangeWithVersionAttribute(Type deprecatedCmdletOutputTypeName, string deprecateByAzVersion, string deprecateByVersion) : | ||
base(string.Empty, deprecateByAzVersion, deprecateByVersion) | ||
{ | ||
this.DeprecatedCmdLetOutputType = deprecatedCmdletOutputTypeName; | ||
} | ||
|
||
public CmdletOutputBreakingChangeWithVersionAttribute(Type deprecatedCmdletOutputTypeName, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate) : | ||
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEfectByDate) | ||
{ | ||
this.DeprecatedCmdLetOutputType = deprecatedCmdletOutputTypeName; | ||
} | ||
|
||
protected override string GetAttributeSpecificMessage() | ||
{ | ||
StringBuilder message = new StringBuilder(); | ||
|
||
//check for the deprecation scenario | ||
if (string.IsNullOrWhiteSpace(ReplacementCmdletOutputTypeName) && NewOutputProperties == null && DeprecatedOutputProperties == null && string.IsNullOrWhiteSpace(ChangeDescription)) | ||
{ | ||
message.Append(string.Format(Resources.BreakingChangesAttributesCmdLetOutputTypeDeprecated, DeprecatedCmdLetOutputType.FullName)); | ||
} | ||
else | ||
{ | ||
if (!string.IsNullOrWhiteSpace(ReplacementCmdletOutputTypeName)) | ||
{ | ||
message.Append(string.Format(Resources.BreakingChangesAttributesCmdLetOutputChange1, DeprecatedCmdLetOutputType.FullName, ReplacementCmdletOutputTypeName)); | ||
} | ||
else | ||
{ | ||
message.Append(string.Format(Resources.BreakingChangesAttributesCmdLetOutputChange2, DeprecatedCmdLetOutputType.FullName)); | ||
} | ||
|
||
if (DeprecatedOutputProperties != null && DeprecatedOutputProperties.Length > 0) | ||
{ | ||
message.Append(Resources.BreakingChangesAttributesCmdLetOutputPropertiesRemoved); | ||
foreach (string property in DeprecatedOutputProperties) | ||
{ | ||
message.Append(" '" + property + "'"); | ||
} | ||
} | ||
|
||
if (NewOutputProperties != null && NewOutputProperties.Length > 0) | ||
{ | ||
message.Append(Resources.BreakingChangesAttributesCmdLetOutputPropertiesAdded); | ||
foreach (string property in NewOutputProperties) | ||
{ | ||
message.Append(" '" + property + "'"); | ||
} | ||
} | ||
} | ||
return message.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.