Skip to content

Format BreakingChange Output Messages in Common Repo #210

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

Merged
merged 12 commits into from
Sep 2, 2020
10 changes: 7 additions & 3 deletions src/Common/CustomAttributes/BreakingChangeAttributeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ public static void ProcessCustomAttributesAtRuntime(Type type, InvocationInfo in
}

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

if (attributes != null && attributes.Count > 0)
{
writeOutput(string.Format(Resources.BreakingChangesAttributesHeaderMessage, Utilities.GetNameFromCmdletType(type)));
appendBreakingChangeInfo(string.Format(Resources.BreakingChangesAttributesHeaderMessage, Utilities.GetNameFromCmdletType(type)));

foreach (GenericBreakingChangeAttribute attribute in attributes)
{
attribute.PrintCustomAttributeInfo(type, false, writeOutput);
attribute.PrintCustomAttributeInfo(type, false, appendBreakingChangeInfo);
}

writeOutput(string.Format(Resources.BreakingChangesAttributesFooterMessage, BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK));
appendBreakingChangeInfo(string.Format(Resources.BreakingChangesAttributesFooterMessage, BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK));

writeOutput(sb.ToString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override string GetAttributeSpecificMessage()
//See if the type of the param is changing
if (OldParamaterType != null && !string.IsNullOrWhiteSpace(NewParameterTypeName))
{
message.Append("\n" + string.Format(Resources.BreakingChangeAttributeParameterTypeChange, OldParamaterType.FullName, NewParameterTypeName));
message.Append(string.Format(Resources.BreakingChangeAttributeParameterTypeChange, OldParamaterType.FullName, NewParameterTypeName));
}
return message.ToString();
}
Expand Down
4 changes: 4 additions & 0 deletions src/Common/CustomAttributes/GenericBreakingChangeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public string GetBreakingChangeTextFromAttribute(Type type, bool withCmdletName)
public void PrintCustomAttributeInfo(Type type, bool withCmdletName, Action<string> writeOutput)
{
if (!withCmdletName) {
if (!GetAttributeSpecificMessage().StartsWith(Environment.NewLine))
{
writeOutput(Environment.NewLine);
}
writeOutput(string.Format(Resources.BreakingChangesAttributesDeclarationMessage, GetAttributeSpecificMessage()));
} else
{
Expand Down
68 changes: 36 additions & 32 deletions src/Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1644,20 +1644,24 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
<comment>0(string): methodType</comment>
</data>
<data name="BreakingChangeAttributeParameterChanging" xml:space="preserve">
<value>The parameter : '{0}' is changing.</value>
<value>
- The parameter : '{0}' is changing.</value>
</data>
<data name="BreakingChangeAttributeParameterMandatoryNow" xml:space="preserve">
<value>The parameter : '{0}' is becoming mandatory.</value>
<value>
- The parameter : '{0}' is becoming mandatory.</value>
</data>
<data name="BreakingChangeAttributeParameterReplaced" xml:space="preserve">
<value>The parameter : '{0}' is being replaced by parameter : '{1}'.</value>
<value>
- The parameter : '{0}' is being replaced by parameter : '{1}'.</value>
</data>
<data name="BreakingChangeAttributeParameterReplacedMandatory" xml:space="preserve">
<value>The parameter : '{0}' is being replaced by mandatory parameter : '{1}'.</value>
<value>
- The parameter : '{0}' is being replaced by mandatory parameter : '{1}'.</value>
</data>
<data name="BreakingChangesAttributesChangeDescriptionMessage" xml:space="preserve">
<value> Change description : {0}
</value>
<value>
- Change description : {0} </value>
</data>
<data name="BreakingChangesAttributesCmdLetDeprecationMessageNoReplacement" xml:space="preserve">
<value>The cmdlet is being deprecated. There will be no replacement for it.</value>
Expand All @@ -1666,42 +1670,39 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
<value>The cmdlet '{0}' is replacing this cmdlet.</value>
</data>
<data name="BreakingChangesAttributesCmdLetOutputChange1" xml:space="preserve">
<value>The output type is changing from the existing type :'{0}' to the new type :'{1}'</value>
<value>
- The output type is changing from the existing type :'{0}' to the new type :'{1}'</value>
</data>
<data name="BreakingChangesAttributesCmdLetOutputChange2" xml:space="preserve">
<value>"The output type '{0}' is changing"</value>
<value>
- The output type '{0}' is changing</value>
</data>
<data name="BreakingChangesAttributesCmdLetOutputPropertiesAdded" xml:space="preserve">
<value>
- The following properties are being added to the output type :
</value>
- The following properties are being added to the output type :</value>
</data>
<data name="BreakingChangesAttributesCmdLetOutputPropertiesRemoved" xml:space="preserve">
<value>
- The following properties in the output type are being deprecated :
</value>
- The following properties in the output type are being deprecated :</value>
</data>
<data name="BreakingChangesAttributesDeclarationMessage" xml:space="preserve">
<value> - {0}

</value>
<value>{0}</value>
</data>
<data name="BreakingChangesAttributesDeclarationMessageWithCmdletName" xml:space="preserve">
<value> - Cmdlet : '{0}'
- {1}
</value>
<value>
- Cmdlet : '{0}'
- {1}</value>
</data>
<data name="BreakingChangesAttributesHeaderMessage" xml:space="preserve">
<value>Breaking changes in the cmdlet '{0}' :</value>
<value>Upcoming breaking changes in the cmdlet '{0}' :</value>
</data>
<data name="BreakingChangesAttributesInEffectByDateMessage" xml:space="preserve">
<value> Note : This change will take effect on '{0}'
</value>
<value>
- This change will take effect on '{0}'</value>
</data>
<data name="BreakingChangesAttributesInEffectByVersion" xml:space="preserve">
<value>Note :The change is expected to take effect from the version : '{0}'

</value>
<value>
- The change is expected to take effect from the version : '{0}'</value>
</data>
<data name="BreakingChangesAttributesUsageChangeMessage" xml:space="preserve">
<value>```powershell
Expand All @@ -1711,24 +1712,27 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
# New
{1}
```

</value>
</data>
<data name="BreakingChangesAttributesUsageChangeMessageConsole" xml:space="preserve">
<value>Cmdlet invocation changes :
Old Way : {0}
New Way : {1}</value>
<value>
Cmdlet invocation changes :
Old Way : {0}
New Way : {1}</value>
</data>
<data name="BreakingChangesAttributesCmdLetOutputTypeDeprecated" xml:space="preserve">
<value>The output type '{0}' is being deprecated without a replacement.</value>
<value>
The output type '{0}' is being deprecated without a replacement.</value>
</data>
<data name="BreakingChangeAttributeParameterTypeChange" xml:space="preserve">
<value> The type of the parameter is changing from '{0}' to '{1}'.</value>
<value>
The type of the parameter is changing from '{0}' to '{1}'.</value>
</data>
<data name="BreakingChangesAttributesFooterMessage" xml:space="preserve">
<value>NOTE : Go to {0} for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.</value>
<value>
Note : Go to {0} for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.</value>
</data>
<data name="PreviewCmdletMessage" xml:space="preserve">
<value>This cmdlet is in preview. The functionality may not be available in the selected subscription.</value>
</data>
</root>
</root>