CP-36392: Use value in empty setters

Mostly to remove warning from SonarQube, so exception is only thrown in DEBUG mode

Address code surrounding previously emptied setters
Avoids throwing exceptions when not needed
Move default `VerticalTabs` fields outside of constructor

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2022-01-24 10:07:10 +00:00 committed by Konstantina Chremmou
parent 2c5373323c
commit 101d6f0a00
5 changed files with 38 additions and 23 deletions

View File

@ -33,6 +33,7 @@ using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Reflection;
using XenAdmin.Core;
@ -46,24 +47,13 @@ namespace XenAdmin.Controls
string SubText { get; }
Image Image { get; }
}
public VerticalTabs()
{
base.ItemHeight = 40;
IntegralHeight = false;
DrawMode = DrawMode.OwnerDrawFixed;
IntegralHeight = false;
}
public override int ItemHeight
{
get
{
return base.ItemHeight;
}
set
{
}
}
public override int ItemHeight => 40;
public override DrawMode DrawMode => DrawMode.OwnerDrawFixed;
public Func<Rectangle, Rectangle> AdjustItemTextBounds;

View File

@ -222,8 +222,7 @@ namespace XenAdmin.Wizards
xenTabPageLvmoHbaSummary.SuccessfullyCreatedSRs.Clear();
xenTabPageLvmoHbaSummary.FailedToCreateSRs.Clear();
bool closeWizard;
RunFinalAction(out closeWizard);
RunFinalAction(out var closeWizard);
return closeWizard;
}

View File

@ -105,7 +105,13 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
{
var frontend = (SrWizardType)radioButton.Tag;
frontend.ResetSrName(Connection);
frontend.AllowToCreateNewSr = SrToReattach == null && !DisasterRecoveryTask;
// these SR types have a blocked setter
if (!(frontend is SrWizardType_Cslg || frontend is SrWizardType_CifsIso || frontend is SrWizardType_NfsIso || frontend is SrWizardType_Cifs))
{
frontend.AllowToCreateNewSr = SrToReattach == null && !DisasterRecoveryTask;
}
frontend.DisasterRecoveryTask = DisasterRecoveryTask;
frontend.SrToReattach = SrToReattach;
}

View File

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using XenAdmin.Actions;
using XenAdmin.Core;
using XenAdmin.Network;
@ -157,7 +158,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
public abstract bool ShowIntroducePrompt { get; }
public abstract bool ShowReattachWarning { get; }
public abstract bool AllowToCreateNewSr { get; set; }
public virtual bool IsGfs2 { get { return false; } set { } }
public virtual bool IsGfs2 {
get => false;
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public string SrName
{
@ -256,7 +260,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
public override string ContentType { get { return SR.Content_Type_ISO; } }
public override bool ShowIntroducePrompt { get { return false; } }
public override bool ShowReattachWarning { get { return false; } }
public override bool AllowToCreateNewSr { get { return true; } set { } }
public override bool AllowToCreateNewSr
{
get => true;
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public override void ResetSrName(IXenConnection connection)
{
@ -340,7 +348,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
public override string ContentType { get { return SR.Content_Type_ISO; } }
public override bool ShowIntroducePrompt { get { return false; } }
public override bool ShowReattachWarning { get { return false; } }
public override bool AllowToCreateNewSr { get { return true; } set { } }
public override bool AllowToCreateNewSr
{
get => true;
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public override void ResetSrName(IXenConnection connection)
{
@ -362,7 +374,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
public override string ContentType { get { return ""; } }
public override bool ShowIntroducePrompt { get { return false; } }
public override bool ShowReattachWarning { get { return false; } }
public override bool AllowToCreateNewSr { get { return true; } set { } }
public override bool AllowToCreateNewSr {
get => true;
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public override void ResetSrName(IXenConnection connection)
{
@ -379,7 +394,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
public override string ContentType { get { return ""; } }
public override bool ShowIntroducePrompt { get { return true; } }
public override bool ShowReattachWarning { get { return true; } }
public override bool AllowToCreateNewSr { get { return true; } set { } }
public override bool AllowToCreateNewSr
{
get => true;
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public SrWizardType_NetApp ToNetApp()
{

View File

@ -32,6 +32,7 @@
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Xml;
namespace XenCenterLib
@ -40,7 +41,7 @@ namespace XenCenterLib
{
public override ICredentials Credentials
{
set { }
set => throw new NotSupportedException($"Invalid set call for '{MethodBase.GetCurrentMethod()?.Name}', value: '{value}'");
}
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)