diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj | 4 | ||||
-rw-r--r-- | src/csharp/Grpc.nuspec | 2 | ||||
-rw-r--r-- | src/csharp/README.md | 111 | ||||
-rw-r--r-- | src/csharp/build_packages.bat | 8 | ||||
-rw-r--r-- | src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m | 63 |
5 files changed, 148 insertions, 40 deletions
diff --git a/src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj b/src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj index 3f7e6c0768..ba6586ee5e 100644 --- a/src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj +++ b/src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -8,7 +8,7 @@ <ProjectGuid>{BF62FE08-373A-43D6-9D73-41CAA38B7011}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>Grpc.Examples.MathServer</RootNamespace> - <AssemblyName>Grpc.Examples.MathServer</AssemblyName> + <AssemblyName>MathServer</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> diff --git a/src/csharp/Grpc.nuspec b/src/csharp/Grpc.nuspec index 1daff491af..e3195e1806 100644 --- a/src/csharp/Grpc.nuspec +++ b/src/csharp/Grpc.nuspec @@ -2,7 +2,7 @@ <package> <metadata> <id>Grpc</id> - <title>gRPC</title> + <title>gRPC C#</title> <summary>C# implementation of gRPC - an RPC library and framework</summary> <description>C# implementation of gRPC - an RPC library and framework. See project site for more info.</description> <version>0.5.0</version> diff --git a/src/csharp/README.md b/src/csharp/README.md index 21aab52118..37aa2ecddc 100644 --- a/src/csharp/README.md +++ b/src/csharp/README.md @@ -4,74 +4,117 @@ gRPC C# A C# implementation of gRPC. Status ------------------ +------ -**This gRPC C# implementation is work-in-progress and is not expected to work yet.** +Ready for early adopters. -- The implementation is a wrapper around gRPC C core library -- Code only runs under mono currently, building gRPC C core library under Windows - is in progress. -- It is very possible that some parts of the code will be heavily refactored or - completely rewritten. +Usage: Windows +-------------- +- Prerequisites: .NET Framework 4.5+, Visual Studio 2013 with NuGet extension installed (VS2015 should work). -INSTALLATION AND USAGE: WINDOWS -------------------------------- +- Open Visual Studio and start a new project/solution. -- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored - upon build. +- Add NuGet package `Grpc` as a dependency (Project options -> Manage NuGet Packages). + That will also pull all the transitive dependencies (including the native libraries that + gRPC C# is internally using). +- TODO: link to Helloworld example -INSTALLATION AND USAGE: LINUX & MONO ------------------------------------- +Usage: Linux (Mono) +-------------- -- Compile and install the gRPC C# extension library (that will be used via - P/Invoke from C#). +- Prerequisites: Mono framework, MonoDevelop 5.9 with NuGet add-in installed. + +- Install gRPC C Core using instructions in https://github.com/grpc/homebrew-grpc + +- TODO: explain using LD_LIBRARY_PATH or installation to /usr/local + +- Open MonoDevelop and start a new project/solution. + +- Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages). + +- TODO: link to Helloworld example + +Building: Windows +----------------- + +You only need to go through these steps if you are planning to develop gRPC C#. +If you are a user of gRPC C#, go to Usage section above. + +- Prerequisites for development: NET Framework 4.5+, Visual Studio 2013 (with NuGet and NUnit extensions installed). + +- The grpc_csharp_ext native library needs to be built so you can build the Grpc C# solution. You can + either build the native solution in `vsprojects/grpc.sln` from Visual Studio manually, or you can use + a convenience batch script that builds everything for you. ``` -make grpc_csharp_ext -sudo make install_grpc_csharp_ext +buildall.bat ``` -- Prerequisites for development: Mono framework, MonoDevelop (IDE) +- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored + upon build (you need to have NuGet add-in installed). + + +Building: Linux & Mono +---------------------- + +You only need to go through these steps if you are planning to develop gRPC C#. +If you are a user of gRPC C#, go to Usage section above. + +- Prerequisites for development: Mono framework, MonoDevelop 5.9 with NuGet and Nunit add-ins installed. ``` sudo apt-get install mono-devel -sudo apt-get install monodevelop monodevelop-nunit sudo apt-get install nunit nunit-console ``` -- NuGet is used to manage project's dependencies. Prior opening Grpc.sln, - download dependencies using NuGet restore command: +You can use older versions of MonoDevelop, but then you might need to restore +NuGet dependencies manually (by `nuget restore`), because older versions of MonoDevelop +don't support NuGet add-in. +- Compile and install the gRPC C# extension library (that will be used via + P/Invoke from C#). ``` -# Import needed certicates into Mono certificate store: -mozroots --import --sync - -# Download NuGet.exe http://nuget.codeplex.com/releases/ -# Restore the nuget packages with Grpc C# dependencies -mono ~/Downloads/NuGet.exe restore Grpc.sln +make grpc_csharp_ext +sudo make install_grpc_csharp_ext ``` -- Use MonoDevelop to open the solution Grpc.sln (you can also run unit tests - from there). +- Use MonoDevelop to open the solution Grpc.sln + +- Build the solution & run all the tests from test view. + +Tests +----- -- After building the solution with MonoDevelop, you can use - nunit-console to run the unit tests (currently only running one by - one will make them pass. +gRPC C# is using NUnit as the testing framework. + +Under Visual Studio, make sure NUnit test adapter is installed (under "Extensions and Updates"). +Then you should be able to run all the tests using Test Explorer. + +Under Monodevelop, make sure you installed "NUnit support" in Add-in manager. +Then you should be able to run all the test from the Test View. + +After building the solution, you can also run the tests from command line +using nunit-console tool. ``` +# from Grpc.Core.Test/bin/Debug directory nunit-console Grpc.Core.Tests.dll ``` -CONTENTS +Contents -------- - ext: The extension library that wraps C API to be more digestible by C#. +- Grpc.Auth: + gRPC OAuth2 support. - Grpc.Core: The main gRPC C# library. - Grpc.Examples: API examples for math.proto - Grpc.Examples.MathClient: An example client that sends some requests to math server. +- Grpc.Examples.MathServer: + An example client that sends some requests to math server. - Grpc.IntegrationTesting: - Client for cross-language gRPC implementation testing (interop testing). + Cross-language gRPC implementation testing (interop testing). diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages.bat index fab80b0e08..fe7e0a495f 100644 --- a/src/csharp/build_packages.bat +++ b/src/csharp/build_packages.bat @@ -1,10 +1,16 @@ -@rem Builds NuGet packages +@rem Builds gRPC NuGet packages @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe +setlocal +cd ..\..\vsprojects\nuget_package @call buildall.bat || goto :error +endlocal +@call buildall.bat || goto :error + +%NUGET% pack ..\..\vsprojects\nuget_package\grpc.native.csharp_ext.nuspec || goto :error %NUGET% pack Grpc.Core\Grpc.Core.nuspec || goto :error %NUGET% pack Grpc.Auth\Grpc.Auth.nuspec || goto :error %NUGET% pack Grpc.nuspec || goto :error diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m index 2ef6a6e4ab..72ceed0c31 100644 --- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m +++ b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m @@ -31,9 +31,12 @@ * */ +#include <grpc/status.h> + #import <UIKit/UIKit.h> #import <XCTest/XCTest.h> +#import <gRPC/ProtoRPC.h> #import <gRPC/GRXWriter+Immediate.h> #import <RemoteTest/Messages.pb.h> #import <RemoteTest/Test.pb.h> @@ -69,7 +72,7 @@ } - (void)testLargeUnaryRPC { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"]; + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"]; RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init] setResponseType:RMTPayloadTypeCompressable] @@ -95,7 +98,7 @@ } - (void)testClientStreamingRPC { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"]; + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"]; id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init] setPayloadBuilder:[[[RMTPayloadBuilder alloc] init] @@ -130,4 +133,60 @@ [self waitForExpectationsWithTimeout:4. handler:nil]; } +- (void)testServerStreamingRPC { + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"]; + NSArray *expectedSizes = @[@31415, @9, @2653, @58979]; + __block int index = 0; + id request = [[[[[[[RMTStreamingOutputCallRequestBuilder alloc] init] + addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init] + setSize:31415] build]] + addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init] + setSize:9] build]] + addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init] + setSize:2653] build]] + addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init] + setSize:58979] build]] + build]; + [_service streamingOutputCallWithRequest:request handler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){ + XCTAssertNil(error, @"Finished with unexpected error: %@", error); + id expectedResponseBuilder = [[RMTStreamingOutputCallResponseBuilder alloc] init]; + id expectedPayload = [[[[[RMTPayloadBuilder alloc] init] + setType:RMTPayloadTypeCompressable] + setBody:[NSMutableData dataWithLength:[expectedSizes[index] unsignedIntegerValue]]] + build]; + expectedResponseBuilder = [expectedResponseBuilder setPayload:expectedPayload]; + id expectedResponse = [expectedResponseBuilder build]; + XCTAssertEqualObjects(response, expectedResponse); + + [expectation fulfill]; + index += 1; + }]; + + [self waitForExpectationsWithTimeout:4 handler:nil]; +} + +- (void)testEmptyStreamRPC { + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"]; + [_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter] + handler:^(bool done, RMTStreamingOutputCallResponse *response, NSError *error) { + XCTAssertNil(error, @"Finished with unexpected error: %@", error); + XCTAssert(done, @"Unexpected response: %@", response); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:4 handler:nil]; +} + +- (void)testCancelAfterBeginRPC { + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"]; + // TODO(mlumish): change to writing that blocks instead of writing + ProtoRPC *call = [_service RPCToStreamingInputCallWithRequestsWriter:[GRXWriter emptyWriter] + handler:^(RMTStreamingInputCallResponse *response, NSError *error) { + XCTAssertEqual([error code], GRPC_STATUS_CANCELLED); + [expectation fulfill]; + }]; + [call start]; + [call cancel]; + [self waitForExpectationsWithTimeout:1 handler:nil]; +} + @end |