Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
Fixed wrong version displayed
  • Loading branch information
StefanKert committed Apr 27, 2019
1 parent c1cf87d commit 764e267
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 129 deletions.
16 changes: 8 additions & 8 deletions src/BuildVision.Common/AppVersionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

Expand All @@ -12,12 +13,11 @@ public class AppVersionInfo

public AppVersionInfo()
{
Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = assembly.GetName();
Version version = assemblyName.Version;
var assembly = Assembly.GetExecutingAssembly();
var versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

AppVersion = version.ToString(3);
BuildVersion = version.ToString(4);
AppVersion = new Version(versionInfo.ProductVersion).ToString();
BuildVersion = new Version(versionInfo.FileVersion).ToString();
BuildDateTime = RetrieveLinkerTimestamp(assembly);
}

Expand All @@ -26,7 +26,7 @@ public AppVersionInfo()
/// </summary>
private static DateTime RetrieveLinkerTimestamp(Assembly assembly)
{
string filePath = assembly.Location;
var filePath = assembly.Location;
const int PeHeaderOffset = 60;
const int LinkerTimestampOffset = 8;
var buffer = new byte[2048];
Expand All @@ -45,8 +45,8 @@ private static DateTime RetrieveLinkerTimestamp(Assembly assembly)
}
}

int i = BitConverter.ToInt32(buffer, PeHeaderOffset);
int secondsSince1970 = BitConverter.ToInt32(buffer, i + LinkerTimestampOffset);
var i = BitConverter.ToInt32(buffer, PeHeaderOffset);
var secondsSince1970 = BitConverter.ToInt32(buffer, i + LinkerTimestampOffset);
var dt = new DateTime(1970, 1, 1, 0, 0, 0);
dt = dt.AddSeconds(secondsSince1970);
dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);
Expand Down
7 changes: 1 addition & 6 deletions src/BuildVision.Common/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ 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));
return timeSpan <= TimeSpan.Zero ? dateTime : dateTime.AddTicks(-(dateTime.Ticks % timeSpan.Ticks));
}
}
}
13 changes: 0 additions & 13 deletions src/BuildVision.Common/Logging/Log.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/BuildVision.Common/ObservableCollectionExtensions.cs

This file was deleted.

9 changes: 9 additions & 0 deletions src/BuildVision.Common/Properties/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Common.FilePathHelper.ShortenPath(System.String,System.Int32)~System.String")]

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Common.Diagnostics.SessionTelemetry.#ctor")]
3 changes: 1 addition & 2 deletions src/BuildVision.Common/PropertyColumnSorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

namespace BuildVision.Common
{
public class PropertyColumnSorter<T> : IComparer
where T : class
public class PropertyColumnSorter<T> : IComparer where T : class
{
private readonly int _direction;
private readonly PropertyInfo _propertyInfo;
Expand Down
8 changes: 8 additions & 0 deletions src/BuildVision.Contracts/Properties/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.Contracts.Exceptions.PropertyNotFoundException.Message")]

1 change: 1 addition & 0 deletions src/BuildVision.UI/BuildVision.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<Compile Include="Converters\InProgressToVisibleConverter.cs" />
<Compile Include="Converters\StateIconKeyToIconConverter.cs" />
<Compile Include="Enums\ResetTaskBarItemInfoCondition.cs" />
<Compile Include="Properties\GlobalSuppressions.cs" />
<Compile Include="Models\SortDescription.cs" />
<Compile Include="Enums\SortOrder.cs" />
<Compile Include="Enums\WindowState.cs" />
Expand Down
37 changes: 37 additions & 0 deletions src/BuildVision.UI/Properties/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~F:BuildVision.UI.Components.SpinnerControl.FormattedValuePropertyKey")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~F:BuildVision.UI.Extensions.VectorResources._baseUri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.DataGridLengthStringConverter.Convert(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.DataGridLengthStringConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.GridColumnSettingsToColumnExampleValueConverter.FormatExample(System.Object,System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.MultiBindingStringFormatConverter.Convert(System.Object[],System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.SubtractConstantConverter.Convert(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetBuildBeginMajorMessage(BuildVision.Contracts.Models.IBuildInformationModel)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetBuildDoneExtraMessage(BuildVision.Contracts.Models.IBuildInformationModel)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetBuildDoneMajorMessage(BuildVision.Contracts.Models.IBuildInformationModel)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetExtraTimePartString(System.TimeSpan)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetMainString(BuildVision.Contracts.Models.IBuildInformationModel)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Helpers.BuildMessagesFactory.GetTimeString(System.Nullable{System.DateTime})~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.ViewModels.BuildVisionPaneViewModel.CopyErrorMessageToClipboard(BuildVision.UI.Models.ProjectItem)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Modelss.GridColumnAttribute.DateTimeExampleValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Modelss.GridColumnAttribute.TimeSpanExampleValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Settings.Models.BuildMessagesSettings.BuildBeginMajorMessageStringFormat")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Settings.Models.BuildMessagesSettings.BuildDoneMajorMessageStringFormat")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Settings.Models.BuildMessagesSettings.DateTimeFormat")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Settings.Models.BuildMessagesSettings.ExtraMessageStringFormat")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~P:BuildVision.UI.Settings.Models.BuildMessagesSettings.TimeSpanFormat")]

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.DataGridLengthStringConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.GridColumnSettingsToColumnExampleValueConverter.FormatExample(System.Object,System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Converters.MultiBindingStringFormatConverter.Convert(System.Object[],System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.DataGrid.ColumnsManager.GenerateColumns(System.Collections.ObjectModel.ObservableCollection{System.Windows.Controls.DataGridColumn},BuildVision.UI.Settings.Models.GridSettings)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.DataGrid.ColumnsManager.SyncColumnSettings(System.Collections.ObjectModel.ObservableCollection{System.Windows.Controls.DataGridColumn},BuildVision.UI.Settings.Models.GridSettings)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.ErrorsGrid.ErrorsGridRowOnMouseLeftButtonUp(System.Object,System.Windows.Input.MouseButtonEventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.Extensions.VectorResources.TryGet(System.String,System.String)~System.Windows.Controls.ControlTemplate")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.ViewModels.BuildVisionPaneViewModel.CopyErrorMessageToClipboard(BuildVision.UI.Models.ProjectItem)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.UI.ViewModels.BuildVisionPaneViewModel.OpenContainingFolder")]
3 changes: 2 additions & 1 deletion src/BuildVision/BuildVision.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@
<Compile Include="Extensions\BuildActionsExtensions.cs" />
<Compile Include="Extensions\BuildStateExtensions.cs" />
<Compile Include="Extensions\IServiceProviderExtensions.cs" />
<Compile Include="Properties\GlobalSuppressions.cs" />
<Compile Include="Services\BuildInformationProvider.cs" />
<Compile Include="Services\ErrorNavigationService.cs" />
<Compile Include="Services\IWindowStateService.cs" />
<Compile Include="Interfaces\IWindowStateService.cs" />
<Compile Include="Services\SolutionProvider.cs" />
<Compile Include="Helpers\ProjectIdentifierGenerator.cs" />
<Compile Include="Core\BuildVisionPackage.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/BuildVision/Core/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public static IVsSolution GetSolution(this IServiceProvider provider)
return GetGlobalService<SVsSolution, IVsSolution>(provider);
}

public static Solution GetDteSolution(this IServiceProvider provider)
{
var ret = provider.GetService(typeof(DTE)) as DTE2;
return ret.Solution;
}

public static IVsSolution GetSolution()
{
return GetGlobalService<SVsSolution, IVsSolution>();
Expand Down
2 changes: 2 additions & 0 deletions src/BuildVision/Extensions/IServiceProviderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using BuildVision.Common.Logging;
using Serilog;

namespace BuildVision.Extensions
{
Expand Down
36 changes: 8 additions & 28 deletions src/BuildVision/Helpers/SolutionProjectsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,16 @@ public static IList<Project> GetProjects(this Solution solution)
return list;
}

public static Project GetProject(this Solution solution, Func<Project, bool> cond)
public static Project FirstOrDefaultProject(this Solution solution, Func<Project, bool> cond)
{
var projects = solution.Projects;
var item = projects.GetEnumerator();
while (item.MoveNext())
{
var project = item.Current as Project;
if (project == null)
{
continue;
}

if (project.Kind == EnvDTEProjectKinds.ProjectKindSolutionFolder)
{
var sub = project.GetSubProject(cond);
if (sub != null)
{
return sub;
}
}
else if (!project.IsHidden())
{
if (cond(project))
{
return project;
}
}
}
var projects = solution.GetProjects();
return projects.FirstOrDefault(cond);
}

return null;
public static Project FirstProject(this Solution solution, Func<Project, bool> cond)
{
var projects = solution.GetProjects();
return projects.First(cond);
}

public static IList<ProjectItem> GetProjectItems(this Solution solution)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BuildVision.UI.Settings.Models.ToolWindow;
using Microsoft.VisualStudio.Shell;

namespace BuildVision.Tool.Building
{
public interface IWindowStateService
Expand Down
Loading

0 comments on commit 764e267

Please sign in to comment.