Skip to content

Commit 95c7e22

Browse files
committed
Fix logging and mzML
* Log4net configuration moved to App.config * Fixed unhandled exception during mzML precursor creation * Explicit usings * Properties (some build/debug information from VS) ignored TODO Check all "possibly null reference" warnings
1 parent df89589 commit 95c7e22

File tree

10 files changed

+55
-82
lines changed

10 files changed

+55
-82
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ obj/
66
.vs/
77
*.csproj.user
88
.vscode/
9+
Properties/

App.config

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
4+
<configSections>
5+
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
6+
</configSections>
7+
8+
<log4net>
9+
<root>
10+
<level value="INFO" />
11+
<appender-ref ref="console" />
12+
<!-- <appender-ref ref="file" /> -->
13+
</root>
14+
<appender name="console" type="log4net.Appender.ConsoleAppender">
15+
<layout type="log4net.Layout.PatternLayout">
16+
<conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} %level %message%newline" />
17+
</layout>
18+
</appender>
19+
<!--<appender name="file" type="log4net.Appender.RollingFileAppender">
20+
<file value="ThermoRawFileParser.log" />
21+
<appendToFile value="true" />
22+
<rollingStyle value="Size" />
23+
<maxSizeRollBackups value="5" />
24+
<maximumFileSize value="10MB" />
25+
<staticLogFileName value="true" />
26+
<layout type="log4net.Layout.PatternLayout">
27+
<conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} [%thread] %message%newline" />
28+
</layout>
29+
</appender>-->
30+
</log4net>
31+
332
<runtime>
433
<loadFromRemoteSources enabled="true" />
5-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
6-
<dependentAssembly>
7-
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
8-
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
9-
</dependentAssembly>
10-
<dependentAssembly>
11-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
12-
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
13-
</dependentAssembly>
14-
<dependentAssembly>
15-
<assemblyIdentity name="OpenMcdf" publicKeyToken="fdbb1629d7c00800" culture="neutral" />
16-
<bindingRedirect oldVersion="0.0.0.0-2.2.1.9" newVersion="2.2.1.9" />
17-
</dependentAssembly>
18-
<dependentAssembly>
19-
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
20-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
21-
</dependentAssembly>
22-
<dependentAssembly>
23-
<assemblyIdentity name="ThermoFisher.CommonCore.Data" publicKeyToken="1aef06afb5abd953" culture="neutral" />
24-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.88" newVersion="5.0.0.88" />
25-
</dependentAssembly>
26-
<dependentAssembly>
27-
<assemblyIdentity name="System.IO.FileSystem.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
28-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
29-
</dependentAssembly>
30-
<dependentAssembly>
31-
<assemblyIdentity name="OpenMcdf.Extensions" publicKeyToken="fdbb1629d7c00800" culture="neutral" />
32-
<bindingRedirect oldVersion="0.0.0.0-2.3.0.0" newVersion="2.3.0.0" />
33-
</dependentAssembly>
34-
<dependentAssembly>
35-
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
36-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
37-
</dependentAssembly>
38-
<dependentAssembly>
39-
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
40-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
41-
</dependentAssembly>
42-
</assemblyBinding>
4334
</runtime>
4435
</configuration>

MainClass.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
using System.Text.RegularExpressions;
1414
using System.Data;
1515

16+
[assembly: log4net.Config.XmlConfigurator()]
17+
1618
namespace ThermoRawFileParser
1719
{
1820
public static class MainClass
1921
{
2022
private static readonly ILog Log =
21-
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
23+
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
2224

2325
public const string Version = "1.4.5";
2426
public static void Main(string[] args)
@@ -125,7 +127,7 @@ private static void XicParametersParsing(string[] args)
125127

126128
if (parameters.help)
127129
{
128-
ShowHelp("usage is:", null,
130+
ShowHelp("usage is:", new OptionException(),
129131
optionSet);
130132
return;
131133
}
@@ -253,12 +255,12 @@ private static void XicParametersParsing(string[] args)
253255
{
254256
if (parameters.help)
255257
{
256-
ShowHelp("usage is:", null,
258+
ShowHelp("usage is:", new OptionException(),
257259
optionSet);
258260
}
259261
else
260262
{
261-
ShowHelp("Error - usage is:", null,
263+
ShowHelp("Error - usage is:", new OptionException(),
262264
optionSet);
263265
}
264266
}
@@ -374,7 +376,7 @@ private static void SpectrumQueryParametersParsing(string[] args)
374376

375377
if (parameters.help)
376378
{
377-
ShowHelp("usage is:", null,
379+
ShowHelp("usage is:", new OptionException(),
378380
optionSet);
379381
return;
380382
}
@@ -416,12 +418,12 @@ private static void SpectrumQueryParametersParsing(string[] args)
416418
{
417419
if (parameters.help)
418420
{
419-
ShowHelp("usage is:", null,
421+
ShowHelp("usage is:", new OptionException(),
420422
optionSet);
421423
}
422424
else
423425
{
424-
ShowHelp("Error - usage is:", null,
426+
ShowHelp("Error - usage is:", new OptionException(),
425427
optionSet);
426428
}
427429
}
@@ -623,7 +625,7 @@ private static void RegularParametersParsing(string[] args)
623625
{
624626
var helpMessage =
625627
$"Usage is {Assembly.GetExecutingAssembly().GetName().Name}.exe [subcommand] [options]\noptional subcommands are xic|query (use [subcommand] -h for more info]):";
626-
ShowHelp(helpMessage, null, optionSet);
628+
ShowHelp(helpMessage, new OptionException(), optionSet);
627629
return;
628630
}
629631

@@ -788,12 +790,12 @@ private static void RegularParametersParsing(string[] args)
788790
{
789791
if (help)
790792
{
791-
ShowHelp("usage is:", null,
793+
ShowHelp("usage is:", new OptionException(),
792794
optionSet);
793795
}
794796
else
795797
{
796-
ShowHelp("Error - usage is:", null,
798+
ShowHelp("Error - usage is:", new OptionException(),
797799
optionSet);
798800
}
799801
}

Query/ProxiSpectrum.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
63
using ThermoRawFileParser.Writer;
74

85
namespace ThermoRawFileParser.Query

RawFileParser.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4+
using System.Reflection;
45
using System.Runtime.InteropServices;
6+
using log4net;
57
using ThermoFisher.CommonCore.Data;
68
using ThermoFisher.CommonCore.Data.Business;
79
using ThermoFisher.CommonCore.Data.Interfaces;
@@ -12,8 +14,8 @@ namespace ThermoRawFileParser
1214
{
1315
public static class RawFileParser
1416
{
15-
private static readonly log4net.ILog Log =
16-
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
17+
private static readonly ILog Log =
18+
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1719

1820
/// <summary>
1921
/// Process and extract the RAW file(s).

ThermoRawFileParser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
6+
<ImplicitUsings>disable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<StartupObject>ThermoRawFileParser.MainClass</StartupObject>
99
<PlatformTarget>x64</PlatformTarget>

Writer/MzMlSpectrumWriter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
653653
Writer.Flush();
654654
Writer.Close();
655655

656-
if (_doIndexing)
656+
//This section is not necessary?
657+
/*if (_doIndexing)
657658
{
658659
try
659660
{
@@ -665,7 +666,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
665666
// Cannot access a closed file. CryptoStream was already closed when closing _writer
666667
Log.Warn($"Warning: {e.Message}");
667668
}
668-
}
669+
}*/
669670
}
670671

671672
// In case of indexed mzML, change the extension from xml to mzML and check for the gzip option
@@ -2450,7 +2451,7 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
24502451
reactionCount++;
24512452
}
24522453
}
2453-
catch (ArgumentOutOfRangeException)
2454+
catch (IndexOutOfRangeException)
24542455
{
24552456
// If we failed do nothing
24562457
}

XIC/XicExecutor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Data;
32
using System.IO;
43
using System.Text;
54
using System.Reflection;

XIC/XicReader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
using System;
2+
using System.IO;
13
using System.Reflection;
4+
using System.Collections.Generic;
25
using System.Runtime.InteropServices;
36
using log4net;
47
using ThermoFisher.CommonCore.Data;

log4net.config

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)