-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Brown
committed
Feb 28, 2020
1 parent
91e86e7
commit a7ca5d6
Showing
16 changed files
with
846 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29806.167 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyInfo", "AssemblyInfo\AssemblyInfo.csproj", "{9AAB585F-C18C-4DC5-85FD-20902AC6732C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9AAB585F-C18C-4DC5-85FD-20902AC6732C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9AAB585F-C18C-4DC5-85FD-20902AC6732C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9AAB585F-C18C-4DC5-85FD-20902AC6732C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9AAB585F-C18C-4DC5-85FD-20902AC6732C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {77D143E2-703B-4951-BE9E-543B5B69FF41} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9AAB585F-C18C-4DC5-85FD-20902AC6732C}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>AssemblyInfo</RootNamespace> | ||
<AssemblyName>AssemblyInfo</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="CommandLine, Version=2.7.82.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemlyInfoWindow.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="AssemlyInfoWindow.Designer.cs"> | ||
<DependentUpon>AssemlyInfoWindow.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Extensions\ByteConverter.cs" /> | ||
<Compile Include="Extensions\Util.cs" /> | ||
<Compile Include="Options.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="AssemlyInfoWindow.resx"> | ||
<DependentUpon>AssemlyInfoWindow.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Versioning; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using AssemblyInfo.Extensions; | ||
|
||
namespace AssemblyInfo | ||
{ | ||
public partial class AssemlyInfoWindow : Form | ||
{ | ||
private ContextMenu _contextMenu; | ||
private bool _toolTipVisible = false; | ||
public Options Options { get; } | ||
|
||
|
||
public AssemlyInfoWindow(Options options) | ||
{ | ||
Options = options; | ||
InitializeComponent(); | ||
BuildDetailsList(); | ||
InspectAssembly(options.Filename); | ||
} | ||
|
||
private void BuildDetailsList() | ||
{ | ||
_contextMenu = new ContextMenu(); | ||
_contextMenu.MenuItems.Add(new MenuItem("Copy", MenuItemCopy_Click, Shortcut.CtrlC)); | ||
listInfo.ContextMenu = _contextMenu; | ||
listInfo.ItemMouseHover += ListInfo_ItemMouseHover; | ||
//listInfo.MouseMove += ListInfo_MouseMove; | ||
toolTip1.Popup += ToolTip1_Popup; | ||
toolTip1.SetToolTip(listInfo, "Test"); | ||
var columnHeaders = new ColumnHeader[] { | ||
new ColumnHeader { Name = "Property", Text = "", Width = 100 }, | ||
new ColumnHeader { Name = "Value", Text = "", Width = listInfo.Width - 105 }, | ||
}; | ||
listInfo.Columns.AddRange(columnHeaders); | ||
|
||
var items = new ListViewItem[] | ||
{ | ||
new ListViewItem(new string[] { "Name", "" }), | ||
new ListViewItem(new string[] { "ProductName", "" }), | ||
new ListViewItem(new string[] { "FileDescription", "" }), | ||
new ListViewItem(new string[] { "Description", "" }), | ||
new ListViewItem(new string[] { "Company", "" }), | ||
new ListViewItem(new string[] { "Version", "" }), | ||
new ListViewItem(new string[] { "FileVersion", "" }), | ||
new ListViewItem(new string[] { "ProductVersion", "" }), | ||
new ListViewItem(new string[] { "PublicKeyToken", "" }), | ||
new ListViewItem(new string[] { "Framework", "" }), | ||
new ListViewItem(new string[] { "Copyright", "" }), | ||
new ListViewItem(new string[] { "Build", "" }), | ||
new ListViewItem(new string[] { "IsDebug", "" }), | ||
new ListViewItem(new string[] { "IsPatched", "" }), | ||
new ListViewItem(new string[] { "IsPreRelease", "" }), | ||
new ListViewItem(new string[] { "Language", "" }), | ||
new ListViewItem(new string[] { "OriginalFilename", "" }), | ||
new ListViewItem(new string[] { "FileSize", "" }), | ||
new ListViewItem(new string[] { "SHA", "" }), | ||
new ListViewItem(new string[] { "MD5", "" }), | ||
}; | ||
listInfo.Items.AddRange(items); | ||
} | ||
|
||
private void ListInfo_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e) | ||
{ | ||
var item = e.Item; | ||
if (item != null && e.Item.SubItems.Count >= 2 && !string.IsNullOrEmpty(item.SubItems[1].Text)) | ||
{ | ||
Debug.WriteLine($"{item.SubItems[1].Text}"); | ||
toolTip1.ToolTipTitle = item.SubItems[0].Text; | ||
toolTip1.SetToolTip(listInfo, item.SubItems[1].Text); | ||
} | ||
} | ||
|
||
private void ToolTip1_Popup(object sender, PopupEventArgs e) | ||
{ | ||
_toolTipVisible = true; | ||
} | ||
|
||
private void MenuItemCopy_Click(object sender, EventArgs e) | ||
{ | ||
var menuItem = sender as MenuItem; | ||
var parent = menuItem.Parent as ContextMenu; | ||
var control = parent.SourceControl as ListView; | ||
var itemList = new List<ListViewItem>(); | ||
foreach (ListViewItem item in control.SelectedItems) | ||
itemList.Add(item); | ||
Clipboard.SetText(string.Join(Environment.NewLine, itemList.Select(x => $"{x.SubItems[0].Text}={x.SubItems[1].Text}"))); | ||
} | ||
|
||
private void ListInfo_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
} | ||
|
||
private void InspectAssembly(string filename) | ||
{ | ||
var assembly = Assembly.LoadFrom(filename); | ||
var assemblyName = assembly.GetName(); | ||
var version = assemblyName.Version; | ||
var fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); | ||
var targetFramework = assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType == typeof(TargetFrameworkAttribute)); | ||
var assemblyConfiguration = assembly.CustomAttributes.FirstOrDefault(x => x.AttributeType == typeof(AssemblyConfigurationAttribute)); | ||
var fileInfo = new FileInfo(filename); | ||
|
||
listInfo.Items[0].SubItems[1].Text = $"{assembly.FullName}"; | ||
listInfo.Items[1].SubItems[1].Text = $"{fileVersion.ProductName}"; | ||
listInfo.Items[2].SubItems[1].Text = $"{fileVersion.FileDescription}"; | ||
listInfo.Items[3].SubItems[1].Text = $"{fileVersion.Comments}"; | ||
listInfo.Items[4].SubItems[1].Text = $"{fileVersion.CompanyName}"; | ||
listInfo.Items[5].SubItems[1].Text = $"{version.ToString()}"; | ||
listInfo.Items[6].SubItems[1].Text = $"{fileVersion.FileVersion}"; | ||
listInfo.Items[7].SubItems[1].Text = $"{fileVersion.ProductVersion}"; | ||
listInfo.Items[8].SubItems[1].Text = $"{string.Join("", assemblyName.GetPublicKeyToken().Select(b => b.ToString("x2")))}"; | ||
listInfo.Items[9].SubItems[1].Text = targetFramework.ConstructorArguments?.FirstOrDefault().Value.ToString(); | ||
listInfo.Items[10].SubItems[1].Text = $"{fileVersion.LegalCopyright}"; | ||
listInfo.Items[11].SubItems[1].Text = $"{assemblyConfiguration.ConstructorArguments?.FirstOrDefault().Value.ToString()}"; | ||
listInfo.Items[12].SubItems[1].Text = $"{fileVersion.IsDebug}"; | ||
listInfo.Items[13].SubItems[1].Text = $"{fileVersion.IsPatched}"; | ||
listInfo.Items[14].SubItems[1].Text = $"{fileVersion.IsPreRelease}"; | ||
listInfo.Items[15].SubItems[1].Text = $"{fileVersion.Language}"; | ||
listInfo.Items[16].SubItems[1].Text = $"{fileVersion.OriginalFilename}"; | ||
listInfo.Items[17].SubItems[1].Text = $"{Util.BytesToString(fileInfo.Length)}"; | ||
|
||
ComputeHashAsync(filename).ConfigureAwait(false); | ||
} | ||
|
||
private async Task ComputeHashAsync(string filename) | ||
{ | ||
var bytes = File.ReadAllBytes(filename); | ||
using (var sha = SHA256.Create()) | ||
{ | ||
var shaHash = sha.ComputeHash(bytes); | ||
listInfo.Items[18].SubItems[1].Text = AssemblyInfo.Extensions.ByteConverter.ToHex(shaHash); | ||
} | ||
using (var md5 = MD5.Create()) | ||
{ | ||
var md5Hash = md5.ComputeHash(bytes); | ||
listInfo.Items[19].SubItems[1].Text = AssemblyInfo.Extensions.ByteConverter.ToHex(md5Hash); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.