Skip to content

Commit 66ffb9c

Browse files
committed
Resharper cleanup had removed private setters.
1 parent c884ca9 commit 66ffb9c

File tree

7 files changed

+77
-34
lines changed

7 files changed

+77
-34
lines changed

src/Coderr.Client.Demo/Coderr.Client.Demo.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66
<Version>1.1.0.0</Version>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="Coderr.Client.Log4Net" Version="2.0.0" />
11+
<PackageReference Include="log4net" Version="2.0.12" />
12+
</ItemGroup>
13+
914
<ItemGroup>
1015
<ProjectReference Include="..\Coderr.Client\Coderr.Client.csproj" />
1116
</ItemGroup>
1217

18+
<ItemGroup>
19+
<None Update="log4net.config">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
1324
</Project>

src/Coderr.Client.Demo/Program.cs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
using System;
2-
using System.Collections;
3-
using System.Collections.Generic;
42
using System.IO;
5-
using System.Net.NetworkInformation;
6-
using System.Runtime.InteropServices;
7-
using Coderr.Client;
8-
using Coderr.Client.Contracts;
9-
using Coderr.Client.Uploaders;
3+
using System.Reflection;
4+
using log4net;
5+
using log4net.Config;
106

117
namespace Coderr.Client.Demo
128
{
@@ -15,37 +11,52 @@ class Program
1511
{
1612
static void Main()
1713
{
18-
//var url = new Uri("http://localhost:60473/");
19-
//Err.Configuration.Credentials(url,
20-
// "5a617e0773b94284bef33940e4bc8384",
21-
// "3fab63fb846c4dd289f67b0b3340fefc");
14+
var log = CreateLogger();
15+
log.Info("Starting application");
2216

23-
var url = new Uri("https://report.coderr.io/");
17+
var url = new Uri("http://localhost:60473/");
2418
Err.Configuration.Credentials(url,
25-
"d0c16767d68943dabe94dc581c45557c",
26-
"88db0622561d4d1db389524e13901c22");
19+
"5a617e0773b94284bef33940e4bc8384",
20+
"3fab63fb846c4dd289f67b0b3340fefc");
21+
Err.Configuration.CatchLog4NetExceptions();
22+
23+
Err.Configuration.AddPartition(x =>
24+
{
25+
x.AddPartition("ServerId", Environment.MachineName);
26+
});
2727

2828
Err.Configuration.EnvironmentName = "Production";
2929

3030
try
3131
{
32-
throw new InvalidOperationException("Hello");
32+
log.Debug("Calling hello");
33+
throw new InvalidDataException("Hello, this is an long example exception");
3334
}
3435
catch (Exception ex)
3536
{
36-
//var report = Err.GenerateReport(ex, new { userId = 10, ErrTags = "important" });
37-
//Err.UploadReport(report);
38-
//Err.LeaveFeedback(report.ReportId, "[email protected]", "This is what I did: NOTHING!");
39-
40-
Err.Report(ex, new { userId = 10, ErrTags="console" });
37+
//log.Error("Opps, failed!", ex);
38+
//Err.Report(ex, new { userId = 10, ErrTags = "console" });
39+
var report = Err.GenerateReport(ex, new { userId = 10, ErrTags = "important" });
40+
Err.UploadReport(report);
41+
Err.LeaveFeedback(report.ReportId, "[email protected]", "This is what I did: NOTHING!");
4142
}
4243

44+
return;
4345
Err.ReportLogicError("User should have been assigned.", errorId: "MainN");
4446

4547
ThrowImportantError();
4648
Console.WriteLine("Hello World!");
4749
}
4850

51+
private static ILog CreateLogger()
52+
{
53+
XmlConfigurator.Configure(
54+
new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config")));
55+
var log = LogManager.GetLogger(typeof(Program));
56+
Err.Configuration.CatchLog4NetExceptions(Assembly.GetExecutingAssembly());
57+
return log;
58+
}
59+
4960
public static void ThrowImportantError()
5061
{
5162
try

src/Coderr.Client.Demo/log4net.config

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<log4net>
4+
<appender name="StandardAppender" type="log4net.Appender.RollingFileAppender">
5+
<file value="c:\logs\Coderr.demo.log" />
6+
<appendToFile value="true" />
7+
<rollingStyle value="Date" />
8+
<PreserveLogFileNameExtension value="true" />
9+
<datePattern value="yyyy-MM-dd" />
10+
<filter type="log4net.Filter.LoggerMatchFilter">
11+
<loggerToMatch value="Coderr.Server.Infrastructure.Messaging" />
12+
<acceptOnMatch value="true" />
13+
</filter>
14+
<filter type="log4net.Filter.DenyAllFilter" />
15+
<layout type="log4net.Layout.PatternLayout">
16+
<conversionPattern value="%date [%thread] %-5level %logger %message%newline" />
17+
</layout>
18+
</appender>
19+
<root>
20+
<level value="ALL" />
21+
<appender-ref ref="StandardAppender" />
22+
</root>
23+
</log4net>

src/Coderr.Client/Coderr.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Client.xml</DocumentationFile>
77
<RootNamespace>Coderr.Client</RootNamespace>
88

9-
<PackageReleaseNotes>Added missing reference for .NET 4.7.2</PackageReleaseNotes>
10-
<Version>2.0.4</Version>
9+
<PackageReleaseNotes>Resharper cleanup removed private setters.</PackageReleaseNotes>
10+
<Version>2.0.5</Version>
1111
</PropertyGroup>
1212

1313
<PropertyGroup>

src/Coderr.Client/Contracts/ErrorReportDTO.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ protected ErrorReportDTO()
4343
/// <summary>
4444
/// To get exact date
4545
/// </summary>
46-
public DateTime CreatedAtUtc { get; }
46+
public DateTime CreatedAtUtc { get; private set; }
4747

4848

4949
/// <summary>
5050
/// Exception which was caught.
5151
/// </summary>
52-
public ExceptionDTO Exception { get; }
52+
public ExceptionDTO Exception { get; private set; }
5353

5454
/// <summary>
5555
/// For backwards compatibility
@@ -76,7 +76,7 @@ protected string IncidentId
7676
/// <example>
7777
/// 1.0
7878
/// </example>
79-
public string ReportVersion { get; }
79+
public string ReportVersion { get; private set; }
8080

8181
/// <summary>
8282
/// Application environment (like "Test" and "Production")

src/Coderr.Client/Contracts/LogEntryDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public LogEntryDto(DateTime timestampUtc, int logLevel, string message)
2525
/// </summary>
2626
/// <remarks>
2727
/// <para>
28-
/// Seralization constructor
28+
/// Serialization constructor
2929
/// </para>
3030
/// </remarks>
3131
protected LogEntryDto()

src/Coderr.Client/Uploaders/UploadToCoderr.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ public UploadToCoderr(Uri oneTrueHost, string apiKey, string sharedSecret)
7373
/// <summary>
7474
/// Initializes a new instance of the <see cref="UploadToCoderr" /> class.
7575
/// </summary>
76-
/// <param name="oneTrueHost">
77-
/// Uri to the root of the codeRR web. Example.
78-
/// <code>http://yourWebServer/codeRR/</code>
76+
/// <param name="coderrHost">
77+
/// Uri to the root of the Coderr web site. Example.
78+
/// <code>http://yourWebServer/coderr/</code>
7979
/// </param>
8080
/// <param name="apiKey">The API key.</param>
8181
/// <param name="sharedSecret">The shared secret.</param>
8282
/// <param name="config">parameters for tests</param>
8383
/// <exception cref="System.ArgumentNullException">apiKey</exception>
84-
internal UploadToCoderr(Uri oneTrueHost, string apiKey, string sharedSecret, TestConfig config)
85-
: this(oneTrueHost, apiKey, sharedSecret)
84+
internal UploadToCoderr(Uri coderrHost, string apiKey, string sharedSecret, TestConfig config)
85+
: this(coderrHost, apiKey, sharedSecret)
8686
{
8787
_queueReportsAccessor = config.QueueReportsAccessor;
8888
_throwExceptionsAccessor = config.ThrowExceptionsAccessor;
@@ -143,13 +143,11 @@ internal HttpRequestMessage CreateRequest(string uri, object dto)
143143

144144

145145
var ms = new MemoryStream();
146-
147146
using (var gzip = new GZipStream(ms, CompressionLevel.Optimal, true))
148147
{
149148
gzip.Write(jsonBytes, 0, jsonBytes.Length);
150149
gzip.Flush();
151150
}
152-
153151
var requestBody = ms.ToArray();
154152

155153
var content = new ByteArrayContent(requestBody);
@@ -171,7 +169,7 @@ internal HttpRequestMessage CreateRequest(string uri, object dto)
171169
uri = uri + "?v=1&throw=" + (Err.Configuration.ThrowExceptions ? "1" : "0");
172170
}
173171

174-
return new HttpRequestMessage(HttpMethod.Post, uri) {Content = content};
172+
return new HttpRequestMessage(HttpMethod.Post, uri) { Content = content };
175173
}
176174

177175
internal void UploadFeedbackNow(FeedbackDTO dto)

0 commit comments

Comments
 (0)