Skip to content

Commit 3d75c4a

Browse files
committed
Change the default warning message of CmdletPreviewAttribute and allow setting ETA
1 parent dfe6dba commit 3d75c4a

File tree

5 files changed

+540
-505
lines changed

5 files changed

+540
-505
lines changed

src/Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private void WriteBreakingChangeOrPreviewMessage()
378378
&& configManager.GetConfigValue<bool>(ConfigKeysForCommon.DisplayBreakingChangeWarning))
379379
{
380380
BreakingChangeAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteWarning);
381-
PreviewAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteDebug);
381+
PreviewAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteWarning);
382382
}
383383
}
384384

src/Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<ItemGroup>
4343
<Compile Update="Properties\Resources.Designer.cs">
44-
<DesignTime>true</DesignTime>
44+
<DesignTime>True</DesignTime>
4545
<AutoGen>true</AutoGen>
4646
<DependentUpon>Resources.resx</DependentUpon>
4747
</Compile>

src/Common/CustomAttributes/CmdletPreviewAttribute.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.WindowsAzure.Commands.Common.Properties;
1616
using System;
17+
using System.Globalization;
1718
using System.Management.Automation;
1819

1920
namespace Microsoft.WindowsAzure.Commands.Common.CustomAttributes
@@ -25,6 +26,10 @@ public class CmdletPreviewAttribute : System.Attribute
2526
{
2627
public string _message;
2728

29+
public DateTime EstimatedGaDate { get; }
30+
31+
public bool IsEstimatedGaDateSet { get; } = false;
32+
2833
public CmdletPreviewAttribute()
2934
{
3035
this._message = Resources.PreviewCmdletMessage;
@@ -35,9 +40,27 @@ public CmdletPreviewAttribute(string message)
3540
this._message = message;
3641
}
3742

43+
44+
public CmdletPreviewAttribute(string message, string estimatedDateOfGa)
45+
{
46+
this._message = message;
47+
48+
49+
if (DateTime.TryParse(estimatedDateOfGa, new CultureInfo("en-US"), DateTimeStyles.None, out DateTime result))
50+
{
51+
this.EstimatedGaDate = result;
52+
this.IsEstimatedGaDateSet = true;
53+
}
54+
55+
}
56+
3857
public void PrintCustomAttributeInfo(Action<string> writeOutput)
3958
{
4059
writeOutput(this._message);
60+
if (IsEstimatedGaDateSet)
61+
{
62+
writeOutput(string.Format(Resources.PreviewCmdletETAMessage, this.EstimatedGaDate));
63+
}
4164
}
4265

4366
public virtual bool IsApplicableToInvocation(InvocationInfo invocation)

0 commit comments

Comments
 (0)