Skip to content

Commit 3a47cca

Browse files
committed
Ported the sample console app to .NET Core
1 parent fb3b340 commit 3a47cca

File tree

10 files changed

+60
-52
lines changed

10 files changed

+60
-52
lines changed

Exceptionless.Net.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exceptionless.Wpf", "src\Pl
4747
EndProject
4848
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{2CEE12C6-3840-4C01-A952-D3026B0A662A}"
4949
EndProject
50-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Exceptionless.SampleConsole", "src\Samples\Exceptionless.SampleConsole\Exceptionless.SampleConsole.xproj", "{12917A87-59E3-4E26-9E14-6CC49A55996E}"
51-
EndProject
5250
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exceptionless.SampleWindows", "src\Samples\Exceptionless.SampleWindows\Exceptionless.SampleWindows.csproj", "{34FE8E6E-247B-46DD-967E-46E45D1CAE6D}"
5351
ProjectSection(ProjectDependencies) = postProject
5452
{C3664CAF-6DE9-4049-951F-516C10FBA012} = {C3664CAF-6DE9-4049-951F-516C10FBA012}
@@ -90,6 +88,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Exceptionless.AspNetCore",
9088
EndProject
9189
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Exceptionless.SampleAspNetCore", "src\Samples\Exceptionless.SampleAspNetCore\Exceptionless.SampleAspNetCore.xproj", "{D7039656-8587-49CC-8657-5C9BDCFC1C80}"
9290
EndProject
91+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Exceptionless.SampleConsole", "src\Samples\Exceptionless.SampleConsole\Exceptionless.SampleConsole.xproj", "{23645F73-57D8-4D70-BE1A-37903A8E4A18}"
92+
EndProject
9393
Global
9494
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9595
Debug|Any CPU = Debug|Any CPU
@@ -136,10 +136,6 @@ Global
136136
{0F4730E7-953F-4F20-A337-9FB43A9AFBEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
137137
{0F4730E7-953F-4F20-A337-9FB43A9AFBEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
138138
{0F4730E7-953F-4F20-A337-9FB43A9AFBEA}.Release|Any CPU.Build.0 = Release|Any CPU
139-
{12917A87-59E3-4E26-9E14-6CC49A55996E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
140-
{12917A87-59E3-4E26-9E14-6CC49A55996E}.Debug|Any CPU.Build.0 = Debug|Any CPU
141-
{12917A87-59E3-4E26-9E14-6CC49A55996E}.Release|Any CPU.ActiveCfg = Release|Any CPU
142-
{12917A87-59E3-4E26-9E14-6CC49A55996E}.Release|Any CPU.Build.0 = Release|Any CPU
143139
{34FE8E6E-247B-46DD-967E-46E45D1CAE6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
144140
{34FE8E6E-247B-46DD-967E-46E45D1CAE6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
145141
{34FE8E6E-247B-46DD-967E-46E45D1CAE6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -176,6 +172,10 @@ Global
176172
{D7039656-8587-49CC-8657-5C9BDCFC1C80}.Debug|Any CPU.Build.0 = Debug|Any CPU
177173
{D7039656-8587-49CC-8657-5C9BDCFC1C80}.Release|Any CPU.ActiveCfg = Release|Any CPU
178174
{D7039656-8587-49CC-8657-5C9BDCFC1C80}.Release|Any CPU.Build.0 = Release|Any CPU
175+
{23645F73-57D8-4D70-BE1A-37903A8E4A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
176+
{23645F73-57D8-4D70-BE1A-37903A8E4A18}.Debug|Any CPU.Build.0 = Debug|Any CPU
177+
{23645F73-57D8-4D70-BE1A-37903A8E4A18}.Release|Any CPU.ActiveCfg = Release|Any CPU
178+
{23645F73-57D8-4D70-BE1A-37903A8E4A18}.Release|Any CPU.Build.0 = Release|Any CPU
179179
EndGlobalSection
180180
GlobalSection(SolutionProperties) = preSolution
181181
HideSolutionNode = FALSE
@@ -189,7 +189,6 @@ Global
189189
{E29380A2-85E5-468E-8D09-4E1CFDF5E90E} = {D363E15F-621D-40E4-8C96-DEE41A7070FF}
190190
{159FB9D1-E226-4828-B2A5-FEDD994F3525} = {D363E15F-621D-40E4-8C96-DEE41A7070FF}
191191
{0F4730E7-953F-4F20-A337-9FB43A9AFBEA} = {D363E15F-621D-40E4-8C96-DEE41A7070FF}
192-
{12917A87-59E3-4E26-9E14-6CC49A55996E} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
193192
{34FE8E6E-247B-46DD-967E-46E45D1CAE6D} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
194193
{C54027FA-B334-49C7-A58B-94B57677556C} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
195194
{02EBBB5A-0F11-461E-9778-010F69C36545} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
@@ -199,5 +198,6 @@ Global
199198
{B7075822-FBB6-4B3A-A639-37C39DC27BB6} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
200199
{F949CF8F-9D5F-454B-B20A-D8F9C22B70D9} = {D363E15F-621D-40E4-8C96-DEE41A7070FF}
201200
{D7039656-8587-49CC-8657-5C9BDCFC1C80} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
201+
{23645F73-57D8-4D70-BE1A-37903A8E4A18} = {2CEE12C6-3840-4C01-A952-D3026B0A662A}
202202
EndGlobalSection
203203
EndGlobal

src/Exceptionless.Tests/project.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"testRunner": "xunit",
33
"buildOptions": {
44
"optimize": true,
5-
"warningsAsErrors": true
5+
"warningsAsErrors": true,
6+
"copyToOutput": {
7+
"include": [ "xunit.runner.json" ]
8+
}
69
},
710
"dependencies": {
811
"BenchmarkDotNet": "0.9.6",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"diagnosticMessages": true,
3+
"methodDisplay": "method"
4+
}

src/Platforms/Exceptionless.NLog/project.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"buildOptions": {
23-
"compile": [ "**/*.cs", "../../GlobalAssemblyInfo.cs" ],
23+
"compile": [ "**/*.cs", "../../GlobalAssemblyInfo.cs" ],
2424
"nowarn": [
2525
"CS1591"
2626
],
@@ -31,13 +31,24 @@
3131
"dependencies": {
3232
"Exceptionless": {
3333
"target": "project"
34-
},
35-
"NLog": "4.3.3"
34+
}
3635
},
3736
"frameworks": {
37+
"netstandard1.3": {
38+
"buildOptions": {
39+
"debugType": "portable",
40+
"define": [ "NETSTANDARD", "NETSTANDARD1_3" ]
41+
},
42+
"dependencies": {
43+
"NLog": "4.4.0-beta11"
44+
}
45+
},
3846
"net45": {
3947
"buildOptions": {
4048
"define": [ "NET45" ]
49+
},
50+
"dependencies": {
51+
"NLog": "4.3.4"
4152
}
4253
}
4354
}

src/Samples/Exceptionless.SampleConsole/Exceptionless.SampleConsole.xproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
55
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
66
</PropertyGroup>
7-
87
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
98
<PropertyGroup Label="Globals">
10-
<ProjectGuid>12917a87-59e3-4e26-9e14-6cc49a55996e</ProjectGuid>
9+
<ProjectGuid>23645f73-57d8-4d70-be1a-37903a8e4a18</ProjectGuid>
1110
<RootNamespace>Exceptionless.SampleConsole</RootNamespace>
1211
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
1312
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
1413
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1514
</PropertyGroup>
16-
1715
<PropertyGroup>
1816
<SchemaVersion>2.0</SchemaVersion>
1917
</PropertyGroup>
2018
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
21-
</Project>
19+
</Project>

src/Samples/Exceptionless.SampleConsole/Plugins/SystemUptimePlugin.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@ public void Run(EventPluginContext context) {
1010
// Only update feature usage events.
1111
if (context.Event.Type != Event.KnownTypes.FeatureUsage)
1212
return;
13+
14+
var uptime = TimeSpan.FromSeconds((double)Stopwatch.GetTimestamp() / Stopwatch.Frequency);
1315

14-
// Get the system uptime
15-
using (var pc = new PerformanceCounter("System", "System Up Time")) {
16-
pc.NextValue();
17-
18-
var uptime = TimeSpan.FromSeconds(pc.NextValue());
19-
20-
// Store the system uptime as an extended property.
21-
context.Event.SetProperty("System Uptime", $"{uptime.Days} Days {uptime.Hours} Hours {uptime.Minutes} Minutes {uptime.Seconds} Seconds");
22-
}
16+
// Store the system uptime as an extended property.
17+
context.Event.SetProperty("System Uptime", $"{uptime.Days} Days {uptime.Hours} Hours {uptime.Minutes} Minutes {uptime.Seconds} Seconds");
2318
}
2419
}
2520
}

src/Samples/Exceptionless.SampleConsole/Program.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
using Exceptionless.Logging;
1111
using Exceptionless.Models;
1212
using Exceptionless.SampleConsole.Plugins;
13+
#if NET45
1314
using log4net;
1415
using log4net.Config;
16+
#endif
1517
using NLog;
1618
using LogLevel = Exceptionless.Logging.LogLevel;
1719

@@ -47,13 +49,15 @@ public static void Main(string[] args) {
4749
GlobalDiagnosticsContext.Set("GlobalProp", "GlobalValue");
4850
//Log.Info().Message("Hi").Tag("Tag1", "Tag2").Property("LocalProp", "LocalValue").MarkUnhandled("SomeMethod").ContextProperty("Blah", new Event()).Write();
4951

50-
//ExceptionlessClient.Default.SubmitLog(typeof(Program).Name, "Trace Message", LogLevel.Trace);
52+
//ExceptionlessClient.Default.SubmitLog(typeof(Program).Name, "Trace Message", LogLevel.Trace);
5153

54+
#if NET45
5255
// test log4net
5356
XmlConfigurator.Configure();
5457
GlobalContext.Properties["GlobalProp"] = "GlobalValue";
5558
ThreadContext.Properties["LocalProp"] = "LocalValue";
5659
//_log4net.Info("Hi");
60+
#endif
5761

5862
var tokenSource = new CancellationTokenSource();
5963
CancellationToken token = tokenSource.Token;
@@ -158,7 +162,7 @@ private static void SampleApiUsages() {
158162
ExceptionlessClient.Default.SubmitSessionStart();
159163

160164
try {
161-
throw new ApplicationException("Test");
165+
throw new Exception("Test");
162166
} catch (Exception ex) {
163167
ex.ToExceptionless().AddTags("SomeTag").Submit();
164168
}

src/Samples/Exceptionless.SampleConsole/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
using System.Runtime.InteropServices;
44
//using Exceptionless.Configuration;
55

6-
// General Information about an assembly is controlled through the following
7-
// set of attributes. Change these attribute values to modify the information
8-
// associated with an assembly.
9-
106
[assembly: AssemblyTitle("SampleConsole")]
117
[assembly: AssemblyCulture("")]
128
[assembly: ComVisible(false)]
139
[assembly: Guid("2a45b7bb-82b6-4055-8c8e-1a3c81afb4f1")]
1410

15-
[assembly: AssemblyVersion("2.0.*")]
1611

1712
// example of setting an attribute value in config.
1813
//[assembly: ExceptionlessSetting("AttributeSettings", "AttributeValue")]

src/Samples/Exceptionless.SampleConsole/project.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
{
1+
{
22
"buildOptions": {
3-
"emitEntryPoint": true,
4-
"warningsAsErrors": true
3+
"compile": [
4+
"**/*.cs",
5+
"../../GlobalAssemblyInfo.cs",
6+
"../../Exceptionless.Tests/Utility/RandomEventGenerator.cs"
7+
],
8+
"emitEntryPoint": true
59
},
610
"dependencies": {
711
"Exceptionless": {
812
"target": "project"
913
},
10-
"Exceptionless.DateTimeExtensions": "3.1.45",
11-
"Exceptionless.Log4net": {
12-
"target": "project"
13-
},
14+
"Exceptionless.DateTimeExtensions": "3.2.52",
1415
"Exceptionless.NLog": {
1516
"target": "project"
1617
},
17-
"Exceptionless.RandomData": "1.0.22.0",
18-
"log4net": "2.0.5",
19-
"NLog": "4.3.3",
20-
"NLog.Config": "4.3.3",
21-
"NLog.Schema": "4.3.0"
18+
"Exceptionless.RandomData": "1.1.23",
19+
"Microsoft.NETCore.App": {
20+
"type": "platform",
21+
"version": "1.0.0-rc2-3002702"
22+
}
2223
},
2324
"frameworks": {
24-
"net45": {
25+
"netcoreapp1.0": {
2526
"buildOptions": {
26-
"define": [ "NET45" ],
27-
"compile": [
28-
"**/*.cs",
29-
"../../Exceptionless.Tests/Utility/RandomEventGenerator.cs"
30-
]
27+
"debugType": "portable",
28+
"define": [ "NETSTANDARD", "NETSTANDARD1_5" ]
3129
}
3230
}
3331
}

tools/Build.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ForEach ($p in $client_projects) {
99
dotnet build "$($p.SourceDir)" -c Release
1010
Write-Host "Finished building $($p.Name)" -ForegroundColor Yellow
1111

12-
If (-not $?) {
12+
If ($LASTEXITCODE -ne 0)
1313
$anyError = $True
1414
}
1515

@@ -51,7 +51,7 @@ ForEach ($p in $client_projects) {
5151
/p:TargetFrameworkVersionProperty="$($b.TargetFrameworkVersionProperty)" `
5252
/t:"Rebuild"
5353
}
54-
If (-not $?) {
54+
If ($LASTEXITCODE -ne 0)
5555
$anyError = $True
5656
}
5757

@@ -62,5 +62,5 @@ ForEach ($p in $client_projects) {
6262
Pop-Location
6363

6464
If ($anyError) {
65-
exit 1
65+
throw "One or more builds failed"
6666
}

0 commit comments

Comments
 (0)