From 3a13fb1c8009d51d566320ba573a7d09678073df Mon Sep 17 00:00:00 2001 From: Christopher Warrington Date: Wed, 14 Apr 2021 09:48:47 -0700 Subject: [PATCH] [c#] Exclude files in output dir from implicit codegen Bond's implicit code generation includes any .bond files in the project's output directories (e.g., `bin/` or `obj/debug/netstandard1.0`). Some projects that copied .bond files into their output directories would then encounter codegen issues when gbc was run on these .bond files implicitly, particularly during incremental builds. Omit any .bond files that match `$(DefaultItemExcludes)` or `$(DefaultExcludesInProjectFolder)` from implicit codegen. Add a regression codegen test. This behavior now matches what the .NET SDK does for .cs files. --- CHANGELOG.md | 8 +++++- cs/build/nuget/Common.props | 4 ++- cs/cs.sln | 28 +++++++++++++++++-- .../default-ignore-output/ConsumeCodegen.cs | 16 +++++++++++ .../codegen/default-ignore-output/README.md | 5 ++++ .../bin/should-not-be-compiled.bond | 2 ++ .../default-ignore-output.csproj | 13 +++++++++ .../should-not-be-compiled.bond | 2 ++ .../should-not-be-compiled.bond | 2 ++ .../obj/should-not-be-compiled.bond | 2 ++ .../codegen/default-ignore-output/simple.bond | 6 ++++ 11 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 cs/test/codegen/default-ignore-output/ConsumeCodegen.cs create mode 100644 cs/test/codegen/default-ignore-output/README.md create mode 100644 cs/test/codegen/default-ignore-output/bin/should-not-be-compiled.bond create mode 100644 cs/test/codegen/default-ignore-output/default-ignore-output.csproj create mode 100644 cs/test/codegen/default-ignore-output/obj/debug/netstandard1.0/should-not-be-compiled.bond create mode 100644 cs/test/codegen/default-ignore-output/obj/retail/netstandard1.0/should-not-be-compiled.bond create mode 100644 cs/test/codegen/default-ignore-output/obj/should-not-be-compiled.bond create mode 100644 cs/test/codegen/default-ignore-output/simple.bond diff --git a/CHANGELOG.md b/CHANGELOG.md index bc04583892..3f20ceacee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ different versioning scheme, following the Haskell community's * IDL core version: TBD * C++ version: TBD (bug fix bump needed) -* C# NuGet version: TBD +* C# NuGet version: TBD (bug fix bump needed) * `gbc` & compiler library: TBD ### C++/Python ### @@ -26,6 +26,12 @@ different versioning scheme, following the Haskell community's * Removed use of deprecated `std::ptr_fun` in the Python library. ([Issue \#1080](https://github.com/microsoft/bond/issues/1080)) +### C# ### + +* Implicit codegen now excludes any .bond files in the project's output + directories (e.g., `bin/`, `obj/debug/netstandard1.0`). This behavior + matches the implicit compilation behavior for .cs files. + ## 9.0.4: 2020-11-23 ## * IDL core version: 3.0 diff --git a/cs/build/nuget/Common.props b/cs/build/nuget/Common.props index ee48f8ff7e..bc75bf5da7 100644 --- a/cs/build/nuget/Common.props +++ b/cs/build/nuget/Common.props @@ -32,7 +32,9 @@ expected, instead of after importing the targets. --> - + $(DefaultItemExcludes);**/*.bond diff --git a/cs/cs.sln b/cs/cs.sln index 5d41522f6b..1c334b6ad0 100644 --- a/cs/cs.sln +++ b/cs/cs.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2043 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31025.218 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Attributes", "src\attributes\Attributes.csproj", "{92915BD9-8AB1-4E4D-A2AC-95BBF4F82D89}" EndProject @@ -334,6 +334,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreNS10", "test\coreNS10\C {C001C79F-D289-4CF3-BB59-5F5A72F70D0E} = {C001C79F-D289-4CF3-BB59-5F5A72F70D0E} EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "default-ignore-output", "test\codegen\default-ignore-output\default-ignore-output.csproj", "{98BF6B10-F821-4402-8923-5F7B726BBFC8}" + ProjectSection(ProjectDependencies) = postProject + {21E175D5-BBDD-4B63-8FB7-38899BF2F9D1} = {21E175D5-BBDD-4B63-8FB7-38899BF2F9D1} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1166,6 +1171,24 @@ Global {3805B86E-2BE3-4FFA-A11C-B4981069EC88}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3805B86E-2BE3-4FFA-A11C-B4981069EC88}.Release|Win32.ActiveCfg = Release|Any CPU {3805B86E-2BE3-4FFA-A11C-B4981069EC88}.Release|Win32.Build.0 = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Win32.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Debug|Win32.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Any CPU.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Any CPU.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Mixed Platforms.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Mixed Platforms.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Win32.ActiveCfg = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Fields|Win32.Build.0 = Debug|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Any CPU.Build.0 = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Win32.ActiveCfg = Release|Any CPU + {98BF6B10-F821-4402-8923-5F7B726BBFC8}.Release|Win32.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1215,6 +1238,7 @@ Global {5C6BAEFE-9F72-451E-85CC-F4521E92AEB9} = {621A2166-EEE0-4A27-88AA-5BE5AC996452} {6887352A-4071-46D6-B095-2514985A3AB6} = {621A2166-EEE0-4A27-88AA-5BE5AC996452} {3805B86E-2BE3-4FFA-A11C-B4981069EC88} = {4268A1D3-AF40-4120-B021-D95A0F754221} + {98BF6B10-F821-4402-8923-5F7B726BBFC8} = {8CF1F5CD-548F-4323-869E-AA5903C88B6A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6EB58560-CA9C-4F6C-B916-CCA6C7FE2A2B} diff --git a/cs/test/codegen/default-ignore-output/ConsumeCodegen.cs b/cs/test/codegen/default-ignore-output/ConsumeCodegen.cs new file mode 100644 index 0000000000..1db18c2fe5 --- /dev/null +++ b/cs/test/codegen/default-ignore-output/ConsumeCodegen.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace CodegenTest.DefaultIgnoresOutput +{ + public static class UsesCodegen + { + public static SimpleType Make() + { + return new SimpleType + { + _int32 = 42, + }; + } + } +} diff --git a/cs/test/codegen/default-ignore-output/README.md b/cs/test/codegen/default-ignore-output/README.md new file mode 100644 index 0000000000..7a6151dbd1 --- /dev/null +++ b/cs/test/codegen/default-ignore-output/README.md @@ -0,0 +1,5 @@ +This test ensures that the .bond files automatically added to BondCodegen +exclude files in the project's output paths. + +This directory has some files intentionally committed under the +typically-ignored `bin/` and `obj/` paths. diff --git a/cs/test/codegen/default-ignore-output/bin/should-not-be-compiled.bond b/cs/test/codegen/default-ignore-output/bin/should-not-be-compiled.bond new file mode 100644 index 0000000000..f4310f755d --- /dev/null +++ b/cs/test/codegen/default-ignore-output/bin/should-not-be-compiled.bond @@ -0,0 +1,2 @@ +This file should not be automatically added by the codegen targets because +it is in one of the output directories. diff --git a/cs/test/codegen/default-ignore-output/default-ignore-output.csproj b/cs/test/codegen/default-ignore-output/default-ignore-output.csproj new file mode 100644 index 0000000000..3f724204c6 --- /dev/null +++ b/cs/test/codegen/default-ignore-output/default-ignore-output.csproj @@ -0,0 +1,13 @@ + + + + Debug;Release + Library + 98BF6B10-F821-4402-8923-5F7B726BBFC8 + netstandard1.0 + + + + + + diff --git a/cs/test/codegen/default-ignore-output/obj/debug/netstandard1.0/should-not-be-compiled.bond b/cs/test/codegen/default-ignore-output/obj/debug/netstandard1.0/should-not-be-compiled.bond new file mode 100644 index 0000000000..f4310f755d --- /dev/null +++ b/cs/test/codegen/default-ignore-output/obj/debug/netstandard1.0/should-not-be-compiled.bond @@ -0,0 +1,2 @@ +This file should not be automatically added by the codegen targets because +it is in one of the output directories. diff --git a/cs/test/codegen/default-ignore-output/obj/retail/netstandard1.0/should-not-be-compiled.bond b/cs/test/codegen/default-ignore-output/obj/retail/netstandard1.0/should-not-be-compiled.bond new file mode 100644 index 0000000000..f4310f755d --- /dev/null +++ b/cs/test/codegen/default-ignore-output/obj/retail/netstandard1.0/should-not-be-compiled.bond @@ -0,0 +1,2 @@ +This file should not be automatically added by the codegen targets because +it is in one of the output directories. diff --git a/cs/test/codegen/default-ignore-output/obj/should-not-be-compiled.bond b/cs/test/codegen/default-ignore-output/obj/should-not-be-compiled.bond new file mode 100644 index 0000000000..f4310f755d --- /dev/null +++ b/cs/test/codegen/default-ignore-output/obj/should-not-be-compiled.bond @@ -0,0 +1,2 @@ +This file should not be automatically added by the codegen targets because +it is in one of the output directories. diff --git a/cs/test/codegen/default-ignore-output/simple.bond b/cs/test/codegen/default-ignore-output/simple.bond new file mode 100644 index 0000000000..d593da0a4d --- /dev/null +++ b/cs/test/codegen/default-ignore-output/simple.bond @@ -0,0 +1,6 @@ +namespace CodegenTest.DefaultIgnoresOutput; + +struct SimpleType +{ + 0: int32 _int32; +}