Skip to content

Commit

Permalink
Updated to Microsoft.AppCenter ver. 4.3.0 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Jun 26, 2021
1 parent 4ca99b9 commit 57d64ac
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NLog.AzureAppCenter
# NLog.AppCenter
NLog Target for [Microsoft Visual Studio App Center with Azure](https://azure.microsoft.com/services/app-center/)

[![Version](https://badge.fury.io/nu/NLog.Targets.AppCenter.svg)](https://www.nuget.org/packages/NLog.Targets.AppCenter)
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 1.0.0.{build}
image: Visual Studio 2017
image: Visual Studio 2019
configuration: Release
platform: Any CPU
build_script:
- ps: msbuild /t:restore,pack /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /verbosity:minimal
- ps: msbuild /t:restore,pack /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:ContinuousIntegrationBuild=true /p:EmbedUntrackedSources=true /verbosity:minimal
test_script:
- ps: dotnet test tests\NLog.Targets.AppCenter.Tests\NLog.Targets.AppCenter.Tests.csproj
artifacts:
Expand Down
19 changes: 10 additions & 9 deletions src/NLog.Targets.AppCenter/AppCenterTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ protected override void Write(LogEventInfo logEvent)
{
var eventName = RenderLogEvent(Layout, logEvent);
var properties = BuildProperties(logEvent);

if (string.IsNullOrWhiteSpace(eventName))
{
// Avoid event being discarded when name is null or empty
if (logEvent.Exception != null)
eventName = logEvent.Exception.GetType().ToString();
else if (properties?.Count > 0)
eventName = nameof(AppCenterTarget);
}

TrackEvent(eventName, logEvent.Exception, properties);
}

Expand Down Expand Up @@ -178,15 +188,6 @@ private IDictionary<string, string> BuildProperties(LogEventInfo logEvent)

private void TrackEvent(string eventName, Exception exception, IDictionary<string, string> properties = null)
{
if (string.IsNullOrWhiteSpace(eventName))
{
// Avoid event being discarded when name is null or empty
if (exception != null)
eventName = exception.GetType().ToString();
else if (properties?.Count > 0)
eventName = nameof(AppCenterTarget);
}

if (ReportExceptionAsCrash && exception != null)
{
properties = properties ?? new Dictionary<string, string>(1);
Expand Down
23 changes: 16 additions & 7 deletions src/NLog.Targets.AppCenter/NLog.Targets.AppCenter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0;netstandard1.3</TargetFrameworks>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionPrefix>2.2.0</VersionPrefix>
<AssemblyVersion>2.0.0.0</AssemblyVersion> <!-- AssemblyVersion must be fixed on 2.0.0.0 -->
<AppVeyorBuildNumber>$(APPVEYOR_BUILD_NUMBER)</AppVeyorBuildNumber>
<AppVeyorBuildNumber Condition="'$(AppVeyorBuildNumber)' == ''">0</AppVeyorBuildNumber>
Expand All @@ -14,23 +14,32 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NLog/NLog.AppCenter.git</RepositoryUrl>
<PackageTags>AppCenter;NLog;logging;log</PackageTags>
<PackageIconUrl>https://nlog-project.org/N.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/NLog/NLog.AppCenter</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/NLog/NLog.AppCenter/blob/master/LICENSE</PackageLicenseUrl>
<PackageIcon>N.png</PackageIcon>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
<PackageReleaseNotes>
- Updated to Microsoft.AppCenter SDK ver. 3.4.3 (Fix Fix naming conflict with Apple iOS 14)
- Updated to Microsoft.AppCenter SDK ver. 4.3.0 (Bug fixes)
- Enabled deterministic build and SourceLink
</PackageReleaseNotes>

<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

</PropertyGroup>

<Target Name="DownloadMissingContent" BeforeTargets="GenerateNuspec">
<DownloadFile SourceUrl="https://nlog-project.org/N.png" DestinationFolder="$(MSBuildThisFileDirectory)" />
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.4.3" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.4.3" />
<None Include="N.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.3.0" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.3.0" />
<PackageReference Include="NLog" Version="4.5.11" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/NLog.Targets.AppCenter.Tests/StringDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void ContainsTest()
var objectDictionary = new Dictionary<string, object>();
var stringDictionary = new StringDictionary(objectDictionary);
Assert.False(stringDictionary.ContainsKey("key"));
Assert.False(stringDictionary.Contains(new KeyValuePair<string, string>("key", "value")));
Assert.DoesNotContain(new KeyValuePair<string, string>("key", "value"), stringDictionary);
objectDictionary["key"] = "value";
Assert.True(stringDictionary.ContainsKey("key"));
Assert.True(stringDictionary.Contains(new KeyValuePair<string, string>("key", "value")));
Assert.Contains(new KeyValuePair<string, string>("key", "value"), stringDictionary);
}

[Fact]
Expand Down

0 comments on commit 57d64ac

Please sign in to comment.