Skip to content

Commit b58ba40

Browse files
authored
Format BreakingChange Output Messages(#210)
1 parent 229b9f4 commit b58ba40

File tree

4 files changed

+48
-36
lines changed

4 files changed

+48
-36
lines changed

src/Common/CustomAttributes/BreakingChangeAttributeHelper.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,21 @@ public static void ProcessCustomAttributesAtRuntime(Type type, InvocationInfo in
9898
}
9999

100100
List<GenericBreakingChangeAttribute> attributes = new List<GenericBreakingChangeAttribute>(GetAllBreakingChangeAttributesInType(type, invocationInfo));
101+
StringBuilder sb = new StringBuilder();
102+
Action<string> appendBreakingChangeInfo = (string s) => sb.Append(s);
101103

102104
if (attributes != null && attributes.Count > 0)
103105
{
104-
writeOutput(string.Format(Resources.BreakingChangesAttributesHeaderMessage, Utilities.GetNameFromCmdletType(type)));
106+
appendBreakingChangeInfo(string.Format(Resources.BreakingChangesAttributesHeaderMessage, Utilities.GetNameFromCmdletType(type)));
105107

106108
foreach (GenericBreakingChangeAttribute attribute in attributes)
107109
{
108-
attribute.PrintCustomAttributeInfo(type, false, writeOutput);
110+
attribute.PrintCustomAttributeInfo(type, false, appendBreakingChangeInfo);
109111
}
110112

111-
writeOutput(string.Format(Resources.BreakingChangesAttributesFooterMessage, BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK));
113+
appendBreakingChangeInfo(string.Format(Resources.BreakingChangesAttributesFooterMessage, BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK));
114+
115+
writeOutput(sb.ToString());
112116
}
113117
}
114118

src/Common/CustomAttributes/CmdletParameterBreakingChangeAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override string GetAttributeSpecificMessage()
8383
//See if the type of the param is changing
8484
if (OldParamaterType != null && !string.IsNullOrWhiteSpace(NewParameterTypeName))
8585
{
86-
message.Append("\n" + string.Format(Resources.BreakingChangeAttributeParameterTypeChange, OldParamaterType.FullName, NewParameterTypeName));
86+
message.Append(string.Format(Resources.BreakingChangeAttributeParameterTypeChange, OldParamaterType.FullName, NewParameterTypeName));
8787
}
8888
return message.ToString();
8989
}

src/Common/CustomAttributes/GenericBreakingChangeAttribute.cs

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public string GetBreakingChangeTextFromAttribute(Type type, bool withCmdletName)
129129
public void PrintCustomAttributeInfo(Type type, bool withCmdletName, Action<string> writeOutput)
130130
{
131131
if (!withCmdletName) {
132+
if (!GetAttributeSpecificMessage().StartsWith(Environment.NewLine))
133+
{
134+
writeOutput(Environment.NewLine);
135+
}
132136
writeOutput(string.Format(Resources.BreakingChangesAttributesDeclarationMessage, GetAttributeSpecificMessage()));
133137
} else
134138
{

src/Common/Properties/Resources.resx

+36-32
Original file line numberDiff line numberDiff line change
@@ -1644,20 +1644,24 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
16441644
<comment>0(string): methodType</comment>
16451645
</data>
16461646
<data name="BreakingChangeAttributeParameterChanging" xml:space="preserve">
1647-
<value>The parameter : '{0}' is changing.</value>
1647+
<value>
1648+
- The parameter : '{0}' is changing.</value>
16481649
</data>
16491650
<data name="BreakingChangeAttributeParameterMandatoryNow" xml:space="preserve">
1650-
<value>The parameter : '{0}' is becoming mandatory.</value>
1651+
<value>
1652+
- The parameter : '{0}' is becoming mandatory.</value>
16511653
</data>
16521654
<data name="BreakingChangeAttributeParameterReplaced" xml:space="preserve">
1653-
<value>The parameter : '{0}' is being replaced by parameter : '{1}'.</value>
1655+
<value>
1656+
- The parameter : '{0}' is being replaced by parameter : '{1}'.</value>
16541657
</data>
16551658
<data name="BreakingChangeAttributeParameterReplacedMandatory" xml:space="preserve">
1656-
<value>The parameter : '{0}' is being replaced by mandatory parameter : '{1}'.</value>
1659+
<value>
1660+
- The parameter : '{0}' is being replaced by mandatory parameter : '{1}'.</value>
16571661
</data>
16581662
<data name="BreakingChangesAttributesChangeDescriptionMessage" xml:space="preserve">
1659-
<value> Change description : {0}
1660-
</value>
1663+
<value>
1664+
- Change description : {0} </value>
16611665
</data>
16621666
<data name="BreakingChangesAttributesCmdLetDeprecationMessageNoReplacement" xml:space="preserve">
16631667
<value>The cmdlet is being deprecated. There will be no replacement for it.</value>
@@ -1666,42 +1670,39 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
16661670
<value>The cmdlet '{0}' is replacing this cmdlet.</value>
16671671
</data>
16681672
<data name="BreakingChangesAttributesCmdLetOutputChange1" xml:space="preserve">
1669-
<value>The output type is changing from the existing type :'{0}' to the new type :'{1}'</value>
1673+
<value>
1674+
- The output type is changing from the existing type :'{0}' to the new type :'{1}'</value>
16701675
</data>
16711676
<data name="BreakingChangesAttributesCmdLetOutputChange2" xml:space="preserve">
1672-
<value>"The output type '{0}' is changing"</value>
1677+
<value>
1678+
- The output type '{0}' is changing</value>
16731679
</data>
16741680
<data name="BreakingChangesAttributesCmdLetOutputPropertiesAdded" xml:space="preserve">
16751681
<value>
1676-
- The following properties are being added to the output type :
1677-
</value>
1682+
- The following properties are being added to the output type :</value>
16781683
</data>
16791684
<data name="BreakingChangesAttributesCmdLetOutputPropertiesRemoved" xml:space="preserve">
16801685
<value>
1681-
- The following properties in the output type are being deprecated :
1682-
</value>
1686+
- The following properties in the output type are being deprecated :</value>
16831687
</data>
16841688
<data name="BreakingChangesAttributesDeclarationMessage" xml:space="preserve">
1685-
<value> - {0}
1686-
1687-
</value>
1689+
<value>{0}</value>
16881690
</data>
16891691
<data name="BreakingChangesAttributesDeclarationMessageWithCmdletName" xml:space="preserve">
1690-
<value> - Cmdlet : '{0}'
1691-
- {1}
1692-
</value>
1692+
<value>
1693+
- Cmdlet : '{0}'
1694+
- {1}</value>
16931695
</data>
16941696
<data name="BreakingChangesAttributesHeaderMessage" xml:space="preserve">
1695-
<value>Breaking changes in the cmdlet '{0}' :</value>
1697+
<value>Upcoming breaking changes in the cmdlet '{0}' :</value>
16961698
</data>
16971699
<data name="BreakingChangesAttributesInEffectByDateMessage" xml:space="preserve">
1698-
<value> Note : This change will take effect on '{0}'
1699-
</value>
1700+
<value>
1701+
- This change will take effect on '{0}'</value>
17001702
</data>
17011703
<data name="BreakingChangesAttributesInEffectByVersion" xml:space="preserve">
1702-
<value>Note :The change is expected to take effect from the version : '{0}'
1703-
1704-
</value>
1704+
<value>
1705+
- The change is expected to take effect from the version : '{0}'</value>
17051706
</data>
17061707
<data name="BreakingChangesAttributesUsageChangeMessage" xml:space="preserve">
17071708
<value>```powershell
@@ -1711,24 +1712,27 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
17111712
# New
17121713
{1}
17131714
```
1714-
17151715
</value>
17161716
</data>
17171717
<data name="BreakingChangesAttributesUsageChangeMessageConsole" xml:space="preserve">
1718-
<value>Cmdlet invocation changes :
1719-
Old Way : {0}
1720-
New Way : {1}</value>
1718+
<value>
1719+
Cmdlet invocation changes :
1720+
Old Way : {0}
1721+
New Way : {1}</value>
17211722
</data>
17221723
<data name="BreakingChangesAttributesCmdLetOutputTypeDeprecated" xml:space="preserve">
1723-
<value>The output type '{0}' is being deprecated without a replacement.</value>
1724+
<value>
1725+
The output type '{0}' is being deprecated without a replacement.</value>
17241726
</data>
17251727
<data name="BreakingChangeAttributeParameterTypeChange" xml:space="preserve">
1726-
<value> The type of the parameter is changing from '{0}' to '{1}'.</value>
1728+
<value>
1729+
The type of the parameter is changing from '{0}' to '{1}'.</value>
17271730
</data>
17281731
<data name="BreakingChangesAttributesFooterMessage" xml:space="preserve">
1729-
<value>NOTE : Go to {0} for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.</value>
1732+
<value>
1733+
Note : Go to {0} for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.</value>
17301734
</data>
17311735
<data name="PreviewCmdletMessage" xml:space="preserve">
17321736
<value>This cmdlet is in preview. The functionality may not be available in the selected subscription.</value>
17331737
</data>
1734-
</root>
1738+
</root>

0 commit comments

Comments
 (0)