Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ endif (SNAPPY_FOUND)

add_definitions (${Boost_LIB_DIAGNOSTIC_DEFINITIONS})

add_definitions (-DAVRO_VERSION="${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR}.${AVRO_VERSION_PATCH}")

include_directories (api ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS})

set (AVRO_SOURCE_FILES
Expand Down
15 changes: 10 additions & 5 deletions lang/c++/impl/avrogencpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,23 +810,28 @@ int main(int argc, char **argv) {
const string NO_UNION_TYPEDEF("no-union-typedef");

po::options_description desc("Allowed options");
desc.add_options()("help,h", "produce help message")("include-prefix,p", po::value<string>()->default_value("avro"),
desc.add_options()("help,h", "produce help message")("version,V", "produce version information")("include-prefix,p", po::value<string>()->default_value("avro"),
"prefix for include headers, - for none, default: avro")("no-union-typedef,U", "do not generate typedefs for unions in records")("namespace,n", po::value<string>(), "set namespace for generated code")("input,i", po::value<string>(), "input file")("output,o", po::value<string>(), "output file to generate");

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count(IN_FILE) == 0 || vm.count(OUT_FILE) == 0) {
if (vm.count("help")) {
std::cout << desc << std::endl;
return 1;
return 0;
}

if (vm.count("help")) {
std::cout << desc << std::endl;
if (vm.count("version")) {
std::cout << AVRO_VERSION << std::endl;
return 0;
}

if (vm.count(IN_FILE) == 0 || vm.count(OUT_FILE) == 0) {
std::cout << desc << std::endl;
return 1;
}

string ns = vm.count(NS) > 0 ? vm[NS].as<string>() : string();
string outf = vm.count(OUT_FILE) > 0 ? vm[OUT_FILE].as<string>() : string();
string inf = vm.count(IN_FILE) > 0 ? vm[IN_FILE].as<string>() : string();
Expand Down
3 changes: 1 addition & 2 deletions lang/csharp/src/apache/codegen/Avro.codegen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
unless framework is explicitly specified with 'dotnet tool install'
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-install
-->
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>$(DefaultExeTargetFrameworks)</TargetFrameworks>
<AssemblyName>avrogen</AssemblyName>
<RootNamespace>Avro.codegen</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\Avro.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
Expand Down
19 changes: 14 additions & 5 deletions lang/csharp/src/apache/codegen/AvroGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Reflection;

namespace Avro
{
Expand All @@ -39,6 +40,13 @@ static int Main(string[] args)
return 0;
}

if (args.Contains("--version"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the expectation to also support -V? args.Any(a => a is "--version" or "-V") <-- Apparently this is only C# 8
if (args.Contains("--version") || args.Contains("-V") )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I added -V to the cpp avrogen and I intended to add for C# as well.

{
// Print version information
Console.WriteLine(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion);
return 0;
}

// Parse command line arguments
bool? isProtocol = null;
string inputFile = null;
Expand Down Expand Up @@ -135,10 +143,11 @@ static void Usage()
" avrogen -p <protocolfile> <outputdir> [--namespace <my.avro.ns:my.csharp.ns>]\n" +
" avrogen -s <schemafile> <outputdir> [--namespace <my.avro.ns:my.csharp.ns>]\n\n" +
"Options:\n" +
" -h --help Show this screen.\n" +
" --namespace Map an Avro schema/protocol namespace to a C# namespace.\n" +
" The format is \"my.avro.namespace:my.csharp.namespace\".\n" +
" May be specified multiple times to map multiple namespaces.\n",
" -h --help Show this screen.\n" +
" -V --version Show version.\n" +
" --namespace Map an Avro schema/protocol namespace to a C# namespace.\n" +
" The format is \"my.avro.namespace:my.csharp.namespace\".\n" +
" May be specified multiple times to map multiple namespaces.\n",
AppDomain.CurrentDomain.FriendlyName);
return;
}
Expand Down
33 changes: 0 additions & 33 deletions lang/csharp/src/apache/codegen/Properties/AssemblyInfo.cs

This file was deleted.