Skip to content

Commit

Permalink
[generator] Mark generated .cs files as such so Roslyn analyzers aren…
Browse files Browse the repository at this point in the history
…'t as strict.
  • Loading branch information
jpobst committed Oct 18, 2022
1 parent f498fcf commit d0a550a
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public override void FixupExplicitImplementation ()
public override void Generate (CodeGenerationOptions opt, GenerationInfo gen_info)
{
using (var sw = gen_info.OpenStream (opt.GetFileName (FullName))) {
WriteAutoGeneratedHeader (sw);
sw.WriteLine ("using System;");
sw.WriteLine ("using System.Collections.Generic;");
if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) {
Expand Down Expand Up @@ -188,6 +189,7 @@ public static void GenerateTypeRegistrations (CodeGenerationOptions opt, Generat
v.Add (new KeyValuePair<string, string> (reg.Key, reg.Value));
}

WriteAutoGeneratedHeader (sw);
sw.WriteLine ("using System;");
sw.WriteLine ("using System.Collections.Generic;");
if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) {
Expand Down Expand Up @@ -254,6 +256,19 @@ public static void GenerateTypeRegistrations (CodeGenerationOptions opt, Generat
}
}

static void WriteAutoGeneratedHeader (StreamWriter sw)
{
sw.WriteLine ("//------------------------------------------------------------------------------");
sw.WriteLine ("// <auto-generated>");
sw.WriteLine ("// This code was generated by a tool.");
sw.WriteLine ("//");
sw.WriteLine ("// Changes to this file may cause incorrect behavior and will be lost if");
sw.WriteLine ("// the code is regenerated.");
sw.WriteLine ("// </auto-generated>");
sw.WriteLine ("//------------------------------------------------------------------------------");
sw.WriteLine ();
}

protected override bool GetEnumMappedMemberInfo ()
{
foreach (var m in Ctors)
Expand Down

0 comments on commit d0a550a

Please sign in to comment.