Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
f61e1791
Commit
f61e1791
authored
Apr 13, 2015
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output file naming logic, configurable file extension, comment rewording
parent
8cec65e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
csharp_generator.cc
src/google/protobuf/compiler/csharp/csharp_generator.cc
+21
-6
csharp_helpers.cc
src/google/protobuf/compiler/csharp/csharp_helpers.cc
+1
-1
csharp_source_generator_base.cc
.../protobuf/compiler/csharp/csharp_source_generator_base.cc
+2
-9
No files found.
src/google/protobuf/compiler/csharp/csharp_generator.cc
View file @
f61e1791
...
...
@@ -49,6 +49,11 @@ namespace protobuf {
namespace
compiler
{
namespace
csharp
{
std
::
string
GetOutputFile
(
const
google
::
protobuf
::
FileDescriptor
*
file
,
const
std
::
string
file_extension
)
{
return
GetFileUmbrellaClassname
(
file
)
+
file_extension
;
}
void
GenerateFile
(
const
google
::
protobuf
::
FileDescriptor
*
file
,
Writer
*
writer
)
{
UmbrellaClassGenerator
umbrellaGenerator
(
file
);
...
...
@@ -61,13 +66,23 @@ bool Generator::Generate(
GeneratorContext
*
generator_context
,
string
*
error
)
const
{
// TODO(jtattermusch): parse generator parameters:
// cls_compliance
// file_extension
vector
<
pair
<
string
,
string
>
>
options
;
ParseGeneratorParameter
(
parameter
,
&
options
);
std
::
string
file_extension
=
".cs"
;
for
(
int
i
=
0
;
i
<
options
.
size
();
i
++
)
{
if
(
options
[
i
].
first
==
"no_cls_compliance"
)
{
*
error
=
"Turning off CLS compliance is not implemented yet."
;
return
false
;
}
else
if
(
options
[
i
].
first
==
"file_extension"
)
{
file_extension
=
options
[
i
].
second
;
}
else
{
*
error
=
"Unknown generator option: "
+
options
[
i
].
first
;
return
false
;
}
}
// TODO(jtattermusch): rework output file naming logic
std
::
string
filename
=
StripDotProto
(
file
->
name
())
+
".cs"
;
std
::
string
filename
=
GetOutputFile
(
file
,
file_extension
);
scoped_ptr
<
io
::
ZeroCopyOutputStream
>
output
(
generator_context
->
Open
(
filename
));
io
::
Printer
printer
(
output
.
get
(),
'$'
);
...
...
src/google/protobuf/compiler/csharp/csharp_helpers.cc
View file @
f61e1791
...
...
@@ -364,7 +364,7 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor,
}
bool
HasRequiredFields
(
const
Descriptor
*
descriptor
)
{
// TODO(jtattermusch): implement
this
.
// TODO(jtattermusch): implement
HasRequiredFields logic
.
return
true
;
}
...
...
src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
View file @
f61e1791
...
...
@@ -62,18 +62,11 @@ SourceGeneratorBase::~SourceGeneratorBase() {
}
void
SourceGeneratorBase
::
WriteGeneratedCodeAttributes
(
Writer
*
writer
)
{
// TODO(jtattermusch):
//if (descriptor.File.CSharpOptions.GeneratedCodeAttributes)
// {
// writer.WriteLine("[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]");
// writer.WriteLine("[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{0}\", \"{1}\")]",
// GetType().Assembly.GetName().Name, GetType().Assembly.GetName().Version);
// }
// This hook can be used to reintroduce generated code attributes in the future.
}
std
::
string
SourceGeneratorBase
::
class_access_level
()
{
// TODO(jtattermusch): implement this
return
"public"
;
return
"public"
;
// public_classes is always on.
}
bool
SourceGeneratorBase
::
cls_compliance
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment