14
14
15
15
using Microsoft . Azure . Commands . Common . Authentication ;
16
16
using Microsoft . Azure . Commands . Common . Authentication . Abstractions ;
17
+ using Microsoft . Azure . PowerShell . Common . Config ;
17
18
using Microsoft . Azure . PowerShell . Common . Share . Survey ;
18
19
using Microsoft . Azure . ServiceManagement . Common . Models ;
19
20
using Microsoft . WindowsAzure . Commands . Common ;
@@ -65,7 +66,7 @@ protected AzurePSDataCollectionProfile _dataCollectionProfile
65
66
}
66
67
else if ( _cachedProfile == null )
67
68
{
68
- _cachedProfile = new AzurePSDataCollectionProfile ( true ) ;
69
+ _cachedProfile = new AzurePSDataCollectionProfile ( ) ;
69
70
WriteWarning ( DataCollectionWarning ) ;
70
71
}
71
72
@@ -361,8 +362,17 @@ protected override void BeginProcessing()
361
362
362
363
//Now see if the cmdlet has any Breaking change attributes on it and process them if it does
363
364
//This will print any breaking change attribute messages that are applied to the cmdlet
364
- BreakingChangeAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteWarning ) ;
365
- PreviewAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteDebug ) ;
365
+ WriteBreakingChangeOrPreviewMessage ( ) ;
366
+ }
367
+
368
+ private void WriteBreakingChangeOrPreviewMessage ( )
369
+ {
370
+ if ( AzureSession . Instance . TryGetComponent < IConfigManager > ( nameof ( IConfigManager ) , out var configManager )
371
+ && configManager . GetConfigValue < bool > ( ConfigKeysForCommon . DisplayBreakingChangeWarning ) )
372
+ {
373
+ BreakingChangeAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteWarning ) ;
374
+ PreviewAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteDebug ) ;
375
+ }
366
376
}
367
377
368
378
/// <summary>
@@ -451,7 +461,7 @@ protected void WriteSurvey()
451
461
Message = "Open-AzSurveyLink" ,
452
462
NoNewLine = true ,
453
463
} ;
454
- }
464
+ }
455
465
HostInformationMessage action = new HostInformationMessage ( )
456
466
{
457
467
Message = " to fill out a short Survey"
@@ -471,7 +481,11 @@ protected void WriteSurvey()
471
481
_qosEvent . IsSuccess = false ;
472
482
}
473
483
base . WriteError ( errorRecord ) ;
474
- PreviewAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteWarning ) ;
484
+ if ( AzureSession . Instance . TryGetComponent < IConfigManager > ( nameof ( IConfigManager ) , out var configManager )
485
+ && configManager . GetConfigValue < bool > ( ConfigKeysForCommon . DisplayBreakingChangeWarning ) )
486
+ {
487
+ PreviewAttributeHelper . ProcessCustomAttributesAtRuntime ( this . GetType ( ) , this . MyInvocation , WriteWarning ) ;
488
+ }
475
489
}
476
490
477
491
protected new void ThrowTerminatingError ( ErrorRecord errorRecord )
0 commit comments