Created
April 23, 2019 16:48
-
-
Save AraHaan/7e7b037b8f33c1d7a82576727c8d2f97 to your computer and use it in GitHub Desktop.
ErrorLogLister - a error log lister example Windows Forms application for .NET Core.
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
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | |
<PropertyGroup> | |
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
<ProjectGuid>{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}</ProjectGuid> | |
<OutputType>WinExe</OutputType> | |
<RootNamespace>ErrorLogLister</RootNamespace> | |
<AssemblyName>ErrorLogLister</AssemblyName> | |
<FileAlignment>512</FileAlignment> | |
<Deterministic>true</Deterministic> | |
<Version>1.0.0.0</Version> | |
<Copyright>Copyright © 2018</Copyright> | |
<Company /> | |
<ApplicationIcon /> | |
<StartupObject /> | |
</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> | |
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
<PlatformTarget>AnyCPU</PlatformTarget> | |
<DebugType>none</DebugType> | |
<Optimize>true</Optimize> | |
<OutputPath>bin\Release\</OutputPath> | |
<DefineConstants>TRACE</DefineConstants> | |
<ErrorReport>prompt</ErrorReport> | |
<WarningLevel>4</WarningLevel> | |
<DebugSymbols>false</DebugSymbols> | |
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Update="Form1.cs"> | |
<SubType>Form</SubType> | |
</Compile> | |
<Compile Update="Form1.Designer.cs"> | |
<DependentUpon>Form1.cs</DependentUpon> | |
</Compile> | |
<EmbeddedResource Update="Form1.resx"> | |
<SubType>Designer</SubType> | |
</EmbeddedResource> | |
</ItemGroup> | |
</Project> |
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
Microsoft Visual Studio Solution File, Format Version 12.00 | |
# Visual Studio 15 | |
VisualStudioVersion = 15.0.28302.56 | |
MinimumVisualStudioVersion = 10.0.40219.1 | |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErrorLogLister", "ErrorLogLister.csproj", "{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}" | |
EndProject | |
Global | |
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
Debug|Any CPU = Debug|Any CPU | |
Release|Any CPU = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
{F0EE9988-DA2A-431C-9EDB-4F1A505D3030}.Release|Any CPU.Build.0 = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(SolutionProperties) = preSolution | |
HideSolutionNode = FALSE | |
EndGlobalSection | |
GlobalSection(ExtensibilityGlobals) = postSolution | |
SolutionGuid = {2C5D77BD-1026-4E76-879D-2152B2757360} | |
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
namespace ErrorLogLister | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Windows.Forms; | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
=> this.InitializeComponent(); | |
private void OpenToolStripMenuItem_Click(object sender, EventArgs e) | |
{ | |
var result = this.OpenFileDialog1.ShowDialog(); | |
if (result == DialogResult.OK) | |
{ | |
// open the file | |
using (var fstream = this.OpenFileDialog1.OpenFile()) | |
using (var textReader = new StreamReader(fstream)) | |
{ | |
var lineLst = new List<string>(); | |
var linetmp = string.Empty; | |
while ((linetmp = textReader.ReadLine()) != null) | |
{ | |
lineLst.Add(linetmp); | |
} | |
var desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); | |
var lines = lineLst.ToArray(); | |
this.listBox1.Items.Clear(); | |
this.listBox2.Items.Clear(); | |
foreach (var line in lines) | |
{ | |
if (line.Contains("warning ")) | |
{ | |
var fixedLine = line; | |
if (line.Contains("corefx\\src\\")) | |
{ | |
fixedLine = line.Replace(desktop + "\\corefx\\src\\", string.Empty); | |
} | |
// add line to listBox2 | |
if (!this.listBox2.Items.Contains(fixedLine)) | |
{ | |
this.listBox2.Items.Add(fixedLine); | |
} | |
} | |
else if (line.Contains("error ")) | |
{ | |
var fixedLine = line; | |
if (line.Contains("corefx\\src\\")) | |
{ | |
fixedLine = line.Replace(desktop + "\\corefx\\src\\", string.Empty); | |
} | |
// add line to listBox1 | |
if (!this.listBox1.Items.Contains(fixedLine)) | |
{ | |
this.listBox1.Items.Add(fixedLine); | |
} | |
} | |
} | |
this.label3.Text = this.listBox1.Items.Count.ToString(); | |
this.label4.Text = this.listBox2.Items.Count.ToString(); | |
} | |
} | |
} | |
} | |
} |
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
namespace ErrorLogLister | |
{ | |
partial class Form1 | |
{ | |
/// <summary> | |
/// Required designer variable. | |
/// </summary> | |
private System.ComponentModel.IContainer components = null; | |
/// <summary> | |
/// Clean up any resources being used. | |
/// </summary> | |
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing && (components != null)) | |
{ | |
components.Dispose(); | |
} | |
base.Dispose(disposing); | |
} | |
#region Windows Form Designer generated code | |
/// <summary> | |
/// Required method for Designer support - do not modify | |
/// the contents of this method with the code editor. | |
/// </summary> | |
private void InitializeComponent() | |
{ | |
this.OpenFileDialog1 = new System.Windows.Forms.OpenFileDialog(); | |
this.listBox1 = new System.Windows.Forms.ListBox(); | |
this.listBox2 = new System.Windows.Forms.ListBox(); | |
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); | |
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); | |
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); | |
this.label1 = new System.Windows.Forms.Label(); | |
this.label2 = new System.Windows.Forms.Label(); | |
this.label3 = new System.Windows.Forms.Label(); | |
this.label4 = new System.Windows.Forms.Label(); | |
this.menuStrip1.SuspendLayout(); | |
this.SuspendLayout(); | |
// | |
// OpenFileDialog1 | |
// | |
this.OpenFileDialog1.AddExtension = false; | |
this.OpenFileDialog1.Filter = "All files|*.*"; | |
this.OpenFileDialog1.ReadOnlyChecked = true; | |
this.OpenFileDialog1.RestoreDirectory = true; | |
this.OpenFileDialog1.ShowReadOnly = true; | |
this.OpenFileDialog1.SupportMultiDottedExtensions = true; | |
this.OpenFileDialog1.Title = "Select a Build log file to scan for build warnings or errors:"; | |
// | |
// listBox1 | |
// | |
this.listBox1.FormattingEnabled = true; | |
this.listBox1.HorizontalScrollbar = true; | |
this.listBox1.Location = new System.Drawing.Point(0, 46); | |
this.listBox1.Name = "listBox1"; | |
this.listBox1.Size = new System.Drawing.Size(388, 381); | |
this.listBox1.TabIndex = 0; | |
// | |
// listBox2 | |
// | |
this.listBox2.FormattingEnabled = true; | |
this.listBox2.HorizontalScrollbar = true; | |
this.listBox2.Location = new System.Drawing.Point(394, 46); | |
this.listBox2.Name = "listBox2"; | |
this.listBox2.Size = new System.Drawing.Size(406, 381); | |
this.listBox2.TabIndex = 1; | |
// | |
// menuStrip1 | |
// | |
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { | |
this.fileToolStripMenuItem}); | |
this.menuStrip1.Location = new System.Drawing.Point(0, 0); | |
this.menuStrip1.Name = "menuStrip1"; | |
this.menuStrip1.Size = new System.Drawing.Size(800, 24); | |
this.menuStrip1.TabIndex = 2; | |
this.menuStrip1.Text = "menuStrip1"; | |
// | |
// fileToolStripMenuItem | |
// | |
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { | |
this.openToolStripMenuItem}); | |
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; | |
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); | |
this.fileToolStripMenuItem.Text = "File"; | |
// | |
// openToolStripMenuItem | |
// | |
this.openToolStripMenuItem.Name = "openToolStripMenuItem"; | |
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22); | |
this.openToolStripMenuItem.Text = "Open"; | |
this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItem_Click); | |
// | |
// label1 | |
// | |
this.label1.AutoSize = true; | |
this.label1.Location = new System.Drawing.Point(0, 30); | |
this.label1.Name = "label1"; | |
this.label1.Size = new System.Drawing.Size(37, 13); | |
this.label1.TabIndex = 3; | |
this.label1.Text = "Errors:"; | |
// | |
// label2 | |
// | |
this.label2.AutoSize = true; | |
this.label2.Location = new System.Drawing.Point(395, 30); | |
this.label2.Name = "label2"; | |
this.label2.Size = new System.Drawing.Size(55, 13); | |
this.label2.TabIndex = 4; | |
this.label2.Text = "Warnings:"; | |
// | |
// label3 | |
// | |
this.label3.AutoSize = true; | |
this.label3.Location = new System.Drawing.Point(177, 432); | |
this.label3.Name = "label3"; | |
this.label3.Size = new System.Drawing.Size(13, 13); | |
this.label3.TabIndex = 5; | |
this.label3.Text = "0"; | |
// | |
// label4 | |
// | |
this.label4.AutoSize = true; | |
this.label4.Location = new System.Drawing.Point(595, 432); | |
this.label4.Name = "label4"; | |
this.label4.Size = new System.Drawing.Size(13, 13); | |
this.label4.TabIndex = 6; | |
this.label4.Text = "0"; | |
// | |
// Form1 | |
// | |
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | |
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
this.ClientSize = new System.Drawing.Size(800, 450); | |
this.Controls.Add(this.label4); | |
this.Controls.Add(this.label3); | |
this.Controls.Add(this.label2); | |
this.Controls.Add(this.label1); | |
this.Controls.Add(this.listBox2); | |
this.Controls.Add(this.listBox1); | |
this.Controls.Add(this.menuStrip1); | |
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; | |
this.MainMenuStrip = this.menuStrip1; | |
this.MaximizeBox = false; | |
this.Name = "Form1"; | |
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; | |
this.Text = "Easy Error and Warning log viewer for .NET Core projects"; | |
this.menuStrip1.ResumeLayout(false); | |
this.menuStrip1.PerformLayout(); | |
this.ResumeLayout(false); | |
this.PerformLayout(); | |
} | |
#endregion | |
private System.Windows.Forms.OpenFileDialog OpenFileDialog1; | |
private System.Windows.Forms.ListBox listBox1; | |
private System.Windows.Forms.ListBox listBox2; | |
private System.Windows.Forms.MenuStrip menuStrip1; | |
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; | |
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; | |
private System.Windows.Forms.Label label1; | |
private System.Windows.Forms.Label label2; | |
private System.Windows.Forms.Label label3; | |
private System.Windows.Forms.Label label4; | |
} | |
} | |
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
<?xml version="1.0" encoding="utf-8"?> | |
<root> | |
<!-- | |
Microsoft ResX Schema | |
Version 2.0 | |
The primary goals of this format is to allow a simple XML format | |
that is mostly human readable. The generation and parsing of the | |
various data types are done through the TypeConverter classes | |
associated with the data types. | |
Example: | |
... ado.net/XML headers & schema ... | |
<resheader name="resmimetype">text/microsoft-resx</resheader> | |
<resheader name="version">2.0</resheader> | |
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |
<value>[base64 mime encoded serialized .NET Framework object]</value> | |
</data> | |
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |
<comment>This is a comment</comment> | |
</data> | |
There are any number of "resheader" rows that contain simple | |
name/value pairs. | |
Each data row contains a name, and value. The row also contains a | |
type or mimetype. Type corresponds to a .NET class that support | |
text/value conversion through the TypeConverter architecture. | |
Classes that don't support this are serialized and stored with the | |
mimetype set. | |
The mimetype is used for serialized objects, and tells the | |
ResXResourceReader how to depersist the object. This is currently not | |
extensible. For a given mimetype the value must be set accordingly: | |
Note - application/x-microsoft.net.object.binary.base64 is the format | |
that the ResXResourceWriter will generate, however the reader can | |
read any of the formats listed below. | |
mimetype: application/x-microsoft.net.object.binary.base64 | |
value : The object must be serialized with | |
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | |
: and then encoded with base64 encoding. | |
mimetype: application/x-microsoft.net.object.soap.base64 | |
value : The object must be serialized with | |
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |
: and then encoded with base64 encoding. | |
mimetype: application/x-microsoft.net.object.bytearray.base64 | |
value : The object must be serialized into a byte array | |
: using a System.ComponentModel.TypeConverter | |
: and then encoded with base64 encoding. | |
--> | |
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |
<xsd:element name="root" msdata:IsDataSet="true"> | |
<xsd:complexType> | |
<xsd:choice maxOccurs="unbounded"> | |
<xsd:element name="metadata"> | |
<xsd:complexType> | |
<xsd:sequence> | |
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | |
</xsd:sequence> | |
<xsd:attribute name="name" use="required" type="xsd:string" /> | |
<xsd:attribute name="type" type="xsd:string" /> | |
<xsd:attribute name="mimetype" type="xsd:string" /> | |
<xsd:attribute ref="xml:space" /> | |
</xsd:complexType> | |
</xsd:element> | |
<xsd:element name="assembly"> | |
<xsd:complexType> | |
<xsd:attribute name="alias" type="xsd:string" /> | |
<xsd:attribute name="name" type="xsd:string" /> | |
</xsd:complexType> | |
</xsd:element> | |
<xsd:element name="data"> | |
<xsd:complexType> | |
<xsd:sequence> | |
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |
</xsd:sequence> | |
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |
<xsd:attribute ref="xml:space" /> | |
</xsd:complexType> | |
</xsd:element> | |
<xsd:element name="resheader"> | |
<xsd:complexType> | |
<xsd:sequence> | |
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
</xsd:sequence> | |
<xsd:attribute name="name" type="xsd:string" use="required" /> | |
</xsd:complexType> | |
</xsd:element> | |
</xsd:choice> | |
</xsd:complexType> | |
</xsd:element> | |
</xsd:schema> | |
<resheader name="resmimetype"> | |
<value>text/microsoft-resx</value> | |
</resheader> | |
<resheader name="version"> | |
<value>2.0</value> | |
</resheader> | |
<resheader name="reader"> | |
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
</resheader> | |
<resheader name="writer"> | |
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
</resheader> | |
<metadata name="OpenFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
<value>17, 17</value> | |
</metadata> | |
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
<value>157, 17</value> | |
</metadata> | |
</root> |
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
namespace ErrorLogLister | |
{ | |
using System; | |
using System.Windows.Forms; | |
internal static class Program | |
{ | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
private static void Main() | |
{ | |
Application.EnableVisualStyles(); | |
Application.SetCompatibleTextRenderingDefault(false); | |
Application.Run(new Form1()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment