Skip to content

Instantly share code, notes, and snippets.

@blachniet
Last active April 15, 2018 18:42
Show Gist options
  • Save blachniet/5100e2bf231a800e37fba0c1e73ac39e to your computer and use it in GitHub Desktop.
Save blachniet/5100e2bf231a800e37fba0c1e73ac39e to your computer and use it in GitHub Desktop.

Differences from apache/avro master

Target Frameworks

All projects targeted .NET Framework 3.5 both before and after these changes. Some projects additionally target some additional frameworks:

  • Executable projects (including the unit test project) target .NET Core 2.0
  • Library projects target .NET Standard 2.0
  • All projects target .NET Framework 3.5 & 4.0

Project Target Framework Table

Project .NET Standard 2.0 .NET Core 2.0 .NET Framework 3.5 .NET Framework 4.0
Avro.codegen ✔️ ✔️ ✔️
Avro.ipc ✔️ ✔️
Avro.ipc.test ✔️ ✔️
Avro.main ✔️ ✔️ ✔️
Avro.msbuild ✔️ ✔️ ✔️
Avro.perf ✔️ ✔️ ✔️
Avro.test ✔️ ✔️ ✔️

IPC

I kept running into various issues with unit tests for the IPC project. Instead of holding up the transition to .NET Standard for the for the other projects. I decided, to move the IPC tests into their own project, Avro.ipc.test. This new project, as well as the Avro.ipc test, only target .NET Framework 3.5 and 4.0.

Targeting .NET Framework 4.0

We are targeting .NET Framework 4.0 in addition to 3.5 so that end users are not required to install .NET Framework 3.5 just for the Avro library. From Targeting and running apps for older versions:

In addition, if your app targets version 2.0, 3.0, or 3.5, your users may be required to enable the .NET Framework 3.5 on a Windows 8 or Windows 8.1 computer before they can run your app.

By targeting both 3.5 and 4.0:

  • An app that targets 3.5 still works
  • An app that targets 4.0+ does not require that 3.5 is installed on the end user's machine

NUnit 3

This PR includes all changes from PR 299 (AVRO-2161). At the time of this writing, PR 299 has not been merged into the apache/avro master branch (PR is still open). commit 884cc0ba3a4462b85a5c97173cbff58c0253b47f

NuGet Dependencies

Removed DLLs that we depend on from the lib/ folder and instead refernce their NuGet package equivalents.

Unit Tests

Disabled unit tests that rely on System.CodeDom compilation when targeting .NET Core. See this comment for a description of why this is necessary. These tests are enabled when targeting the .NET Framework. commit 58cfdf3a456001c9aab36ed4fec3a539197c24a3

The table below shows the number of passing unit tests before and after for each target framework.

.NET 3.5 .NET 4.0 .NET Core 2.0
Before 520 N/A N/A
After 520 520 498*

*.NET Core 2.0 has fewer tests because IPC is not currently targeting .NET Standard/Core, and a few tests relied on System.CodeDom compilation.

 520
-  3 System.CodeDom compilation tests not supported by .NET Core
- 19 IPC tests - IPC not targeting .NET Standard/Core at this time
====
 498

Support for Later Versions of Newtonsoft.Json

In Newtonsoft.Json v3.5, JToken.ToString() returned the raw JSON representation of the token. In later versions of Newtonsoft.Json, JToken.ToString() returns a simple string representation of the value. For example:

JToken token = "Hello World";
Console.WriteLine(token.ToString()); 

The code block above prints different values depending on the version of Newtonsoft.Json in use:

  • v3.5: \"Hello World\"
  • Later versions: Hello World

In this commit, I've updated the project to work with later versions of Newtonsoft.Json as well as v3.5. I've replaced some usages of JToken.ToString(). When we need the raw JSON representation, we use JsonConvert.Serialize(). When we need the string value of a string JToken, we use JToken.Value<string>().

See commit 8fe9db3f764666d0d3ede27159207d74bd38b0d2

Note that the project still references Newtonsoft.Json v3.5. The changes I describe above enable clients to use later versions of Newtonsoft.Json without breaking compatibility with Newtonsoft.Json v3.5.

This change fixes the two TestAliases unit tests that were failing in PR 300.

Differences from PR 300

  • Unit Tests: One test project that targets .NET Core & .NET Framework. PR 300 had one test project per target with copied code files.
  • Target Frameworks: Continued support for .NET Framework 3.5. PR 300 had deprecated this.
  • Newtonsoft.Json: Continued support for Newtonsoft.Json 3.5. PR 300 referenced Newtonsoft.Json 9.0.1.

Future Work

  • Update README
  • Fix tests on Linux (see this comment on bug: microsoft/testfx#203 (comment)
  • Does Mono still work? Do we still want to support it?
  • Do we need a build script for Linux/Mac?
  • Publish a NuGet packages on nuget.org.
  • VS Code project configurations?
  • Remove all build profiles except "Any CPU" from solution?
  • Update the exe projects' "Platform target" to "Any CPU" (currently "x86").
  • There are some usages of JToken.ToString() in exceptions messages that we may want to replace
  • Microsoft.NET.Test.Sdk references Newtonsoft.Json v9.0.1. Is that a problem?
  • Do we want to continue to support .NET 3.5?
  • Do we want to require a newer version of Newtonsoft.Json?

Other Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment