Search code examples
xamlmsbuildcompiler-warningsauto-generate

How to disable "Missing XML comment" warning for auto generated code in Windows Store app?


I get numerous compiler warnings CS1591 Missing XML comment for publicly visible type or member ... in my Universal Windows Store App project in VS2015 for auto generated code files, e.g.

  • App.g.cs
  • App.g.i.cs
  • SomePage.g.cs
  • SomePage.g.i.cs

I know of the different approaches available to fix these warnings from showing up, but I can't get the specific approach mentioned in Quoc Lam's blog to work. The other possible solutions don't work for me, so what do I have to do make it work for my project?

There are a couple of things I still don't understand:

  • Where do I have to place the code lines containing the new target? I tried to put them into my Windows Phone project file (.csproj), but XamlGeneratedCodeFiles always seems to be empty (judging from diagnostic build output)
  • I also tried setting the AftetTargets attribute from XamlMarkupCompilePass1 to XamlMarkupCompilePass2, but still the same as above
  • Where is XamlGeneratedCodeFiles actually filled with data? Or do I misunderstand something?
  • Is XamlGeneratedCodeFiles the right variable to access?

I also looked at several of the msbuild .target files but got completely lost. Please let me know if you need further information that is still missing form this post.

Update

In addition to the accepted answer I post the working solution for my project as it wouldn't fit into a comment:

<Target Name="CodeWarningRemover" AfterTargets="MarkupCompilePass2">
    <ItemGroup>
        <CSFiles Include="**\*.g.cs;**\*.g.i.cs" />
    </ItemGroup>
    <Message Text="CSFiles: '@(CSFiles)'" />
    <Exec Command="for %%f in (@(CSFiles)) do echo #pragma warning disable > %%f.temp" />
    <Exec Command="for %%f in (@(CSFiles)) do type %%f >> %%f.temp" />
    <Exec Command="for %%f in (@(CSFiles)) do move /y %%f.temp %%f" />
</Target>

Solution

  • You could load the list of files to modify in the target wit ItemGroup :

    <Target Name="CodeWarningRemover" AfterTargets="FindTheTagertToOverwrite">
        <ItemGroup>
            <Content Include="*.g.cs" />
            <Content Include="*.g.i.cs" />
        </ItemGroup>
        <Exec Command="for %%f in (@(Content)) do echo #pragma warning disable > %%f.temp" />
        <Exec Command="for %%f in (@(Content)) do type %%f >> %%f.temp" />
        <Exec Command="for %%f in (@(Content)) do copy /y %%f.temp %%f" />
    </Target>
    

    You need to find the target to overwrite : named "FindTheTagertToOverwrite" in the sample. It's the target used by the Universal Windows Store App project and it's build process or your custom build process. Sorry, I'm not familliar with this project

    You could try with MarkupCompilePass1