Skip to content

Commit

Permalink
Fixed many compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Apr 27, 2019
1 parent 97cffaa commit c1cf87d
Show file tree
Hide file tree
Showing 66 changed files with 549 additions and 178 deletions.
2 changes: 2 additions & 0 deletions src/BuildVision.Common/AppVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ private static DateTime RetrieveLinkerTimestamp(Assembly assembly)
finally
{
if (stream != null)
{
stream.Close();
}
}

int i = BitConverter.ToInt32(buffer, PeHeaderOffset);
Expand Down
8 changes: 6 additions & 2 deletions src/BuildVision.Common/BindableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ public abstract class BindableBase : INotifyPropertyChanged
public virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage, value))
{
return false;
}

storage = value;
OnPropertyChanged(propertyName);

return true;
}

public virtual bool SetProperty<T>(Func<T> storage, Action<T> set, T value, [CallerMemberName] string propertyName = null)
public virtual bool SetProperty<T>(Func<T> storage, Action<T> setAction, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage(), value))
{
return false;
}

set(value);
setAction(value);
OnPropertyChanged(propertyName);

return true;
Expand Down
2 changes: 2 additions & 0 deletions src/BuildVision.Common/CustomStringFormatProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public object GetFormat(Type formatType)
public string Format(string format, object arg, IFormatProvider formatProvider)
{
if (arg == null)
{
return null;
}

if (format != null && arg is string)
{
Expand Down
27 changes: 22 additions & 5 deletions src/BuildVision.Common/Diagnostics/DiagnosticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static void Initialize(string apiKey)

public static void OnExit()
{
if (!_initialized) return;
if (!_initialized)
{
return;
}

_client.Flush();
// Allow time for flushing:
Expand All @@ -38,26 +41,40 @@ public static void OnExit()

public static void TrackEvent(string eventName, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null)
{
if (!_initialized) return;
if (!_initialized)
{
return;
}

_client.TrackEvent(eventName, properties, metrics);
}

public static void TrackTrace(string evt)
{
if (!_initialized) return;
if (!_initialized)
{
return;
}

_client.TrackTrace(evt);
}

public static void Notify(Exception exception)
{
if (!_initialized) return;
if (!_initialized)
{
return;
}

_client.TrackException(exception);
}

public static void TrackPageView(string pageName)
{
if (!_initialized) return;
if (!_initialized)
{
return;
}

_client.TrackPageView(pageName);
}
Expand Down
3 changes: 3 additions & 0 deletions src/BuildVision.Common/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ public static class DateTimeExtensions
public static DateTime Truncate(this DateTime dateTime, TimeSpan timeSpan)
{
if (timeSpan <= TimeSpan.Zero)
{
return dateTime;
}

return dateTime.AddTicks(-(dateTime.Ticks % timeSpan.Ticks));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BuildVision.Common/FilePathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static string ShortenPath(string path, int maxLength)
}
}

if (lastPart == "")
if (string.IsNullOrEmpty(lastPart))
{
//the filename (and root path) in itself was longer than maxLength, shorten it
lastPart = pathParts[pathParts.Length - 1];//"pathParts[pathParts.Length -1]" is the equivalent of "Path.GetFileName(pathToShorten)"
Expand Down
11 changes: 6 additions & 5 deletions src/BuildVision.Common/GithubHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using BuildVision.Common;

namespace BuildVision.Helpers
{
public class GithubHelper
public static class GithubHelper
{
const string ASSIGNEE = "stefankert";
const string URL_TEMPLATE = "https://github.com/StefanKert/BuildVision/issues/new?labels={0}&title={1}&assignee={2}&body={3}";
Expand All @@ -24,13 +25,13 @@ public static void OpenBrowserWithPrefilledIssue()
{
var appVersion = new AppVersionInfo();

var url = GetUrlForNewBug(string.Format(template, VsVersion.FullVersion, appVersion.BuildVersion, Environment.OSVersion));
Process.Start(new ProcessStartInfo(url));
var url = GetUrlForNewBug(string.Format(CultureInfo.CurrentCulture, template, VsVersion.FullVersion, appVersion.BuildVersion, Environment.OSVersion));
Process.Start(new ProcessStartInfo(url.ToString()));
}

public static string GetUrlForNewBug(string body)
public static Uri GetUrlForNewBug(string body)
{
return string.Format(URL_TEMPLATE, "Bug", "", ASSIGNEE, WebUtility.UrlEncode(body));
return new Uri(string.Format(CultureInfo.CurrentCulture, URL_TEMPLATE, "Bug", "", ASSIGNEE, WebUtility.UrlEncode(body)));
}
}
}
6 changes: 6 additions & 0 deletions src/BuildVision.Common/PropertyColumnSorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public PropertyColumnSorter(ListSortDirection direction, string propertyName)
_propertyInfo = typeof(T).GetProperty(propertyName);

if (_propertyInfo == null)
{
throw new PropertyNotFoundException(propertyName, typeof(T));
}
}

int IComparer.Compare(object x, object y)
Expand All @@ -32,10 +34,14 @@ protected int Compare(T x, T y)
var y1 = _propertyInfo.GetValue(y, null) as IComparable;

if (x1 != null && y1 != null)
{
return x1.CompareTo(y1) * _direction;
}

if (x1 == null && y1 == null)
{
return 0;
}

// Null values always in the bottom.
return (x1 == null) ? 1 : -1;
Expand Down
5 changes: 1 addition & 4 deletions src/BuildVision.Common/RelayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public RelayCommand(Action<object> execute)
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");

_execute = execute;
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
}

Expand Down
2 changes: 2 additions & 0 deletions src/BuildVision.Common/SettingsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public void InitFrom<T>(T source) where T : SettingsBase
{
PropertyInfo[] properties = typeof(T).GetProperties();
foreach (var property in properties)
{
property.SetValue(this, property.GetValue(source, null), null);
}
}
}
}
2 changes: 2 additions & 0 deletions src/BuildVision.Common/VSVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public static Version FullVersion
mVsVersion = new Version(verName);
}
else
{
mVsVersion = new Version(0, 0); // Not running inside Visual Studio!
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/BuildVision.Contracts/Enums/BuildActions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace BuildVision.Contracts
{
public enum BuildActions
public enum BuildAction
{
BuildActionBuild = 1,
BuildActionRebuildAll = 2,
BuildActionClean = 3,
BuildActionDeploy = 4,
Build = 1,
RebuildAll = 2,
Clean = 3,
Deploy = 4,
Unknown = 5
}
}
8 changes: 4 additions & 4 deletions src/BuildVision.Contracts/Enums/BuildScopes.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace BuildVision.Contracts
{
public enum BuildScopes
public enum BuildScope
{
BuildScopeSolution = 1,
BuildScopeBatch = 2,
BuildScopeProject = 3,
Solution = 1,
Batch = 2,
Project = 3,
Unknown = 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

namespace BuildVision.Contracts.Exceptions
{
[Serializable]
public class PropertyNotFoundException : Exception
{
public string PropertyName { get; }

public Type PropertyType { get; }

public override string Message => string.Format("Property '{0}' not found in '{1}' type.", PropertyName, PropertyType);

public PropertyNotFoundException(string propertyName, Type type)
{
PropertyName = propertyName;
Type = type;
PropertyType = type;
}

public string PropertyName { get; }

public Type Type { get; }

public override string Message => string.Format("Property '{0}' not found in '{1}' type.", PropertyName, Type);
}
}
4 changes: 2 additions & 2 deletions src/BuildVision.Contracts/Models/BuildProjectContextEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BuildVision.UI.Models;
using BuildVision.UI.Models;
using System.Collections.Generic;

namespace BuildVision.UI.Contracts
Expand All @@ -11,7 +11,7 @@ public class BuildProjectContextEntry

public string FileName { get; set; }

public IDictionary<string, string> Properties { get; set; }
public IDictionary<string, string> Properties { get; }

public IProjectItem ProjectItem { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/BuildVision.Contracts/Models/ErrorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ public void VerifyValues()
}

if (LineNumber < 1)
{
LineNumber = 1;
}

if (ColumnNumber < 1)
{
ColumnNumber = 1;
}

if (EndLineNumber == 0 && EndColumnNumber == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/BuildVision.Contracts/Models/IBuildInformationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace BuildVision.Contracts.Models
{
public interface IBuildInformationModel : INotifyPropertyChanged
{
BuildActions BuildAction { get; set; }
BuildAction BuildAction { get; set; }
DateTime? BuildFinishTime { get; set; }
BuildScopes BuildScope { get; set; }
BuildScope BuildScope { get; set; }
DateTime? BuildStartTime { get; set; }
BuildState CurrentBuildState { get; set; }
int ErrorCount { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/BuildVision.Contracts/Models/IProjectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public interface IProjectItem
int MessagesCount { get; set; }
int ErrorsCount { get; set; }
int WarningsCount { get; set; }
ObservableCollection<ErrorItem> Errors { get; set; }
ObservableCollection<ErrorItem> Warnings { get; set; }
ObservableCollection<ErrorItem> Messages { get; set; }
ObservableCollection<ErrorItem> Errors { get; }
ObservableCollection<ErrorItem> Warnings { get; }
ObservableCollection<ErrorItem> Messages { get; }

void RaiseBuildElapsedTimeChanged();
void AddErrorItem(ErrorItem errorItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public interface IBuildInformationProvider
IBuildInformationModel BuildInformationModel { get; }
ObservableCollection<IProjectItem> Projects { get; }

void ProjectBuildStarted(IProjectItem projectItem, BuildActions buildAction);
void ProjectBuildFinished(BuildActions buildAction, string projectIdentifier, bool succeess, bool canceled);
void ProjectBuildStarted(IProjectItem projectItem, BuildAction buildAction);
void ProjectBuildFinished(BuildAction buildAction, string projectIdentifier, bool succeess, bool canceled);
void ReloadCurrentProjects();
void ResetCurrentProjects();
void BuildFinished(bool success, bool canceled);
void BuildStarted(BuildActions currentBuildAction, BuildScopes scope);
void BuildStarted(BuildAction currentBuildAction, BuildScope scope);
void BuildUpdate();
void ResetBuildInformationModel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/BuildVision.Exports/Sevices/ITaskBarInfoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace BuildVision.Exports.Services
public interface ITaskBarInfoService
{
void ResetTaskBarInfo(bool ifTaskBarProgressEnabled = true);
void UpdateTaskBarInfo(BuildState buildState, BuildScopes buildScope, int projectsCount, int finishedProjects);
void UpdateTaskBarInfo(BuildState buildState, BuildScope buildScope, int projectsCount, int finishedProjects);
}
}
2 changes: 2 additions & 0 deletions src/BuildVision.UI/Attributes/DisplayStringAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public override bool Equals(object obj)
{
var dsaObj = obj as DisplayStringAttribute;
if (dsaObj == null)
{
return false;
}

return DisplayString.Equals(dsaObj.DisplayString);
}
Expand Down
2 changes: 2 additions & 0 deletions src/BuildVision.UI/Components/ErrorsGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ private void ErrorsGridRowOnMouseLeftButtonUp(object sender, MouseButtonEventArg
private void ErrorsGridOnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (_errorsGridScrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)
{
return;
}

e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
Expand Down
4 changes: 4 additions & 0 deletions src/BuildVision.UI/Components/ProjectGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs
Grid.SelectedIndex = -1;

if (Grid.SelectedIndex == -1)
{
Grid.ScrollIntoView(ViewModel.BuildInformationModel.CurrentProject);
}
}
}

Expand Down Expand Up @@ -110,7 +112,9 @@ private void DataGridRowDetailsOnMouseLeftButtonDown(object sender, MouseButtonE
{
// http://stackoverflow.com/questions/6279724/mousedoubleclick-events-dont-bubble/6326181#6326181)
if (e.ClickCount == 2)
{
e.Handled = true;
}
}

// Autofocus for RowDetails (without extra mouse click).
Expand Down
Loading

0 comments on commit c1cf87d

Please sign in to comment.