Skip to content

Commit

Permalink
- Add VS build optimisation
Browse files Browse the repository at this point in the history
- Some more tinkering with `null`'s

#1020
  • Loading branch information
Smurf-IV committed Jul 15, 2023
1 parent 1ea5ef5 commit ee13f99
Show file tree
Hide file tree
Showing 27 changed files with 79 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<WarningLevel>6</WarningLevel>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class ViewDrawAutoHiddenTab : ViewDrawButton,
/// </summary>
/// <param name="page">Reference to the page this tab represents.</param>
/// <param name="orientation">Visual orientation used for drawing the tab.</param>
public ViewDrawAutoHiddenTab(KryptonPage page,
public ViewDrawAutoHiddenTab([DisallowNull] KryptonPage page,
VisualOrientation orientation)
: base(page.StateDisabled.CheckButton,
page.StateNormal.CheckButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<WarningLevel>6</WarningLevel>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<WarningLevel>6</WarningLevel>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class ButtonSpecCollectionBase : GlobalId
protected ButtonSpecCollectionBase([DisallowNull] object owner)
{
Debug.Assert(owner != null);
Owner = owner;
Owner = owner!;
}
#endregion

Expand All @@ -63,6 +63,7 @@ protected ButtonSpecCollectionBase([DisallowNull] object owner)
/// <summary>
/// Gets and sets the owner of the collection.
/// </summary>
[DisallowNull]
public object Owner { get; set; }

#endregion
Expand Down Expand Up @@ -224,7 +225,7 @@ object IList.this[int index]
public int IndexOf([DisallowNull] T item)
{
Debug.Assert(item != null);
return _specs.IndexOf(item);
return _specs.IndexOf(item!);
}

/// <summary>
Expand Down Expand Up @@ -354,7 +355,7 @@ public void Add([DisallowNull] T item)
public bool Contains([DisallowNull] T item)
{
Debug.Assert(item != null);
return _specs.Contains(item);
return _specs.Contains(item!);
}

/// <summary>
Expand Down Expand Up @@ -388,16 +389,16 @@ public bool Remove([DisallowNull] T item)
Debug.Assert(item != null);

// Cache the index of the button spec
var index = IndexOf(item);
var index = IndexOf(item!);

// Generate before event
OnRemoving(new ButtonSpecEventArgs(item, index));
OnRemoving(new ButtonSpecEventArgs(item!, index));

// Remove from the internal list
var ret = _specs.Remove(item);
var ret = _specs.Remove(item!);

// Generate after event
OnRemoved(new ButtonSpecEventArgs(item, index));
OnRemoved(new ButtonSpecEventArgs(item!, index));

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected ButtonSpecFormFixed([DisallowNull] KryptonForm form,
Debug.Assert(form != null);

// Remember back reference to owning navigator.
KryptonForm = form;
KryptonForm = form!;

// Fix the type
ProtectedType = fixedStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected override void OnClick(EventArgs e)
{
// Only if the mouse is still within the button bounds do we perform action
var mea = (MouseEventArgs)e;
if (GetView().ClientRectangle.Contains(mea.Location))
if (GetView()!.ClientRectangle.Contains(mea.Location))
{
// Toggle between maximized and restored
KryptonForm.SendSysCommand(KryptonForm.WindowState == FormWindowState.Maximized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal class ListSpacers : List<ViewLayoutMetricSpacer> { }
/// <param name="getRenderer">Delegate for returning a tool strip renderer.</param>
/// <param name="needPaint">Delegate for notifying paint requests.</param>
protected ButtonSpecManagerBase([DisallowNull] Control control,
[DisallowNull] PaletteRedirect redirector,
[DisallowNull] PaletteRedirect? redirector,
ButtonSpecCollectionBase? variableSpecs,
ButtonSpecCollectionBase? fixedSpecs,
IPaletteMetric[] viewMetrics,
Expand All @@ -78,7 +78,7 @@ protected ButtonSpecManagerBase([DisallowNull] Control control,
_viewMetricIntOutside = viewMetricIntOutside;
_viewMetricIntInside = viewMetricIntInside;
_viewMetricPaddings = viewMetricPaddings;
_getRenderer = getRenderer;
_getRenderer = getRenderer!;

if (_viewMetrics != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ButtonSpecManagerDraw : ButtonSpecManagerBase
/// <param name="getRenderer">Delegate for returning a tool strip renderer.</param>
/// <param name="needPaint">Delegate for notifying paint requests.</param>
public ButtonSpecManagerDraw(Control control,
PaletteRedirect? redirector,
[DisallowNull] PaletteRedirect? redirector,
ButtonSpecCollectionBase variableSpecs,
ButtonSpecCollectionBase? fixedSpecs,
ViewDrawDocker[] viewDockers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ButtonSpecManagerLayout(Control control,
/// <param name="getRenderer">Delegate for returning a tool strip renderer.</param>
/// <param name="needPaint">Delegate for notifying paint requests.</param>
public ButtonSpecManagerLayout(Control control,
PaletteRedirect? redirector,
[DisallowNull] PaletteRedirect? redirector,
ButtonSpecCollectionBase? variableSpecs,
ButtonSpecCollectionBase? fixedSpecs,
ViewLayoutDocker[] viewDockers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected ButtonSpecRemapByContentBase(PaletteBase? target,
: base(target)
{
Debug.Assert(buttonSpec != null);
_buttonSpec = buttonSpec;
_buttonSpec = buttonSpec!;
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ButtonSpecToContent([DisallowNull] PaletteBase? palette,
Debug.Assert(palette != null);
Debug.Assert(buttonSpec != null);
_palette = palette;
_buttonSpec = buttonSpec;
_buttonSpec = buttonSpec!;
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public virtual ButtonSpecViewControllers CreateController(ViewDrawButton viewBut
/// <param name="e">An EventArgs that contains the event data.</param>
protected virtual void OnFinishDelegate(object sender, EventArgs? e) =>
// Ask the button to remove the fixed pressed appearance
_controller.RemoveFixed();
_controller?.RemoveFixed();

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public Color ImageTransparentColor
#endregion

#region Internal
internal void SetPaletteRedirect(PaletteTripleRedirect redirector) => _redirectHeading.SetRedirectStates(redirector, redirector);
internal void SetPaletteRedirect(PaletteTripleRedirect redirector) => _redirectHeading?.SetRedirectStates(redirector, redirector);

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public DateTime TodayDate
[KryptonPersist]
[Localizable(true)]
[Description(@"Indicates which annual dates should be boldface.")]
[AllowNull]
public DateTime[] AnnuallyBoldedDates
{
get => _annualDates.ToArray();
Expand Down Expand Up @@ -366,6 +367,7 @@ public DateTime[] AnnuallyBoldedDates
[KryptonPersist]
[Localizable(true)]
[Description(@"Indicates which monthly dates should be boldface.")]
[AllowNull]
public DateTime[] MonthlyBoldedDates
{
get => _monthlyDates.ToArray();
Expand Down Expand Up @@ -398,6 +400,7 @@ public DateTime[] MonthlyBoldedDates
[KryptonPersist]
[Localizable(true)]
[Description(@"Indicates which dates should be boldface.")]
[AllowNull]
public DateTime[] BoldedDates
{
get => BoldedDatesList.ToArray();
Expand Down Expand Up @@ -433,12 +436,12 @@ public DateTime MinDate
{
if (value > DateTimePicker.MaximumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is greater than the maximum culture supported date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is greater than the maximum culture supported date.");
}

if (value < DateTimePicker.MinimumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is less than the minimum culture supported date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is less than the minimum culture supported date.");
}
}

Expand Down Expand Up @@ -469,12 +472,12 @@ public DateTime MaxDate
{
if (value > DateTimePicker.MaximumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is greater than the maximum culture supported date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is greater than the maximum culture supported date.");
}

if (value < DateTimePicker.MinimumDateTime)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is less than the minimum culture supported date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is less than the minimum culture supported date.");
}
}

Expand Down Expand Up @@ -504,7 +507,7 @@ public int MaxSelectionCount
{
if (value < 1)
{
throw new ArgumentOutOfRangeException(nameof(value), "MaxSelectionCount cannot be less than zero.");
throw new ArgumentOutOfRangeException(nameof(value), @"MaxSelectionCount cannot be less than zero.");
}

if (value != _maxSelectionCount)
Expand Down Expand Up @@ -534,12 +537,12 @@ public DateTime SelectionStart
{
if (value > _maxDate)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is greater than the maximum date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is greater than the maximum date.");
}

if (value < _minDate)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is less than the minimum date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is less than the minimum date.");
}

// End date cannot be before the start date
Expand Down Expand Up @@ -584,12 +587,12 @@ public DateTime SelectionEnd
{
if (value > _maxDate)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is greater than the maximum date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is greater than the maximum date.");
}

if (value < _minDate)
{
throw new ArgumentOutOfRangeException(nameof(value), "Date provided is less than the minimum date.");
throw new ArgumentOutOfRangeException(nameof(value), @"Date provided is less than the minimum date.");
}

// Start date cannot be after the end date
Expand Down Expand Up @@ -647,6 +650,7 @@ private void ResetSelectionRange()
[DefaultValue(@"d")]
[RefreshProperties(RefreshProperties.Repaint)]
[Localizable(true)]
[AllowNull]
public string TodayFormat
{
get => _todayFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class KryptonContextMenuRadioButton : KryptonContextMenuItemBase
private bool _enabled;
private string _text;
private string? _extraText;
private Image _image;
private Image? _image;
private Color _imageTransparentColor;
private readonly PaletteContentInheritRedirect _stateCommonRedirect;
private KryptonCommand _command;
Expand Down Expand Up @@ -235,6 +235,7 @@ public Image? Image
[Category(@"Appearance")]
[Description(@"Radio button image color to make transparent.")]
[Localizable(true)]
[DisallowNull]
public Color ImageTransparentColor
{
get => _imageTransparentColor;
Expand All @@ -249,7 +250,7 @@ public Color ImageTransparentColor
}
}

private bool ShouldSerializeImageTransparentColor() => (_imageTransparentColor == null) || !_imageTransparentColor.Equals(Color.Empty);
private bool ShouldSerializeImageTransparentColor() => !_imageTransparentColor.Equals(Color.Empty);

/// <summary>
/// Gets and sets the radio button label style.
Expand Down Expand Up @@ -401,6 +402,7 @@ public bool AutoCheck
[Category(@"Behavior")]
[Description(@"Command associated with the menu check box.")]
[DefaultValue(null)]
[AllowNull]
public virtual KryptonCommand? KryptonCommand
{
get => _command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<WarningLevel>6</WarningLevel>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit ee13f99

Please sign in to comment.