1*6777b538SAndroid Build Coastguard WorkerThis directory contains the C# Protocol Buffers runtime library. 2*6777b538SAndroid Build Coastguard Worker 3*6777b538SAndroid Build Coastguard WorkerUsage 4*6777b538SAndroid Build Coastguard Worker===== 5*6777b538SAndroid Build Coastguard Worker 6*6777b538SAndroid Build Coastguard WorkerThe easiest way how to use C# protobufs is via the `Google.Protobuf` 7*6777b538SAndroid Build Coastguard WorkerNuGet package. Just add the NuGet package to your VS project. 8*6777b538SAndroid Build Coastguard Worker 9*6777b538SAndroid Build Coastguard WorkerYou will also want to install the `Google.Protobuf.Tools` NuGet package, which 10*6777b538SAndroid Build Coastguard Workercontains precompiled version of `protoc.exe` and a copy of well known `.proto` 11*6777b538SAndroid Build Coastguard Workerfiles under the package's `tools` directory. 12*6777b538SAndroid Build Coastguard Worker 13*6777b538SAndroid Build Coastguard WorkerTo generate C# files from your `.proto` files, invoke `protoc` with the 14*6777b538SAndroid Build Coastguard Worker`--csharp_out` option. 15*6777b538SAndroid Build Coastguard Worker 16*6777b538SAndroid Build Coastguard WorkerSupported platforms 17*6777b538SAndroid Build Coastguard Worker=================== 18*6777b538SAndroid Build Coastguard Worker 19*6777b538SAndroid Build Coastguard WorkerThe runtime library is built as a portable class library, supporting: 20*6777b538SAndroid Build Coastguard Worker 21*6777b538SAndroid Build Coastguard Worker- .NET 4.5 22*6777b538SAndroid Build Coastguard Worker- Windows 8 23*6777b538SAndroid Build Coastguard Worker- Windows Phone Silverlight 8 24*6777b538SAndroid Build Coastguard Worker- Windows Phone 8.1 25*6777b538SAndroid Build Coastguard Worker- .NET Core 26*6777b538SAndroid Build Coastguard Worker 27*6777b538SAndroid Build Coastguard WorkerYou should be able to use Protocol Buffers in Visual Studio 2012 and 28*6777b538SAndroid Build Coastguard Workerall later versions. This includes all code generated by `protoc`, 29*6777b538SAndroid Build Coastguard Workerwhich only uses features from C# 3 and earlier. 30*6777b538SAndroid Build Coastguard Worker 31*6777b538SAndroid Build Coastguard WorkerBuilding 32*6777b538SAndroid Build Coastguard Worker======== 33*6777b538SAndroid Build Coastguard Worker 34*6777b538SAndroid Build Coastguard WorkerOpen the `src/Google.Protobuf.sln` solution in Visual Studio 2017 or 35*6777b538SAndroid Build Coastguard Workerlater. 36*6777b538SAndroid Build Coastguard Worker 37*6777b538SAndroid Build Coastguard WorkerAlthough *users* of this project are only expected to have Visual 38*6777b538SAndroid Build Coastguard WorkerStudio 2012 or later, *developers* of the library are required to 39*6777b538SAndroid Build Coastguard Workerhave Visual Studio 2017 or later, as the library uses C# 6 features 40*6777b538SAndroid Build Coastguard Workerin its implementation, as well as the new Visual Studio 2017 csproj 41*6777b538SAndroid Build Coastguard Workerformat. These features have no impact when using the compiled code - 42*6777b538SAndroid Build Coastguard Workerthey're only relevant when building the `Google.Protobuf` assembly. 43*6777b538SAndroid Build Coastguard Worker 44*6777b538SAndroid Build Coastguard WorkerIn order to run and debug the AddressBook example in the IDE, you must 45*6777b538SAndroid Build Coastguard Workerinstall the optional component, ".Net Core 1.0 - 1.1 development tools 46*6777b538SAndroid Build Coastguard Workerfor Web" (as it's labelled in current versions of the VS2017 47*6777b538SAndroid Build Coastguard Workerinstaller), above and beyond the main .NET Core cross-platform 48*6777b538SAndroid Build Coastguard Workerdevelopment feature. 49*6777b538SAndroid Build Coastguard Worker 50*6777b538SAndroid Build Coastguard WorkerTesting 51*6777b538SAndroid Build Coastguard Worker======= 52*6777b538SAndroid Build Coastguard Worker 53*6777b538SAndroid Build Coastguard WorkerThe unit tests use [NUnit 3](https://github.com/nunit/nunit). Tests can be 54*6777b538SAndroid Build Coastguard Workerrun using the Visual Studio Test Explorer or `dotnet test`. 55*6777b538SAndroid Build Coastguard Worker 56*6777b538SAndroid Build Coastguard Worker.NET 3.5 57*6777b538SAndroid Build Coastguard Worker======== 58*6777b538SAndroid Build Coastguard Worker 59*6777b538SAndroid Build Coastguard WorkerWe don't officially support .NET 3.5. However, there has been some effort 60*6777b538SAndroid Build Coastguard Workerto make enabling .NET 3.5 support relatively painless in case you require it. 61*6777b538SAndroid Build Coastguard WorkerThere's no guarantee that this will continue in the future, so rely on .NET 62*6777b538SAndroid Build Coastguard Worker3.5 support at your peril. 63*6777b538SAndroid Build Coastguard Worker 64*6777b538SAndroid Build Coastguard WorkerTo enable .NET 3.5 support, you must edit the `TargetFrameworks` elements of 65*6777b538SAndroid Build Coastguard Worker[src/Google.Protobuf/Google.Protobuf.csproj](src/Google.Protobuf/Google.Protobuf.csproj) 66*6777b538SAndroid Build Coastguard Worker(and [src/Google.Protobuf.Test/Google.Protobuf.Test.csproj](src/Google.Protobuf.Test/Google.Protobuf.Test.csproj) 67*6777b538SAndroid Build Coastguard Workerif you want to run the unit tests): 68*6777b538SAndroid Build Coastguard Worker 69*6777b538SAndroid Build Coastguard WorkerOpen the .csproj file in a text editor and simply add `net35` to the list of 70*6777b538SAndroid Build Coastguard Workertarget frameworks, noting that the `TargetFrameworks` element appears twice in 71*6777b538SAndroid Build Coastguard Workerthe file (once in the first `PropertyGroup` element, and again in the second 72*6777b538SAndroid Build Coastguard Worker`PropertyGroup` element, i.e., the one with the conditional). 73*6777b538SAndroid Build Coastguard Worker 74*6777b538SAndroid Build Coastguard WorkerHistory of C# protobufs 75*6777b538SAndroid Build Coastguard Worker======================= 76*6777b538SAndroid Build Coastguard Worker 77*6777b538SAndroid Build Coastguard WorkerThis subtree was originally imported from https://github.com/jskeet/protobuf-csharp-port 78*6777b538SAndroid Build Coastguard Workerand represents the latest development version of C# protobufs, that will now be developed 79*6777b538SAndroid Build Coastguard Workerand maintained by Google. All the development will be done in open, under this repository 80*6777b538SAndroid Build Coastguard Worker(https://github.com/protocolbuffers/protobuf). 81*6777b538SAndroid Build Coastguard Worker 82*6777b538SAndroid Build Coastguard WorkerThe previous project differs from this project in a number of ways: 83*6777b538SAndroid Build Coastguard Worker 84*6777b538SAndroid Build Coastguard Worker- The old code only supported proto2; the new code only supports 85*6777b538SAndroid Build Coastguard Workerproto3 (so no unknown fields, no required/optional distinction, no 86*6777b538SAndroid Build Coastguard Workerextensions) 87*6777b538SAndroid Build Coastguard Worker- The old code was based on immutable message types and builders for 88*6777b538SAndroid Build Coastguard Workerthem 89*6777b538SAndroid Build Coastguard Worker- The old code did not support maps or `oneof` 90*6777b538SAndroid Build Coastguard Worker- The old code had its own JSON representation, whereas the new code 91*6777b538SAndroid Build Coastguard Workeruses the standard protobuf JSON representation 92*6777b538SAndroid Build Coastguard Worker- The old code had no notion of the "well-known types" which have 93*6777b538SAndroid Build Coastguard Workerspecial support in the new code 94*6777b538SAndroid Build Coastguard Worker- The old project supported some older platforms (such as older 95*6777b538SAndroid Build Coastguard Workerversions of Silverlight) which are not currently supported in the 96*6777b538SAndroid Build Coastguard Workernew project 97