Skip to content

Commit

Permalink
Ensure generated code has the correct header to be picked up by code …
Browse files Browse the repository at this point in the history
…analysis. (#902)

* Ensure generated code has the correct header to be picked up by code analysis.

* Add more header.
  • Loading branch information
jlaanstra authored Jul 7, 2021
1 parent 363f47f commit fcf49db
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
29 changes: 27 additions & 2 deletions src/cswinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,15 @@ Where <spec> is one or more of:
group.add([&componentActivatableClasses, &projectionFileWritten]
{
writer wm;
wm.write("// This file was generated by cswinrt.exe version %", VERSION_STRING);
wm.write(R"(//------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by cswinrt.exe version %
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
)", VERSION_STRING);
write_module_activation_factory(wm, componentActivatableClasses);
wm.flush_to_file(settings.output_folder / (std::string("WinRT_Module") + ".cs"));
projectionFileWritten = true;
Expand All @@ -330,6 +338,15 @@ Where <spec> is one or more of:

group.get();
writer eventHelperWriter("WinRT");
eventHelperWriter.write(R"(//------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by cswinrt.exe version %
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
)", VERSION_STRING);
eventHelperWriter.write("namespace WinRT\n{\n%\n}", bind([&](writer& w) {
for (auto&& [key, value] : typeNameToDefinitionMap)
{
Expand All @@ -347,7 +364,15 @@ Where <spec> is one or more of:
continue;
}
writer ws;
ws.write("// This file was generated by cswinrt.exe version %", VERSION_STRING);
ws.write(R"(//------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by cswinrt.exe version %
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
)", VERSION_STRING);
ws.write(string.value);
ws.flush_to_file(settings.output_folder / (std::string(string.name) + ".cs"));
}
Expand Down
11 changes: 9 additions & 2 deletions src/cswinrt/type_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ namespace cswinrt
{
_in_abi_impl_namespace = settings.component;
std::string namespacePrefix = settings.component ? "ABI.Impl." : "";
write(R"(// This file was generated by cswinrt.exe
write(R"(//------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by cswinrt.exe version %
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
Expand All @@ -54,7 +61,7 @@ using WinRT.Interop;
namespace %%
{
)", namespacePrefix, _current_namespace);
)", VERSION_STRING, namespacePrefix, _current_namespace);
}

void write_end()
Expand Down

0 comments on commit fcf49db

Please sign in to comment.