• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
9 
10 #include <sstream>
11 
12 #include "google/protobuf/compiler/code_generator.h"
13 #include "google/protobuf/descriptor.h"
14 #include "google/protobuf/compiler/csharp/csharp_helpers.h"
15 #include "google/protobuf/compiler/csharp/names.h"
16 #include "google/protobuf/compiler/csharp/csharp_options.h"
17 #include "google/protobuf/descriptor.pb.h"
18 #include "google/protobuf/io/printer.h"
19 #include "google/protobuf/io/zero_copy_stream.h"
20 
21 namespace google {
22 namespace protobuf {
23 namespace compiler {
24 namespace csharp {
25 
SourceGeneratorBase(const Options * options)26 SourceGeneratorBase::SourceGeneratorBase(
27     const Options *options) : options_(options) {
28 }
29 
~SourceGeneratorBase()30 SourceGeneratorBase::~SourceGeneratorBase() {
31 }
32 
WriteGeneratedCodeAttributes(io::Printer * printer)33 void SourceGeneratorBase::WriteGeneratedCodeAttributes(io::Printer* printer) {
34   printer->Print("[global::System.Diagnostics.DebuggerNonUserCodeAttribute]\n");
35   // The second argument of the [GeneratedCode] attribute could be set to current protoc
36   // version, but that would cause excessive code churn in the pre-generated
37   // code in the repository every time the protobuf version number is updated.
38   printer->Print("[global::System.CodeDom.Compiler.GeneratedCode(\"protoc\", null)]\n");
39 }
40 
class_access_level()41 std::string SourceGeneratorBase::class_access_level() {
42   return this->options()->internal_access ? "internal" : "public";
43 }
44 
options()45 const Options* SourceGeneratorBase::options() {
46   return this->options_;
47 }
48 
49 }  // namespace csharp
50 }  // namespace compiler
51 }  // namespace protobuf
52 }  // namespace google
53