Skip to content

Commit

Permalink
Fixing authoring tests and added them to build.cmd (#501)
Browse files Browse the repository at this point in the history
* Fix authoring test and add versioning to source generator.

* Don't generate default files if no projection types were written and make sure cswinrt targets get pulled in for authoring component.

* Fix typo.
  • Loading branch information
manodasanW authored Oct 15, 2020
1 parent 42d1760 commit 11c5d3b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
9 changes: 9 additions & 0 deletions Authoring/AuthoringSample/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >

<PropertyGroup>
<SimulateCsWinRTNugetReference>true</SimulateCsWinRTNugetReference>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

</Project>
5 changes: 5 additions & 0 deletions Authoring/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

</Project>
12 changes: 12 additions & 0 deletions Authoring/WinRT.SourceGenerator/WinRT.SourceGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Authors>Microsoft Corporation</Authors>
<Company>Microsoft Corporation</Company>
<Product>C#/WinRT</Product>
<PackageId>WinRT.SourceGenerator</PackageId>
<FileVersion>$(VersionNumber)</FileVersion>
<Version>$(VersionNumber)</Version>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<InformationalVersion>$(VersionNumber)</InformationalVersion>
<NeutralLanguage>en</NeutralLanguage>
<Description>C#/WinRT Authoring Source Generator Preview $(VersionString)</Description>
<AssemblyTitle>C#/WinRT Authoring Source Generator Preview v$(VersionString)</AssemblyTitle>
<Copyright>Copyright (c) Microsoft Corporation. All rights reserved.</Copyright>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ if ErrorLevel 1 (
exit /b !ErrorLevel!
)

rem Run Authoring tests
echo Running cswinrt authoring tests for %cswinrt_platform% %cswinrt_configuration%
call :exec %~dp0_build\%cswinrt_platform%\%cswinrt_configuration%\AuthoringConsumptionTest\bin\AuthoringConsumptionTest.exe --gtest_output=xml:%~dp0hosttest_%cswinrt_version_string%.xml
if ErrorLevel 1 (
echo.
echo ERROR: Authoring test failed, skipping NuGet pack
exit /b !ErrorLevel!
)

:package
set cswinrt_bin_dir=%~dp0_build\%cswinrt_platform%\%cswinrt_configuration%\cswinrt\bin\
set cswinrt_exe=%cswinrt_bin_dir%cswinrt.exe
Expand Down
29 changes: 16 additions & 13 deletions cswinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,10 @@ Where <spec> is one or more of:

task_group group;

group.add([]
{
for (auto&& string : strings::base)
{
writer w;
w.write("// This file was generated by cswinrt.exe version %", VERSION_STRING);
w.write(string.value);
w.flush_to_file(settings.output_folder / (std::string(string.name) + ".cs"));
}
});

bool projectionFileWritten = false;
for (auto&& ns_members : c.namespaces())
{
group.add([&ns_members, &componentActivatableClasses]
group.add([&ns_members, &componentActivatableClasses, &projectionFileWritten]
{
auto&& [ns, members] = ns_members;
std::string_view currentType = "";
Expand Down Expand Up @@ -306,6 +296,7 @@ Where <spec> is one or more of:

auto filename = w.write_temp("%.cs", ns);
w.flush_to_file(settings.output_folder / filename);
projectionFileWritten = true;
}
}
catch (std::exception const& e)
Expand All @@ -320,17 +311,29 @@ Where <spec> is one or more of:

if(settings.component)
{
group.add([&componentActivatableClasses]
group.add([&componentActivatableClasses, &projectionFileWritten]
{
writer w;
w.write("// This file was generated by cswinrt.exe version %", VERSION_STRING);
write_module_activation_factory(w, componentActivatableClasses);
w.flush_to_file(settings.output_folder / (std::string("WinRT_Module") + ".cs"));
projectionFileWritten = true;
});
}

group.get();

if (projectionFileWritten)
{
for (auto&& string : strings::base)
{
writer w;
w.write("// This file was generated by cswinrt.exe version %", VERSION_STRING);
w.write(string.value);
w.flush_to_file(settings.output_folder / (std::string(string.name) + ".cs"));
}
}

if (settings.verbose)
{
w.write("time: %ms\n", get_elapsed_time(start));
Expand Down

0 comments on commit 11c5d3b

Please sign in to comment.