Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into non_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
g-easy authored Aug 1, 2019
2 parents e2b684f + 2b20acc commit 03887e7
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public static List<CodeGenerator<?>> create(
GapicCodePathMapper samplePathMapper = newCodePathMapper.apply(".Samples");
generators.add(
newCsharpGenerator.apply(new CSharpStandaloneSampleTransformer(samplePathMapper)));
if (artifactFlags.packagingFilesEnabled()) {
generators.add(
newCsharpGenerator.apply(CSharpBasicPackageTransformer.forSamples(samplePathMapper)));
}
}

} else if (language.equals(GO)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class CSharpBasicPackageTransformer implements ModelToViewTransformer<Pro
"csharp/gapic_snippets_csproj.snip";
private static final String UNITTEST_CSPROJ_TEMPLATE_FILENAME =
"csharp/gapic_unittest_csproj.snip";
private static final String SAMPLE_CSPROJ_TEMPLATE_FILENAME = "csharp/gapic_samples_csproj.snip";

private static final CSharpAliasMode ALIAS_MODE = CSharpAliasMode.MessagesOnly;

Expand All @@ -63,6 +64,11 @@ private CSharpBasicPackageTransformer(
this.shouldGenerateFn = shouldGenerateFn;
}

public static CSharpBasicPackageTransformer forSamples(GapicCodePathMapper pathMapper) {
return new CSharpBasicPackageTransformer(
pathMapper, SAMPLE_CSPROJ_TEMPLATE_FILENAME, ".Samples.csproj", shouldGenSamplePackage());
}

public static CSharpBasicPackageTransformer forSmokeTests(GapicCodePathMapper pathMapper) {
return new CSharpBasicPackageTransformer(
pathMapper,
Expand All @@ -85,6 +91,22 @@ private static Predicate<GapicInterfaceContext> shouldGenSmokeTestPackage() {
return parameter -> parameter.getInterfaceConfig().getSmokeTestConfig() != null;
}

private static Predicate<GapicInterfaceContext> shouldGenSamplePackage() {
return CSharpBasicPackageTransformer::shouldGenerateSamplePackage;
}

private static boolean shouldGenerateSamplePackage(GapicInterfaceContext interfaceContext) {
boolean fromSampleConfigs =
!interfaceContext.getProductConfig().getSampleConfigTable().cellSet().isEmpty();
boolean fromGapicConfigs =
interfaceContext
.getInterfaceConfig()
.getMethodConfigs()
.stream()
.anyMatch(config -> config.getSampleSpec().isConfigured());
return fromSampleConfigs || fromGapicConfigs;
}

@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@snippet generate(sample)
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../{@sample.fileHeader.packageName}/{@sample.fileHeader.packageName}.csproj" />
<PackageReference Include="CommandLineParser" Version="2.5.0" />
</ItemGroup>

</Project>

@end
5 changes: 4 additions & 1 deletion src/main/resources/com/google/api/codegen/nodejs/main.snip
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* your project ID will be detected automatically.
* @@param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @@param {string} [options.servicePath] - The domain name of the
* @@param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts) {
Expand Down Expand Up @@ -432,6 +432,9 @@
{@handleCallback()}
@case "NonStreaming"
{@handleCallback()}
request = request || {};
@case "ServerStreaming"
request = request || {};
@default
@end
options = options || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,23 @@ namespace Google.Example.Library.V1.Samples
}
}
}
============== file: Google.Example.Library.V1/Google.Example.Library.V1.Samples/Google.Example.Library.V1.Samples.csproj ==============
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../Google.Example.Library.V1/Google.Example.Library.V1.csproj" />
<PackageReference Include="CommandLineParser" Version="2.5.0" />
</ItemGroup>

</Project>

============== file: Google.Example.Library.V1/Google.Example.Library.V1.Samples/Lovelace.cs ==============
// Copyright 2019 Google LLC
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,23 @@ namespace Google.Example.Library.V1.Samples
}
}
}
============== file: Google.Example.Library.V1/Google.Example.Library.V1.Samples/Google.Example.Library.V1.Samples.csproj ==============
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../Google.Example.Library.V1/Google.Example.Library.V1.csproj" />
<PackageReference Include="CommandLineParser" Version="2.5.0" />
</ItemGroup>

</Project>

============== file: Google.Example.Library.V1/Google.Example.Library.V1.Samples/Hopper.cs ==============
// Copyright 2019 Google LLC
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4257,7 +4257,7 @@ class LibraryServiceClient {
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.servicePath] - The domain name of the
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts) {
Expand Down Expand Up @@ -4621,6 +4621,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.createShelf(request, options, callback);
Expand Down Expand Up @@ -4680,6 +4681,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -4768,6 +4770,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
if (request === undefined) {
request = {};
Expand Down Expand Up @@ -4857,6 +4860,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -4918,6 +4922,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -4979,6 +4984,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5055,6 +5061,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5107,6 +5114,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5219,6 +5227,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5325,6 +5334,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5396,6 +5406,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5455,6 +5466,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5550,6 +5562,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.listStrings(request, options, callback);
Expand Down Expand Up @@ -5656,6 +5669,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5708,6 +5722,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5768,6 +5783,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5823,6 +5839,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5879,6 +5896,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -5918,6 +5936,7 @@ class LibraryServiceClient {
* });
*/
streamShelves(request, options) {
request = request || {};
options = options || {};

return this._innerApiCalls.streamShelves(request, options);
Expand Down Expand Up @@ -5951,6 +5970,7 @@ class LibraryServiceClient {
* });
*/
streamBooks(request, options) {
request = request || {};
options = options || {};

return this._innerApiCalls.streamBooks(request, options);
Expand Down Expand Up @@ -6176,6 +6196,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.findRelatedBooks(request, options, callback);
Expand Down Expand Up @@ -6291,6 +6312,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -6387,6 +6409,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -6483,6 +6506,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
Expand Down Expand Up @@ -6722,6 +6746,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.testOptionalRequiredFlatteningParams(request, options, callback);
Expand Down Expand Up @@ -6771,6 +6796,7 @@ class LibraryServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.privateListShelves(request, options, callback);
Expand Down Expand Up @@ -7191,7 +7217,7 @@ class MyProtoClient {
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.servicePath] - The domain name of the
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts) {
Expand Down Expand Up @@ -7382,6 +7408,7 @@ class MyProtoClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};

return this._innerApiCalls.myMethod(request, options, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class DecrementerServiceClient {
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.servicePath] - The domain name of the
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts) {
Expand Down Expand Up @@ -521,7 +521,7 @@ class IncrementerServiceClient {
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.servicePath] - The domain name of the
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts) {
Expand Down Expand Up @@ -689,6 +689,7 @@ class IncrementerServiceClient {
callback = options;
options = {};
}
request = request || {};
options = options || {};
if (request === undefined) {
request = {};
Expand Down
Loading

0 comments on commit 03887e7

Please sign in to comment.