From 204ec2f3cec173d34bd3cdd038e949f4e7f0962e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=C3=ADel=20P=2E=20Purkh=C3=BAs?= Date: Wed, 3 Apr 2024 13:42:12 +0000 Subject: [PATCH 1/4] Rule API cleanup ## What? * Remove all flags except `strict_deps` --- docs/csharp_binary.md | 18 +- docs/csharp_library.md | 11 +- docs/csharp_test.md | 17 +- docs/defs.md | 421 +++++++++++------- docs/fsharp_binary.md | 16 +- docs/fsharp_library.md | 12 +- docs/fsharp_test.md | 16 +- dotnet/defs.bzl | 188 +------- dotnet/private/BUILD.bazel | 72 +-- dotnet/private/providers.bzl | 2 +- dotnet/private/rules/common/BUILD.bazel | 1 - dotnet/private/rules/common/attrs.bzl | 24 +- dotnet/private/rules/common/binary.bzl | 25 +- dotnet/private/rules/csharp/binary.bzl | 8 +- dotnet/private/rules/csharp/library.bzl | 8 +- dotnet/private/rules/csharp/test.bzl | 8 +- dotnet/private/rules/fsharp/binary.bzl | 8 +- dotnet/private/rules/fsharp/library.bzl | 8 +- dotnet/private/rules/fsharp/test.bzl | 8 +- .../private/rules/publish_binary/BUILD.bazel | 2 + .../rules/publish_binary/publish_binary.bzl | 52 ++- .../warning_settings/csharp_warnings.bzl | 65 +-- .../warning_settings/fsharp_warnings.bzl | 65 +-- .../private/tools/apphost_shimmer/BUILD.bazel | 1 - dotnet/settings/BUILD.bazel | 58 +-- dotnet/toolchain.bzl | 48 -- 26 files changed, 408 insertions(+), 754 deletions(-) diff --git a/docs/csharp_binary.md b/docs/csharp_binary.md index cfd2c226..55ed399c 100644 --- a/docs/csharp_binary.md +++ b/docs/csharp_binary.md @@ -9,13 +9,12 @@ Rule for compiling C# binaries. ## csharp_binary
-csharp_binary(name, additionalfiles, allow_unsafe_blocks, apphost_shimmer, compile_data, data,
-              defines, deps, generate_documentation_file, include_host_model_dll,
-              internals_visible_to, keyfile, langversion, nullable, out, override_strict_deps,
-              override_treat_warnings_as_errors, override_warning_level, override_warnings_as_errors,
-              override_warnings_not_as_errors, project_sdk, resources, roll_forward_behavior,
-              run_analyzers, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
-              warning_level, warnings_as_errors, warnings_not_as_errors, winexe)
+csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
+              generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
+              langversion, nullable, out, override_strict_deps, project_sdk, resources,
+              roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a C# exe @@ -28,7 +27,6 @@ Compile a C# exe | name | A unique name for this target. | Name | required | | | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | -| apphost_shimmer | - | Label | optional | None | | compile_data | Additional compile time files. | List of labels | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | @@ -41,10 +39,6 @@ Compile a C# exe | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | diff --git a/docs/csharp_library.md b/docs/csharp_library.md index 55aa9f52..fd87672c 100644 --- a/docs/csharp_library.md +++ b/docs/csharp_library.md @@ -11,10 +11,9 @@ Rule for compiling C# libraries.
 csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
                exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nullable, out, override_strict_deps, override_treat_warnings_as_errors,
-               override_warning_level, override_warnings_as_errors, override_warnings_not_as_errors,
-               project_sdk, resources, run_analyzers, srcs, strict_deps, target_frameworks,
-               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors)
+               nullable, out, override_strict_deps, project_sdk, resources, run_analyzers, srcs,
+               strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+               warnings_as_errors, warnings_not_as_errors)
 
Compile a C# DLL @@ -39,10 +38,6 @@ Compile a C# DLL | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | diff --git a/docs/csharp_test.md b/docs/csharp_test.md index 3d9c5ba4..c966a0de 100644 --- a/docs/csharp_test.md +++ b/docs/csharp_test.md @@ -12,13 +12,11 @@ a Bazel test. ## csharp_test
-csharp_test(name, additionalfiles, allow_unsafe_blocks, apphost_shimmer, compile_data, data,
-            defines, deps, generate_documentation_file, internals_visible_to, keyfile, langversion,
-            nullable, out, override_strict_deps, override_treat_warnings_as_errors,
-            override_warning_level, override_warnings_as_errors, override_warnings_not_as_errors,
-            project_sdk, resources, roll_forward_behavior, run_analyzers, srcs, strict_deps,
-            target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
-            warnings_not_as_errors, winexe)
+csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
+            generate_documentation_file, internals_visible_to, keyfile, langversion, nullable, out,
+            override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+            strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+            warnings_as_errors, warnings_not_as_errors, winexe)
 
Compiles a C# executable and runs it as a test @@ -31,7 +29,6 @@ Compiles a C# executable and runs it as a test | name | A unique name for this target. | Name | required | | | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | -| apphost_shimmer | - | Label | optional | None | | compile_data | Additional compile time files. | List of labels | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | @@ -43,10 +40,6 @@ Compiles a C# executable and runs it as a test | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | diff --git a/docs/defs.md b/docs/defs.md index 3d2e16d4..0d691ed7 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -5,261 +5,381 @@ Public API surface is re-exported here. Users should not load files under "/dotnet" - + -## import_dll +## csharp_binary
-import_dll(name, data, dll, version)
+csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
+              generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
+              langversion, nullable, out, override_strict_deps, project_sdk, resources,
+              roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
-Imports a DLL +Compile a C# exe **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| data | Other files that this DLL depends on at runtime | List of labels | optional | [] | -| dll | The name of the library | Label | required | | -| version | The version of the library | String | optional | "" | +| name | A unique name for this target. | Name | required | | +| additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | +| allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| include_host_model_dll | Whether to include Microsoft.NET.HostModel from the toolchain. This is only required to build tha apphost shimmer. | Boolean | optional | False | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | +| run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| winexe | If true, output a winexe-style executable, otherwiseoutput a console-style executable. | Boolean | optional | False | - + -## import_library +## csharp_library
-import_library(name, analyzers, data, deps, framework_list, library_name, libs, native, nupkg, refs,
-               sha512, targeting_pack_overrides, version)
+csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
+               exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
+               nullable, out, override_strict_deps, project_sdk, resources, run_analyzers, srcs,
+               strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+               warnings_as_errors, warnings_not_as_errors)
 
-Creates a target for a static DLL for a specific target framework +Compile a C# DLL **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| analyzers | Static analyzer DLLs | List of labels | optional | [] | -| data | Other files that this DLL depends on at runtime | List of labels | optional | [] | -| deps | Other DLLs that this DLL depends on. | List of labels | optional | [] | -| framework_list | Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PlatformManifest.txt that includes all the DLLs that are included in the targeting pack. This is used to determine which version of a DLL should be used during compilation or runtime. | Dictionary: String -> String | optional | {} | -| library_name | The name of the library | String | required | | -| libs | Static runtime DLLs | List of labels | optional | [] | -| native | Native runtime DLLs | List of labels | optional | [] | -| nupkg | The .nupkg file providing this import | Label | optional | None | -| refs | Compile time DLLs | List of labels | optional | [] | -| sha512 | The SHA512 sum of the NuGet package | String | optional | "" | -| targeting_pack_overrides | Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PackageOverride.txt that includes a list of NuGet packages that should be omitted in a compiliation because they are included in the targeting pack | Dictionary: String -> String | optional | {} | -| version | The version of the library | String | optional | "" | +| name | A unique name for this target. | Name | required | | +| additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | +| allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| exports | List of targets to add to the dependencies of those that depend on this target. Use this sparingly as it weakens the precision of the build graph.

This attribute does nothing if you don't have strict dependencies enabled. | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | - + -## nuget_archive +## csharp_test
-nuget_archive(name, id, netrc, repo_mapping, sha512, sources, version)
+csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
+            generate_documentation_file, internals_visible_to, keyfile, langversion, nullable, out,
+            override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+            strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+            warnings_as_errors, warnings_not_as_errors, winexe)
 
- +Compiles a C# executable and runs it as a test **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this repository. | Name | required | | -| id | - | String | optional | "" | -| netrc | - | Label | optional | None | -| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | | -| sha512 | - | String | optional | "" | -| sources | - | List of strings | optional | [] | -| version | - | String | optional | "" | +| name | A unique name for this target. | Name | required | | +| additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | +| allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | +| run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| winexe | If true, output a winexe-style executable, otherwiseoutput a console-style executable. | Boolean | optional | False | - + -## publish_binary +## fsharp_binary
-publish_binary(name, binary, roll_forward_behavior, runtime_identifier, self_contained,
-               target_framework)
+fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
+              internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+              resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
-Publish a .Net binary +Compile a F# exe **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| binary | The .Net binary that is being published | Label | required | | -| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Minor" | -| runtime_identifier | The runtime identifier that is being targeted. See https://docs.microsoft.com/en-us/dotnet/core/rid-catalog | String | optional | "" | -| self_contained | Whether the binary should be self-contained.

If true, the binary will be published as a self-contained but you need to provide a runtime pack in the runtime_packs attribute. At some point the rules might resolve the runtime pack automatically.

If false, the binary will be published as a non-self-contained. That means that to be able to run the binary you need to have a .Net runtime installed on the host system. | Boolean | optional | False | -| target_framework | The target framework that should be published | String | required | | +| name | A unique name for this target. | Name | required | | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| winexe | If true, output a winexe-style executable, otherwiseoutput a console-style executable. | Boolean | optional | False | - + -## csharp_binary +## fsharp_library
-csharp_binary(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors,
-              warnings_not_as_errors, warning_level, strict_deps, kwargs)
+fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
+               internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+               resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
+               warning_level, warnings_as_errors, warnings_not_as_errors)
 
+Compile a F# DLL - -**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| exports | List of targets to add to the dependencies of those that depend on this target. Use this sparingly as it weakens the precision of the build graph.

This attribute does nothing if you don't have strict dependencies enabled. | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | - + -## csharp_library +## fsharp_test
-csharp_library(treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors, warning_level,
-               strict_deps, kwargs)
+fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
+            internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+            resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+            winexe)
 
+Compile a F# executable and runs it as a test - -**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| compile_data | Additional compile time files. | List of labels | optional | [] | +| data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | +| defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | +| deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | +| generate_documentation_file | Whether or not to generate a documentation file. | Boolean | optional | True | +| internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | +| keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | +| langversion | The version string for the language. | String | optional | "" | +| out | File name, without extension, of the built assembly. | String | optional | "" | +| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | +| project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | +| resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | +| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | +| srcs | The source files used in the compilation. | List of labels | optional | [] | +| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | +| target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | +| treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | +| warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | +| warnings_as_errors | List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| warnings_not_as_errors | List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. | List of strings | optional | [] | +| winexe | If true, output a winexe-style executable, otherwiseoutput a console-style executable. | Boolean | optional | False | - + -## csharp_nunit_test +## import_dll
-csharp_nunit_test(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors,
-                  warnings_not_as_errors, warning_level, strict_deps, kwargs)
+import_dll(name, data, dll, version)
 
+Imports a DLL - -**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| data | Other files that this DLL depends on at runtime | List of labels | optional | [] | +| dll | The name of the library | Label | required | | +| version | The version of the library | String | optional | "" | - + -## csharp_test +## import_library
-csharp_test(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors,
-            warning_level, strict_deps, kwargs)
+import_library(name, analyzers, data, deps, framework_list, library_name, libs, native, nupkg, refs,
+               sha512, targeting_pack_overrides, version)
 
+Creates a target for a static DLL for a specific target framework - -**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| analyzers | Static analyzer DLLs | List of labels | optional | [] | +| data | Other files that this DLL depends on at runtime | List of labels | optional | [] | +| deps | Other DLLs that this DLL depends on. | List of labels | optional | [] | +| framework_list | Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PlatformManifest.txt that includes all the DLLs that are included in the targeting pack. This is used to determine which version of a DLL should be used during compilation or runtime. | Dictionary: String -> String | optional | {} | +| library_name | The name of the library | String | required | | +| libs | Static runtime DLLs | List of labels | optional | [] | +| native | Native runtime DLLs | List of labels | optional | [] | +| nupkg | The .nupkg file providing this import | Label | optional | None | +| refs | Compile time DLLs | List of labels | optional | [] | +| sha512 | The SHA512 sum of the NuGet package | String | optional | "" | +| targeting_pack_overrides | Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PackageOverride.txt that includes a list of NuGet packages that should be omitted in a compiliation because they are included in the targeting pack | Dictionary: String -> String | optional | {} | +| version | The version of the library | String | optional | "" | - + -## fsharp_binary +## nuget_archive
-fsharp_binary(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors,
-              warnings_not_as_errors, warning_level, strict_deps, kwargs)
+nuget_archive(name, id, netrc, repo_mapping, sha512, sources, version)
 
-**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this repository. | Name | required | | +| id | - | String | optional | "" | +| netrc | - | Label | optional | None | +| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | | +| sha512 | - | String | optional | "" | +| sources | - | List of strings | optional | [] | +| version | - | String | optional | "" | - + -## fsharp_library +## publish_binary
-fsharp_library(treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors, warning_level,
-               strict_deps, kwargs)
+publish_binary(name, binary, roll_forward_behavior, runtime_identifier, self_contained,
+               target_framework)
 
+Publish a .Net binary - -**PARAMETERS** +**ATTRIBUTES** -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| binary | The .Net binary that is being published | Label | required | | +| roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Minor" | +| runtime_identifier | The runtime identifier that is being targeted. See https://docs.microsoft.com/en-us/dotnet/core/rid-catalog | String | optional | "" | +| self_contained | Whether the binary should be self-contained.

If true, the binary will be published as a self-contained but you need to provide a runtime pack in the runtime_packs attribute. At some point the rules might resolve the runtime pack automatically.

If false, the binary will be published as a non-self-contained. That means that to be able to run the binary you need to have a .Net runtime installed on the host system. | Boolean | optional | False | +| target_framework | The target framework that should be published | String | required | | - + -## fsharp_nunit_test +## csharp_nunit_test
-fsharp_nunit_test(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors,
-                  warnings_not_as_errors, warning_level, strict_deps, kwargs)
+csharp_nunit_test(kwargs)
 
@@ -269,22 +389,15 @@ fsharp_nunit_test(use_apphost_shim | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| kwargs |

-

| none | - + -## fsharp_test +## fsharp_nunit_test
-fsharp_test(use_apphost_shim, treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors,
-            warning_level, strict_deps, kwargs)
+fsharp_nunit_test(kwargs)
 
@@ -294,13 +407,7 @@ fsharp_test(use_apphost_shim, use_apphost_shim |

-

| True | -| treat_warnings_as_errors |

-

| None | -| warnings_as_errors |

-

| None | -| warnings_not_as_errors |

-

| None | -| warning_level |

-

| None | -| strict_deps |

-

| None | -| kwargs |

-

| none | +| kwargs |

-

| none | diff --git a/docs/fsharp_binary.md b/docs/fsharp_binary.md index ecd3744b..dbe52ded 100644 --- a/docs/fsharp_binary.md +++ b/docs/fsharp_binary.md @@ -9,12 +9,11 @@ Rule for compiling F# binaries. ## fsharp_binary
-fsharp_binary(name, apphost_shimmer, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, out, override_strict_deps,
-              override_treat_warnings_as_errors, override_warning_level, override_warnings_as_errors,
-              override_warnings_not_as_errors, project_sdk, resources, roll_forward_behavior, srcs,
-              strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-              warnings_as_errors, warnings_not_as_errors, winexe)
+fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
+              internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+              resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a F# exe @@ -25,7 +24,6 @@ Compile a F# exe | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| apphost_shimmer | - | Label | optional | None | | compile_data | Additional compile time files. | List of labels | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | @@ -36,10 +34,6 @@ Compile a F# exe | langversion | The version string for the language. | String | optional | "" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | diff --git a/docs/fsharp_library.md b/docs/fsharp_library.md index d72d1ff2..13d7c522 100644 --- a/docs/fsharp_library.md +++ b/docs/fsharp_library.md @@ -10,11 +10,9 @@ Rule for compiling F# libraries.
 fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, out, override_strict_deps,
-               override_treat_warnings_as_errors, override_warning_level, override_warnings_as_errors,
-               override_warnings_not_as_errors, project_sdk, resources, srcs, strict_deps,
-               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
-               warnings_not_as_errors)
+               internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+               resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
+               warning_level, warnings_as_errors, warnings_not_as_errors)
 
Compile a F# DLL @@ -36,10 +34,6 @@ Compile a F# DLL | langversion | The version string for the language. | String | optional | "" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | srcs | The source files used in the compilation. | List of labels | optional | [] | diff --git a/docs/fsharp_test.md b/docs/fsharp_test.md index 7c8f4baa..f744b843 100644 --- a/docs/fsharp_test.md +++ b/docs/fsharp_test.md @@ -12,12 +12,11 @@ a Bazel test. ## fsharp_test
-fsharp_test(name, apphost_shimmer, compile_data, data, defines, deps, generate_documentation_file,
-            internals_visible_to, keyfile, langversion, out, override_strict_deps,
-            override_treat_warnings_as_errors, override_warning_level, override_warnings_as_errors,
-            override_warnings_not_as_errors, project_sdk, resources, roll_forward_behavior, srcs,
-            strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-            warnings_as_errors, warnings_not_as_errors, winexe)
+fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
+            internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
+            resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+            winexe)
 
Compile a F# executable and runs it as a test @@ -28,7 +27,6 @@ Compile a F# executable and runs it as a test | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| apphost_shimmer | - | Label | optional | None | | compile_data | Additional compile time files. | List of labels | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | @@ -39,10 +37,6 @@ Compile a F# executable and runs it as a test | langversion | The version string for the language. | String | optional | "" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | -| override_treat_warnings_as_errors | Whether or not to override the treat_warnings_as_errors attribute. | Boolean | optional | False | -| override_warning_level | Whether or not to override the warning_level attribute. | Boolean | optional | False | -| override_warnings_as_errors | Whether or not to override the warnings_as_errors attribute. | Boolean | optional | False | -| override_warnings_not_as_errors | Whether or not to override the warnings_not_as_errors attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | diff --git a/dotnet/defs.bzl b/dotnet/defs.bzl index d9c30dad..2a159b3a 100644 --- a/dotnet/defs.bzl +++ b/dotnet/defs.bzl @@ -53,186 +53,14 @@ load( _publish_binary = "publish_binary", ) -def csharp_binary( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _csharp_binary( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - -def csharp_library( - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _csharp_library( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - **kwargs - ) - -def csharp_test( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _csharp_test( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - -def csharp_nunit_test( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _csharp_nunit_test( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - -def fsharp_binary( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _fsharp_binary( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - -def fsharp_library( - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _fsharp_library( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - **kwargs - ) - -def fsharp_test( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _fsharp_test( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - -def fsharp_nunit_test( - use_apphost_shim = True, - treat_warnings_as_errors = None, - warnings_as_errors = None, - warnings_not_as_errors = None, - warning_level = None, - strict_deps = None, - **kwargs): - _fsharp_nunit_test( - treat_warnings_as_errors = treat_warnings_as_errors if treat_warnings_as_errors != None else False, - override_treat_warnings_as_errors = True if treat_warnings_as_errors != None else False, - warnings_as_errors = warnings_as_errors if warnings_as_errors != None else [], - override_warnings_as_errors = True if warnings_as_errors != None else False, - warnings_not_as_errors = warnings_not_as_errors if warnings_not_as_errors != None else [], - override_warnings_not_as_errors = True if warnings_not_as_errors != None else False, - warning_level = warning_level if warning_level != None else 3, - override_warning_level = True if warning_level != None else False, - strict_deps = strict_deps if strict_deps != None else True, - override_strict_deps = True if strict_deps != None else False, - apphost_shimmer = Label("//dotnet/private/tools/apphost_shimmer:apphost_shimmer") if use_apphost_shim else None, - **kwargs - ) - +csharp_binary = _csharp_binary +csharp_library = _csharp_library +csharp_test = _csharp_test +csharp_nunit_test = _csharp_nunit_test +fsharp_binary = _fsharp_binary +fsharp_library = _fsharp_library +fsharp_test = _fsharp_test +fsharp_nunit_test = _fsharp_nunit_test publish_binary = _publish_binary import_library = _import_library import_dll = _import_dll diff --git a/dotnet/private/BUILD.bazel b/dotnet/private/BUILD.bazel index 4b806edd..1cd9e8d4 100644 --- a/dotnet/private/BUILD.bazel +++ b/dotnet/private/BUILD.bazel @@ -22,42 +22,6 @@ bzl_library( ], ) -bzl_library( - name = "providers", - srcs = ["providers.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - -bzl_library( - name = "resolved_toolchain", - srcs = ["resolved_toolchain.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - -bzl_library( - name = "rids", - srcs = ["rids.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - -bzl_library( - name = "semver", - srcs = ["semver.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - -bzl_library( - name = "toolchains_repo", - srcs = ["toolchains_repo.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - -bzl_library( - name = "versions", - srcs = ["versions.bzl"], - visibility = ["//dotnet:__subpackages__"], -) - config_setting( name = "linux", constraint_values = [ @@ -135,3 +99,39 @@ config_setting( ], visibility = ["//visibility:public"], ) + +bzl_library( + name = "providers", + srcs = ["providers.bzl"], + visibility = ["//dotnet:__subpackages__"], +) + +bzl_library( + name = "resolved_toolchain", + srcs = ["resolved_toolchain.bzl"], + visibility = ["//dotnet:__subpackages__"], +) + +bzl_library( + name = "rids", + srcs = ["rids.bzl"], + visibility = ["//dotnet:__subpackages__"], +) + +bzl_library( + name = "semver", + srcs = ["semver.bzl"], + visibility = ["//dotnet:__subpackages__"], +) + +bzl_library( + name = "toolchains_repo", + srcs = ["toolchains_repo.bzl"], + visibility = ["//dotnet:__subpackages__"], +) + +bzl_library( + name = "versions", + srcs = ["versions.bzl"], + visibility = ["//dotnet:__subpackages__"], +) diff --git a/dotnet/private/providers.bzl b/dotnet/private/providers.bzl index 46569cf4..76c81671 100644 --- a/dotnet/private/providers.bzl +++ b/dotnet/private/providers.bzl @@ -57,9 +57,9 @@ NuGetInfo = provider( DotnetBinaryInfo = provider( doc = "Information about a .Net binary", fields = { - "app_host": "File: The apphost executable", "dll": "File: The main binary dll", "transitive_runtime_deps": "list[DotnetAssemblyRuntimeInfo]: The transitive runtime dependencies of the binary", + "apphost_pack_info": "DotnetApphostPackInfo: The apphost pack for the binary", "runtime_pack_info": "DotnetRuntimePackInfo: The runtime pack for the binary", }, ) diff --git a/dotnet/private/rules/common/BUILD.bazel b/dotnet/private/rules/common/BUILD.bazel index b2f0c40c..21149f2b 100644 --- a/dotnet/private/rules/common/BUILD.bazel +++ b/dotnet/private/rules/common/BUILD.bazel @@ -7,7 +7,6 @@ bzl_library( deps = [ "//dotnet/private:common", "//dotnet/private:providers", - "@bazel_skylib//lib:paths", "@bazel_skylib//rules:common_settings", ], ) diff --git a/dotnet/private/rules/common/attrs.bzl b/dotnet/private/rules/common/attrs.bzl index 10c0647c..08dc0c7f 100644 --- a/dotnet/private/rules/common/attrs.bzl +++ b/dotnet/private/rules/common/attrs.bzl @@ -76,26 +76,17 @@ COMMON_ATTRS = { "treat_warnings_as_errors": attr.bool( doc = "Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors.", mandatory = False, - ), - "override_treat_warnings_as_errors": attr.bool( - doc = "Whether or not to override the treat_warnings_as_errors attribute.", - mandatory = False, + default = False, ), "warnings_as_errors": attr.string_list( doc = "List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors.", mandatory = False, - ), - "override_warnings_as_errors": attr.bool( - doc = "Whether or not to override the warnings_as_errors attribute.", - mandatory = False, + default = [], ), "warnings_not_as_errors": attr.string_list( doc = "List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors.", mandatory = False, - ), - "override_warnings_not_as_errors": attr.bool( - doc = "Whether or not to override the warnings_not_as_errors attribute.", - mandatory = False, + default = [], ), "warning_level": attr.int( doc = "The warning level that should be used by the compiler.", @@ -103,10 +94,6 @@ COMMON_ATTRS = { values = [0, 1, 2, 3, 4, 5], default = 3, ), - "override_warning_level": attr.bool( - doc = "Whether or not to override the warning_level attribute.", - mandatory = False, - ), "strict_deps": attr.bool( doc = """Whether to use strict dependencies or not. @@ -172,11 +159,6 @@ BINARY_COMMON_ATTRS = { "output a console-style executable.", default = False, ), - "apphost_shimmer": attr.label( - providers = [DotnetAssemblyCompileInfo, DotnetAssemblyRuntimeInfo], - executable = True, - cfg = default_transition, - ), "_bash_runfiles": attr.label( default = "@bazel_tools//tools/bash/runfiles", allow_single_file = True, diff --git a/dotnet/private/rules/common/binary.bzl b/dotnet/private/rules/common/binary.bzl index 5f051926..512c1988 100644 --- a/dotnet/private/rules/common/binary.bzl +++ b/dotnet/private/rules/common/binary.bzl @@ -2,7 +2,6 @@ Base rule for building .Net binaries """ -load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load( "//dotnet/private:common.bzl", @@ -15,22 +14,6 @@ load( ) load("//dotnet/private:providers.bzl", "DotnetApphostPackInfo", "DotnetBinaryInfo", "DotnetRuntimePackInfo") -def _create_shim_exe(ctx, dll): - windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo] - - apphost = ctx.attr._apphost_pack[0][DotnetApphostPackInfo].apphost - output = ctx.actions.declare_file(paths.replace_extension(dll.basename, ".exe" if ctx.target_platform_has_constraint(windows_constraint) else ""), sibling = dll) - - ctx.actions.run( - executable = ctx.attr.apphost_shimmer[0].files_to_run, - arguments = [apphost.path, dll.path, output.path], - inputs = depset([apphost, dll], transitive = [ctx.attr.apphost_shimmer[0].default_runfiles.files]), - tools = [ctx.attr.apphost_shimmer[0].files, ctx.attr.apphost_shimmer[0].default_runfiles.files], - outputs = [output], - ) - - return output - def _create_launcher(ctx, runfiles, executable): runtime = ctx.toolchains["//dotnet:toolchain_type"].runtime windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo] @@ -87,12 +70,6 @@ def build_binary(ctx, compile_action): default_info_files = [dll] + runtime_provider.xml_docs additional_runfiles = [] - app_host = None - if len(ctx.attr.apphost_shimmer) > 0: - app_host = _create_shim_exe(ctx, dll) - additional_runfiles.append(app_host) - default_info_files = default_info_files.append(app_host) - launcher = _create_launcher(ctx, additional_runfiles, dll) runtimeconfig = None @@ -154,8 +131,8 @@ def build_binary(ctx, compile_action): dotnet_binary_info = DotnetBinaryInfo( dll = dll, - app_host = app_host, transitive_runtime_deps = transitive_runtime_deps, + apphost_pack_info = ctx.attr._apphost_pack[0][DotnetApphostPackInfo], runtime_pack_info = ctx.attr._runtime_pack[0][DotnetRuntimePackInfo], ) diff --git a/dotnet/private/rules/csharp/binary.bzl b/dotnet/private/rules/csharp/binary.bzl index db6e7a68..16b265e6 100644 --- a/dotnet/private/rules/csharp/binary.bzl +++ b/dotnet/private/rules/csharp/binary.bzl @@ -39,10 +39,10 @@ def _compile_action(ctx, tfm): strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = ctx.attr.include_host_model_dll, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.csharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.csharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.csharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.csharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/csharp/library.bzl b/dotnet/private/rules/csharp/library.bzl index 22ab7043..df13704f 100644 --- a/dotnet/private/rules/csharp/library.bzl +++ b/dotnet/private/rules/csharp/library.bzl @@ -38,10 +38,10 @@ def _compile_action(ctx, tfm): strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = False, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.csharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.csharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.csharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.csharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/csharp/test.bzl b/dotnet/private/rules/csharp/test.bzl index f535552b..51b6fa03 100644 --- a/dotnet/private/rules/csharp/test.bzl +++ b/dotnet/private/rules/csharp/test.bzl @@ -41,10 +41,10 @@ def _compile_action(ctx, tfm): strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = False, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.csharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.csharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.csharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.csharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/fsharp/binary.bzl b/dotnet/private/rules/fsharp/binary.bzl index 77a54bb9..58397d42 100644 --- a/dotnet/private/rules/fsharp/binary.bzl +++ b/dotnet/private/rules/fsharp/binary.bzl @@ -36,10 +36,10 @@ def _compile_action(ctx, tfm): toolchain = toolchain, strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.fsharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.fsharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.fsharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.fsharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/rules/fsharp/library.bzl b/dotnet/private/rules/fsharp/library.bzl index 6750c573..7d969648 100644 --- a/dotnet/private/rules/fsharp/library.bzl +++ b/dotnet/private/rules/fsharp/library.bzl @@ -37,10 +37,10 @@ def _compile_action(ctx, tfm): toolchain = toolchain, strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.fsharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.fsharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.fsharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.fsharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/rules/fsharp/test.bzl b/dotnet/private/rules/fsharp/test.bzl index 43ea9d5f..f6ef3200 100644 --- a/dotnet/private/rules/fsharp/test.bzl +++ b/dotnet/private/rules/fsharp/test.bzl @@ -39,10 +39,10 @@ def _compile_action(ctx, tfm): toolchain = toolchain, strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, - treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors if ctx.attr.override_treat_warnings_as_errors else toolchain.dotnetinfo.fsharp_treat_warnings_as_errors[BuildSettingInfo].value, - warnings_as_errors = ctx.attr.warnings_as_errors if ctx.attr.override_warnings_as_errors else toolchain.dotnetinfo.fsharp_warnings_as_errors[BuildSettingInfo].value, - warnings_not_as_errors = ctx.attr.warnings_not_as_errors if ctx.attr.override_warnings_not_as_errors else toolchain.dotnetinfo.fsharp_warnings_not_as_errors[BuildSettingInfo].value, - warning_level = ctx.attr.warning_level if ctx.attr.override_warning_level else toolchain.dotnetinfo.fsharp_warning_level[BuildSettingInfo].value, + treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, + warnings_as_errors = ctx.attr.warnings_as_errors, + warnings_not_as_errors = ctx.attr.warnings_not_as_errors, + warning_level = ctx.attr.warning_level, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/rules/publish_binary/BUILD.bazel b/dotnet/private/rules/publish_binary/BUILD.bazel index fbfa4294..359029c7 100644 --- a/dotnet/private/rules/publish_binary/BUILD.bazel +++ b/dotnet/private/rules/publish_binary/BUILD.bazel @@ -15,7 +15,9 @@ bzl_library( deps = [ "//dotnet/private:providers", "//dotnet/private/sdk/runtime_packs:runtime_pack_transition", + "//dotnet/private/transitions:default_transition", "//dotnet/private/transitions:tfm_transition", + "@bazel_skylib//lib:paths", "@bazel_skylib//lib:shell", ], ) diff --git a/dotnet/private/rules/publish_binary/publish_binary.bzl b/dotnet/private/rules/publish_binary/publish_binary.bzl index 6d403976..431b9230 100644 --- a/dotnet/private/rules/publish_binary/publish_binary.bzl +++ b/dotnet/private/rules/publish_binary/publish_binary.bzl @@ -2,9 +2,11 @@ Rules for compiling F# binaries. """ +load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//lib:shell.bzl", "shell") load("//dotnet/private:common.bzl", "generate_depsjson", "generate_runtimeconfig", "to_rlocation_path") load("//dotnet/private:providers.bzl", "DotnetAssemblyCompileInfo", "DotnetAssemblyRuntimeInfo", "DotnetBinaryInfo") +load("//dotnet/private/transitions:default_transition.bzl", "default_transition") load("//dotnet/private/transitions:tfm_transition.bzl", "tfm_transition") def _copy_file(script_body, src, dst, is_windows): @@ -26,14 +28,14 @@ def _get_assembly_files(assembly_info, transitive_runtime_deps): def _copy_to_publish(ctx, runtime_identifier, runtime_pack_info, binary_info, assembly_info, transitive_runtime_deps, repo_mapping_manifest): is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) - inputs = [binary_info.app_host] - app_host_copy = ctx.actions.declare_file( - "{}/publish/{}/{}".format(ctx.label.name, runtime_identifier, binary_info.app_host.basename), + inputs = [binary_info.dll] + main_dll_copy = ctx.actions.declare_file( + "{}/publish/{}/{}".format(ctx.label.name, runtime_identifier, binary_info.dll.basename), ) - outputs = [app_host_copy] + outputs = [main_dll_copy] script_body = ["@echo off"] if is_windows else ["#! /usr/bin/env bash", "set -eou pipefail"] - _copy_file(script_body, binary_info.app_host, app_host_copy, is_windows = is_windows) + _copy_file(script_body, binary_info.dll, main_dll_copy, is_windows = is_windows) (libs, native, data) = _get_assembly_files(assembly_info, transitive_runtime_deps) @@ -73,7 +75,7 @@ def _copy_to_publish(ctx, runtime_identifier, runtime_pack_info, binary_info, as inputs.append(file) manifest_path = to_rlocation_path(ctx, file) output = ctx.actions.declare_file( - "{}/publish/{}/{}.runfiles/{}".format(ctx.label.name, runtime_identifier, binary_info.app_host.basename, manifest_path), + "{}/publish/{}/{}.runfiles/{}".format(ctx.label.name, runtime_identifier, paths.replace_extension(binary_info.dll.basename, ""), manifest_path), ) outputs.append(output) _copy_file(script_body, file, output, is_windows = is_windows) @@ -83,7 +85,7 @@ def _copy_to_publish(ctx, runtime_identifier, runtime_pack_info, binary_info, as if repo_mapping_manifest: inputs.append(repo_mapping_manifest) output = ctx.actions.declare_file( - "{}/publish/{}/{}.runfiles/_repo_mapping".format(ctx.label.name, runtime_identifier, binary_info.app_host.basename), + "{}/publish/{}/{}.runfiles/_repo_mapping".format(ctx.label.name, runtime_identifier, paths.replace_extension(binary_info.dll.basename, "")), ) outputs.append(output) _copy_file(script_body, repo_mapping_manifest, output, is_windows = is_windows) @@ -99,7 +101,7 @@ def _copy_to_publish(ctx, runtime_identifier, runtime_pack_info, binary_info, as runtime_pack.data, ) for file in runtime_pack_files.to_list(): - output = ctx.actions.declare_file(file.basename, sibling = app_host_copy) + output = ctx.actions.declare_file(file.basename, sibling = main_dll_copy) outputs.append(output) inputs.append(file) _copy_file(script_body, file, output, is_windows = is_windows) @@ -118,7 +120,23 @@ def _copy_to_publish(ctx, runtime_identifier, runtime_pack_info, binary_info, as tools = [copy_script], ) - return (app_host_copy, outputs) + return (main_dll_copy, outputs) + +def _create_shim_exe(ctx, apphost_pack_info, dll): + windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo] + + apphost = apphost_pack_info.apphost + output = ctx.actions.declare_file(paths.replace_extension(dll.basename, ".exe" if ctx.target_platform_has_constraint(windows_constraint) else ""), sibling = dll) + + ctx.actions.run( + executable = ctx.attr._apphost_shimmer[0].files_to_run, + arguments = [apphost.path, dll.path, output.path], + inputs = depset([apphost, dll], transitive = [ctx.attr._apphost_shimmer[0].default_runfiles.files]), + tools = [ctx.attr._apphost_shimmer[0].files, ctx.attr._apphost_shimmer[0].default_runfiles.files], + outputs = [output], + ) + + return output def _generate_runtimeconfig(ctx, output, target_framework, project_sdk, is_self_contained, roll_forward_behavior, runtime_pack_info): runtimeconfig_struct = generate_runtimeconfig(target_framework, project_sdk, is_self_contained, roll_forward_behavior, runtime_pack_info) @@ -157,7 +175,7 @@ def _publish_binary_impl(ctx): runtime_identifier = binary_info.runtime_pack_info.runtime_identifier roll_forward_behavior = ctx.attr.roll_forward_behavior - (executable, runfiles) = _copy_to_publish( + (main_dll, runfiles) = _copy_to_publish( ctx, runtime_identifier, runtime_pack_info, @@ -167,6 +185,8 @@ def _publish_binary_impl(ctx): repo_mapping_manifest, ) + apphost_shim = _create_shim_exe(ctx, binary_info.apphost_pack_info, main_dll) + runtimeconfig = ctx.actions.declare_file("{}/publish/{}/{}.runtimeconfig.json".format( ctx.label.name, runtime_identifier, @@ -195,9 +215,9 @@ def _publish_binary_impl(ctx): return [ DefaultInfo( - executable = executable, - files = depset([executable, runtimeconfig, depsjson] + runfiles), - runfiles = ctx.runfiles(files = [executable, runtimeconfig, depsjson] + runfiles), + executable = apphost_shim, + files = depset([apphost_shim, main_dll, runtimeconfig, depsjson] + runfiles), + runfiles = ctx.runfiles(files = [apphost_shim, main_dll, runtimeconfig, depsjson] + runfiles), ), ] @@ -242,6 +262,12 @@ publish_binary = rule( default = "Minor", values = ["Minor", "Major", "LatestPatch", "LatestMinor", "LatestMajor", "Disable"], ), + "_apphost_shimmer": attr.label( + providers = [DotnetAssemblyCompileInfo, DotnetAssemblyRuntimeInfo], + executable = True, + default = "//dotnet/private/tools/apphost_shimmer:apphost_shimmer", + cfg = default_transition, + ), "_allowlist_function_transition": attr.label( default = "@bazel_tools//tools/allowlists/function_transition_allowlist", ), diff --git a/dotnet/private/tests/warning_settings/csharp_warnings.bzl b/dotnet/private/tests/warning_settings/csharp_warnings.bzl index f7c56d44..2844d385 100644 --- a/dotnet/private/tests/warning_settings/csharp_warnings.bzl +++ b/dotnet/private/tests/warning_settings/csharp_warnings.bzl @@ -1,74 +1,11 @@ "C# Warning settings" -load("@bazel_skylib//lib:unittest.bzl", "analysistest") load("//dotnet:defs.bzl", "csharp_library") -load("//dotnet/private/tests:utils.bzl", "ACTION_ARGS_TEST_ARGS", "action_args_test", "action_args_test_impl") - -csharp_treat_warnings_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:csharp_treat_warnings_as_errors")): True}, -) - -csharp_warnings_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:csharp_warnings_as_errors")): ["CS0025", "CS0026"]}, -) - -csharp_warnings_not_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = { - str(Label("//dotnet/settings:csharp_treat_warnings_as_errors")): True, - str(Label("//dotnet/settings:csharp_warnings_not_as_errors")): ["CS0025", "CS0026"], - }, -) - -csharp_warning_level_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:csharp_warning_level")): 5}, -) +load("//dotnet/private/tests:utils.bzl", "action_args_test") # buildifier: disable=function-docstring # buildifier: disable=unnamed-macro def csharp_warnings(): - csharp_library( - name = "csharp", - srcs = ["warnings.cs"], - target_frameworks = ["net6.0"], - tags = ["manual"], - ) - - csharp_treat_warnings_as_errors_config_wrapper_test( - name = "csharp_treat_warnings_as_errors_config_test", - target_under_test = ":csharp", - action_mnemonic = "CSharpCompile", - expected_partial_args = ["/warnaserror+"], - ) - - csharp_warnings_as_errors_config_wrapper_test( - name = "csharp_warnings_as_errors_config_wrapper_test", - target_under_test = ":csharp", - action_mnemonic = "CSharpCompile", - expected_partial_args = ["/warnaserror+:CS0025", "/warnaserror+:CS0026"], - ) - - csharp_warnings_not_as_errors_config_wrapper_test( - name = "csharp_warnings_not_as_errors_config_wrapper_test", - target_under_test = ":csharp", - action_mnemonic = "CSharpCompile", - expected_partial_args = ["/warnaserror-:CS0025", "/warnaserror-:CS0026"], - ) - - csharp_warning_level_config_wrapper_test( - name = "csharp_warning_level_config_wrapper_test", - target_under_test = ":csharp", - action_mnemonic = "CSharpCompile", - expected_partial_args = ["/warn:5"], - ) - csharp_library( name = "csharp_all_warnings", srcs = ["warnings.cs"], diff --git a/dotnet/private/tests/warning_settings/fsharp_warnings.bzl b/dotnet/private/tests/warning_settings/fsharp_warnings.bzl index bb52ffe4..1e1a06bb 100644 --- a/dotnet/private/tests/warning_settings/fsharp_warnings.bzl +++ b/dotnet/private/tests/warning_settings/fsharp_warnings.bzl @@ -1,74 +1,11 @@ "F# Warning settings" -load("@bazel_skylib//lib:unittest.bzl", "analysistest") load("//dotnet:defs.bzl", "fsharp_library") -load("//dotnet/private/tests:utils.bzl", "ACTION_ARGS_TEST_ARGS", "action_args_test", "action_args_test_impl") - -fsharp_treat_warnings_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:fsharp_treat_warnings_as_errors")): True}, -) - -fsharp_warnings_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:fsharp_warnings_as_errors")): ["FS0025", "FS0026"]}, -) - -fsharp_warnings_not_as_errors_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = { - str(Label("//dotnet/settings:fsharp_treat_warnings_as_errors")): True, - str(Label("//dotnet/settings:fsharp_warnings_not_as_errors")): ["FS0025", "FS0026"], - }, -) - -fsharp_warning_level_config_wrapper_test = analysistest.make( - action_args_test_impl, - attrs = ACTION_ARGS_TEST_ARGS, - config_settings = {str(Label("//dotnet/settings:fsharp_warning_level")): 5}, -) +load("//dotnet/private/tests:utils.bzl", "action_args_test") # buildifier: disable=function-docstring # buildifier: disable=unnamed-macro def fsharp_warnings(): - fsharp_library( - name = "fsharp", - srcs = ["warnings.fs"], - target_frameworks = ["net6.0"], - tags = ["manual"], - ) - - fsharp_treat_warnings_as_errors_config_wrapper_test( - name = "fsharp_treat_warnings_as_errors_config_test", - target_under_test = ":fsharp", - action_mnemonic = "FSharpCompile", - expected_partial_args = ["/warnaserror+"], - ) - - fsharp_warnings_as_errors_config_wrapper_test( - name = "fsharp_warnings_as_errors_config_wrapper_test", - target_under_test = ":fsharp", - action_mnemonic = "FSharpCompile", - expected_partial_args = ["/warnaserror+:FS0025", "/warnaserror+:FS0026"], - ) - - fsharp_warnings_not_as_errors_config_wrapper_test( - name = "fsharp_warnings_not_as_errors_config_wrapper_test", - target_under_test = ":fsharp", - action_mnemonic = "FSharpCompile", - expected_partial_args = ["/warnaserror-:FS0025", "/warnaserror-:FS0026"], - ) - - fsharp_warning_level_config_wrapper_test( - name = "fsharp_warning_level_config_wrapper_test", - target_under_test = ":fsharp", - action_mnemonic = "FSharpCompile", - expected_partial_args = ["/warn:5"], - ) - fsharp_library( name = "fsharp_all_warnings", srcs = ["warnings.fs"], diff --git a/dotnet/private/tools/apphost_shimmer/BUILD.bazel b/dotnet/private/tools/apphost_shimmer/BUILD.bazel index 0c7641b8..933ce298 100644 --- a/dotnet/private/tools/apphost_shimmer/BUILD.bazel +++ b/dotnet/private/tools/apphost_shimmer/BUILD.bazel @@ -11,7 +11,6 @@ csharp_binary( ], include_host_model_dll = True, target_frameworks = ["net6.0"], - use_apphost_shim = False, visibility = ["//visibility:public"], deps = [ ], diff --git a/dotnet/settings/BUILD.bazel b/dotnet/settings/BUILD.bazel index b502685b..82a784fc 100644 --- a/dotnet/settings/BUILD.bazel +++ b/dotnet/settings/BUILD.bazel @@ -1,4 +1,4 @@ -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_list_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") # A flag controlling if strict dependencies are enforced or not. bool_flag( @@ -6,59 +6,3 @@ bool_flag( build_setting_default = True, visibility = ["//visibility:public"], ) - -# A flag controlling if the C# compiler should consider all warnings as errors -bool_flag( - name = "csharp_treat_warnings_as_errors", - build_setting_default = False, - visibility = ["//visibility:public"], -) - -# A flag controlling what C# compiler warning should be considered as errors. -string_list_flag( - name = "csharp_warnings_as_errors", - build_setting_default = [], - visibility = ["//visibility:public"], -) - -# A flag controlling what C# compiler warning should not be considered as errors. -string_list_flag( - name = "csharp_warnings_not_as_errors", - build_setting_default = [], - visibility = ["//visibility:public"], -) - -# A flag controlling the warning level for the C# compiler. -int_flag( - name = "csharp_warning_level", - build_setting_default = 3, - visibility = ["//visibility:public"], -) - -# A flag controlling if the F# compiler should consider all warnings as errors -bool_flag( - name = "fsharp_treat_warnings_as_errors", - build_setting_default = False, - visibility = ["//visibility:public"], -) - -# A flag controlling what F# compiler warning should be considered as errors. -string_list_flag( - name = "fsharp_warnings_as_errors", - build_setting_default = [], - visibility = ["//visibility:public"], -) - -# A flag controlling what F# compiler warning should not be considered as errors. -string_list_flag( - name = "fsharp_warnings_not_as_errors", - build_setting_default = [], - visibility = ["//visibility:public"], -) - -# A flag controlling the warning level for the F# compiler. -int_flag( - name = "fsharp_warning_level", - build_setting_default = 3, - visibility = ["//visibility:public"], -) diff --git a/dotnet/toolchain.bzl b/dotnet/toolchain.bzl index 3068797a..e2a030fd 100644 --- a/dotnet/toolchain.bzl +++ b/dotnet/toolchain.bzl @@ -25,15 +25,7 @@ May be empty if the apphost_path points to a locally installed tool binary.""", "runtime_version": "Version of the dotnet runtime", "runtime_tfm": "The target framework moniker for the current SDK", "csharp_default_version": "Default version of the C# language", - "csharp_treat_warnings_as_errors": "Treat all C# compiler warnings as errors", - "csharp_warnings_as_errors": "List of C# compiler warning codes that should be treated as errors", - "csharp_warnings_not_as_errors": "List of C# compiler warning codes that should not be treated as errors", - "csharp_warning_level": "List of C# compiler warning codes that should not be displayed", "fsharp_default_version": "Default version of the F# language", - "fsharp_treat_warnings_as_errors": "Treat all F# compiler warnings as errors", - "fsharp_warnings_as_errors": "List of F# compiler warning codes that should be treated as errors", - "fsharp_warnings_not_as_errors": "List of F# compiler warning codes that should not be treated as errors", - "fsharp_warning_level": "List of F# compiler warning codes that should not be displayed", }, ) @@ -122,15 +114,7 @@ def _dotnet_toolchain_impl(ctx): runtime_version = ctx.attr.runtime_version, runtime_tfm = ctx.attr.runtime_tfm, csharp_default_version = ctx.attr.csharp_default_version, - csharp_treat_warnings_as_errors = ctx.attr._csharp_treat_warnings_as_errors, - csharp_warnings_as_errors = ctx.attr._csharp_warnings_as_errors, - csharp_warnings_not_as_errors = ctx.attr._csharp_warnings_not_as_errors, - csharp_warning_level = ctx.attr._csharp_warning_level, fsharp_default_version = ctx.attr.fsharp_default_version, - fsharp_treat_warnings_as_errors = ctx.attr._fsharp_treat_warnings_as_errors, - fsharp_warnings_as_errors = ctx.attr._fsharp_warnings_as_errors, - fsharp_warnings_not_as_errors = ctx.attr._fsharp_warnings_not_as_errors, - fsharp_warning_level = ctx.attr._fsharp_warning_level, ) # Export all the providers inside our ToolchainInfo @@ -214,42 +198,10 @@ dotnet_toolchain = rule( doc = "The default C# version used by the current dotnet SDK", mandatory = True, ), - "_csharp_treat_warnings_as_errors": attr.label( - doc = "Treat all C# compiler warnings as errors. Note that this attribute can not be used in conjunction with csharp_warnings_as_errors.", - default = "//dotnet/settings:csharp_treat_warnings_as_errors", - ), - "_csharp_warnings_as_errors": attr.label( - doc = "List of C# compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with csharp_treat_warnings_as_errors.", - default = "//dotnet/settings:csharp_warnings_as_errors", - ), - "_csharp_warnings_not_as_errors": attr.label( - doc = "List of C# compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with csharp_treat_warnings_as_errors.", - default = "//dotnet/settings:csharp_warnings_not_as_errors", - ), - "_csharp_warning_level": attr.label( - doc = "List of C# compiler warning codes that should not be displayed.", - default = "//dotnet/settings:csharp_warning_level", - ), "fsharp_default_version": attr.string( doc = "The default F# version used by the current dotnet SDK", mandatory = True, ), - "_fsharp_treat_warnings_as_errors": attr.label( - doc = "Treat all F# compiler warnings as errors. Note that this attribute can not be used in conjunction with fsharp_warnings_as_errors.", - default = "//dotnet/settings:fsharp_treat_warnings_as_errors", - ), - "_fsharp_warnings_as_errors": attr.label( - doc = "List of F# compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with fsharp_treat_warnings_as_errors.", - default = "//dotnet/settings:fsharp_warnings_as_errors", - ), - "_fsharp_warnings_not_as_errors": attr.label( - doc = "List of F# compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with fsharp_treat_warnings_as_errors.", - default = "//dotnet/settings:fsharp_warnings_not_as_errors", - ), - "_fsharp_warning_level": attr.label( - doc = "List of F# compiler warning codes that should not be displayed.", - default = "//dotnet/settings:fsharp_warning_level", - ), "_strict_deps": attr.label( doc = "Whether to use strict deps or not", default = "//dotnet/settings:strict_deps", From 0a752d0f50fea3bafc25c4e086b4e58ec5000b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=C3=ADel=20P=2E=20Purkh=C3=BAs?= Date: Wed, 3 Apr 2024 13:57:13 +0000 Subject: [PATCH 2/4] * Add `nowarn` attribute for supressing compiler warnings --- docs/csharp_binary.md | 3 +- docs/csharp_library.md | 5 ++-- docs/csharp_test.md | 7 +++-- docs/defs.md | 30 +++++++++++-------- docs/fsharp_binary.md | 5 ++-- docs/fsharp_library.md | 5 ++-- docs/fsharp_test.md | 5 ++-- dotnet/private/common.bzl | 7 ++++- dotnet/private/rules/common/attrs.bzl | 10 +++++++ .../rules/csharp/actions/csharp_assembly.bzl | 7 +++++ dotnet/private/rules/csharp/binary.bzl | 1 + dotnet/private/rules/csharp/library.bzl | 1 + dotnet/private/rules/csharp/test.bzl | 1 + .../rules/fsharp/actions/fsharp_assembly.bzl | 7 +++++ dotnet/private/rules/fsharp/binary.bzl | 1 + dotnet/private/rules/fsharp/library.bzl | 1 + dotnet/private/rules/fsharp/test.bzl | 1 + .../warning_settings/csharp_warnings.bzl | 15 ++++++++++ .../warning_settings/fsharp_warnings.bzl | 15 ++++++++++ 19 files changed, 102 insertions(+), 25 deletions(-) diff --git a/docs/csharp_binary.md b/docs/csharp_binary.md index 55ed399c..35501938 100644 --- a/docs/csharp_binary.md +++ b/docs/csharp_binary.md @@ -11,7 +11,7 @@ Rule for compiling C# binaries.
 csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
               generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nullable, out, override_strict_deps, project_sdk, resources,
+              langversion, nowarn, nullable, out, override_strict_deps, project_sdk, resources,
               roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
               winexe)
@@ -36,6 +36,7 @@ Compile a C# exe
 | internals_visible_to |  Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching.   | List of strings | optional | [] |
 | keyfile |  The key file used to sign the assembly with a strong name.   | Label | optional | None |
 | langversion |  The version string for the language.   | String | optional | "" |
+| nowarn |  List of warnings that should be ignored   | List of strings | optional | ["CS1701", "CS1702"] |
 | nullable |  Enable nullable context, or nullable warnings.   | String | optional | "disable" |
 | out |  File name, without extension, of the built assembly.   | String | optional | "" |
 | override_strict_deps |  Whether or not to override the strict_deps attribute.   | Boolean | optional | False |
diff --git a/docs/csharp_library.md b/docs/csharp_library.md
index fd87672c..73117506 100644
--- a/docs/csharp_library.md
+++ b/docs/csharp_library.md
@@ -11,8 +11,8 @@ Rule for compiling C# libraries.
 
 csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
                exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nullable, out, override_strict_deps, project_sdk, resources, run_analyzers, srcs,
-               strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+               nowarn, nullable, out, override_strict_deps, project_sdk, resources, run_analyzers,
+               srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
                warnings_as_errors, warnings_not_as_errors)
 
@@ -35,6 +35,7 @@ Compile a C# DLL | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | diff --git a/docs/csharp_test.md b/docs/csharp_test.md index c966a0de..38ca150c 100644 --- a/docs/csharp_test.md +++ b/docs/csharp_test.md @@ -13,9 +13,9 @@ a Bazel test.
 csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-            generate_documentation_file, internals_visible_to, keyfile, langversion, nullable, out,
-            override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
-            strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+            generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
+            out, override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers,
+            srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
             warnings_as_errors, warnings_not_as_errors, winexe)
 
@@ -37,6 +37,7 @@ Compiles a C# executable and runs it as a test | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | diff --git a/docs/defs.md b/docs/defs.md index 0d691ed7..c535278c 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -12,7 +12,7 @@ Users should not load files under "/dotnet"
 csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
               generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nullable, out, override_strict_deps, project_sdk, resources,
+              langversion, nowarn, nullable, out, override_strict_deps, project_sdk, resources,
               roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
               winexe)
@@ -37,6 +37,7 @@ Compile a C# exe
 | internals_visible_to |  Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching.   | List of strings | optional | [] |
 | keyfile |  The key file used to sign the assembly with a strong name.   | Label | optional | None |
 | langversion |  The version string for the language.   | String | optional | "" |
+| nowarn |  List of warnings that should be ignored   | List of strings | optional | ["CS1701", "CS1702"] |
 | nullable |  Enable nullable context, or nullable warnings.   | String | optional | "disable" |
 | out |  File name, without extension, of the built assembly.   | String | optional | "" |
 | override_strict_deps |  Whether or not to override the strict_deps attribute.   | Boolean | optional | False |
@@ -61,8 +62,8 @@ Compile a C# exe
 
 csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
                exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nullable, out, override_strict_deps, project_sdk, resources, run_analyzers, srcs,
-               strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+               nowarn, nullable, out, override_strict_deps, project_sdk, resources, run_analyzers,
+               srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
                warnings_as_errors, warnings_not_as_errors)
 
@@ -85,6 +86,7 @@ Compile a C# DLL | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | @@ -106,9 +108,9 @@ Compile a C# DLL
 csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-            generate_documentation_file, internals_visible_to, keyfile, langversion, nullable, out,
-            override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
-            strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
+            generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
+            out, override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers,
+            srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
             warnings_as_errors, warnings_not_as_errors, winexe)
 
@@ -130,6 +132,7 @@ Compiles a C# executable and runs it as a test | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | @@ -153,8 +156,8 @@ Compiles a C# executable and runs it as a test
 fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-              resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+              internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+              project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
               winexe)
 
@@ -175,6 +178,7 @@ Compile a F# exe | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | @@ -196,8 +200,8 @@ Compile a F# exe
 fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-               resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
+               internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+               project_sdk, resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
                warning_level, warnings_as_errors, warnings_not_as_errors)
 
@@ -218,6 +222,7 @@ Compile a F# DLL | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | @@ -237,8 +242,8 @@ Compile a F# DLL
 fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
-            internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-            resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+            internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+            project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
             treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
             winexe)
 
@@ -259,6 +264,7 @@ Compile a F# executable and runs it as a test | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | diff --git a/docs/fsharp_binary.md b/docs/fsharp_binary.md index dbe52ded..1c97347d 100644 --- a/docs/fsharp_binary.md +++ b/docs/fsharp_binary.md @@ -10,8 +10,8 @@ Rule for compiling F# binaries.
 fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-              resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+              internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+              project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
               winexe)
 
@@ -32,6 +32,7 @@ Compile a F# exe | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | diff --git a/docs/fsharp_library.md b/docs/fsharp_library.md index 13d7c522..74f4e327 100644 --- a/docs/fsharp_library.md +++ b/docs/fsharp_library.md @@ -10,8 +10,8 @@ Rule for compiling F# libraries.
 fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-               resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
+               internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+               project_sdk, resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
                warning_level, warnings_as_errors, warnings_not_as_errors)
 
@@ -32,6 +32,7 @@ Compile a F# DLL | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | diff --git a/docs/fsharp_test.md b/docs/fsharp_test.md index f744b843..a0628160 100644 --- a/docs/fsharp_test.md +++ b/docs/fsharp_test.md @@ -13,8 +13,8 @@ a Bazel test.
 fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
-            internals_visible_to, keyfile, langversion, out, override_strict_deps, project_sdk,
-            resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
+            internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
+            project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
             treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
             winexe)
 
@@ -35,6 +35,7 @@ Compile a F# executable and runs it as a test | internals_visible_to | Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. | List of strings | optional | [] | | keyfile | The key file used to sign the assembly with a strong name. | Label | optional | None | | langversion | The version string for the language. | String | optional | "" | +| nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | | override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | diff --git a/dotnet/private/common.bzl b/dotnet/private/common.bzl index 836e6133..1f9a5a59 100644 --- a/dotnet/private/common.bzl +++ b/dotnet/private/common.bzl @@ -418,7 +418,8 @@ def generate_warning_args( treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors, - warning_level): + warning_level, + nowarn): """Generates the compiler arguments for warnings and errors Args: @@ -427,6 +428,7 @@ def generate_warning_args( warnings_as_errors: List of warnings that should be treated as errors warnings_not_as_errors: List of warnings that should not be treated as errors warning_level: The warning level to use + nowarn: List of warnings to suppress """ if treat_warnings_as_errors: if len(warnings_as_errors) > 0: @@ -444,6 +446,9 @@ def generate_warning_args( args.add("/warn:{}".format(warning_level)) + if len(nowarn) > 0: + args.add("/nowarn:{}".format(",".join(nowarn))) + def framework_preprocessor_symbols(tfm): """Gets the standard preprocessor symbols for the target framework. diff --git a/dotnet/private/rules/common/attrs.bzl b/dotnet/private/rules/common/attrs.bzl index 08dc0c7f..ed0b33d1 100644 --- a/dotnet/private/rules/common/attrs.bzl +++ b/dotnet/private/rules/common/attrs.bzl @@ -217,6 +217,11 @@ CSHARP_COMMON_ATTRS = dicts.add( mandatory = False, default = True, ), + "nowarn": attr.string_list( + doc = "List of warnings that should be ignored", + mandatory = False, + default = ["CS1701", "CS1702"], + ), }, ) @@ -243,6 +248,11 @@ FSHARP_COMMON_ATTRS = dicts.add( # that is generated by a dotnet binary cfg = default_transition, ), + "nowarn": attr.string_list( + doc = "List of warnings that should be ignored", + mandatory = False, + default = [], + ), }, ) diff --git a/dotnet/private/rules/csharp/actions/csharp_assembly.bzl b/dotnet/private/rules/csharp/actions/csharp_assembly.bzl index 2b28d212..3a2b5cf6 100644 --- a/dotnet/private/rules/csharp/actions/csharp_assembly.bzl +++ b/dotnet/private/rules/csharp/actions/csharp_assembly.bzl @@ -79,6 +79,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, project_sdk, allow_unsafe_blocks, nullable, @@ -115,6 +116,7 @@ def AssemblyAction( warnings_as_errors: List of warnings to treat as errors. warnings_not_as_errors: List of warnings to not treat errors. warning_level: The warning level to use. + nowarn: List of warnings to suppress. project_sdk: The project sdk being targeted allow_unsafe_blocks: Compiles the target with /unsafe nullable: Enable nullable context, or nullable warnings. @@ -176,6 +178,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, allow_unsafe_blocks, nullable, run_analyzers, @@ -221,6 +224,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, allow_unsafe_blocks, nullable, run_analyzers, @@ -255,6 +259,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, allow_unsafe_blocks, nullable, run_analyzers, @@ -314,6 +319,7 @@ def _compile( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, allow_unsafe_blocks, nullable, run_analyzers, @@ -360,6 +366,7 @@ def _compile( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, ) args.add("/target:" + target) diff --git a/dotnet/private/rules/csharp/binary.bzl b/dotnet/private/rules/csharp/binary.bzl index 16b265e6..45d176a9 100644 --- a/dotnet/private/rules/csharp/binary.bzl +++ b/dotnet/private/rules/csharp/binary.bzl @@ -43,6 +43,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/csharp/library.bzl b/dotnet/private/rules/csharp/library.bzl index df13704f..7fe109e8 100644 --- a/dotnet/private/rules/csharp/library.bzl +++ b/dotnet/private/rules/csharp/library.bzl @@ -42,6 +42,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/csharp/test.bzl b/dotnet/private/rules/csharp/test.bzl index 51b6fa03..c449282c 100644 --- a/dotnet/private/rules/csharp/test.bzl +++ b/dotnet/private/rules/csharp/test.bzl @@ -45,6 +45,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks, nullable = ctx.attr.nullable, diff --git a/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl b/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl index 2211a6e4..a8adaf5f 100644 --- a/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl +++ b/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl @@ -96,6 +96,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, project_sdk): """Creates an action that runs the F# compiler with the specified inputs. @@ -127,6 +128,7 @@ def AssemblyAction( warnings_as_errors: List of warnings to treat as errors. warnings_not_as_errors: List of warnings to not treat errors. warning_level: The warning level to use. + nowarn: List of warnings to suppress. project_sdk: The project SDK being targeted Returns: @@ -181,6 +183,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, out_dll = out_dll, out_ref = out_ref, out_pdb = out_pdb, @@ -219,6 +222,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, out_ref = out_iref, out_dll = out_dll, out_pdb = out_pdb, @@ -248,6 +252,7 @@ def AssemblyAction( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, out_dll = None, out_ref = out_ref, out_pdb = None, @@ -301,6 +306,7 @@ def _compile( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, out_dll = None, out_ref = None, out_pdb = None, @@ -331,6 +337,7 @@ def _compile( warnings_as_errors, warnings_not_as_errors, warning_level, + nowarn, ) args.add("--target:" + target) diff --git a/dotnet/private/rules/fsharp/binary.bzl b/dotnet/private/rules/fsharp/binary.bzl index 58397d42..b82892dd 100644 --- a/dotnet/private/rules/fsharp/binary.bzl +++ b/dotnet/private/rules/fsharp/binary.bzl @@ -40,6 +40,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/rules/fsharp/library.bzl b/dotnet/private/rules/fsharp/library.bzl index 7d969648..a07c0eff 100644 --- a/dotnet/private/rules/fsharp/library.bzl +++ b/dotnet/private/rules/fsharp/library.bzl @@ -41,6 +41,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/rules/fsharp/test.bzl b/dotnet/private/rules/fsharp/test.bzl index f6ef3200..4b58a053 100644 --- a/dotnet/private/rules/fsharp/test.bzl +++ b/dotnet/private/rules/fsharp/test.bzl @@ -43,6 +43,7 @@ def _compile_action(ctx, tfm): warnings_as_errors = ctx.attr.warnings_as_errors, warnings_not_as_errors = ctx.attr.warnings_not_as_errors, warning_level = ctx.attr.warning_level, + nowarn = ctx.attr.nowarn, project_sdk = ctx.attr.project_sdk, ) diff --git a/dotnet/private/tests/warning_settings/csharp_warnings.bzl b/dotnet/private/tests/warning_settings/csharp_warnings.bzl index 2844d385..81a99253 100644 --- a/dotnet/private/tests/warning_settings/csharp_warnings.bzl +++ b/dotnet/private/tests/warning_settings/csharp_warnings.bzl @@ -66,3 +66,18 @@ def csharp_warnings(): action_mnemonic = "CSharpCompile", expected_partial_args = ["/warn:5"], ) + + csharp_library( + name = "csharp_nowarn", + srcs = ["warnings.cs"], + target_frameworks = ["net6.0"], + nowarn = ["CS1234", "CS0000"], + tags = ["manual"], + ) + + action_args_test( + name = "csharp_nowarn_test", + target_under_test = ":csharp_nowarn", + action_mnemonic = "CSharpCompile", + expected_partial_args = ["/nowarn:CS1234,CS0000"], + ) diff --git a/dotnet/private/tests/warning_settings/fsharp_warnings.bzl b/dotnet/private/tests/warning_settings/fsharp_warnings.bzl index 1e1a06bb..d37e3c5d 100644 --- a/dotnet/private/tests/warning_settings/fsharp_warnings.bzl +++ b/dotnet/private/tests/warning_settings/fsharp_warnings.bzl @@ -66,3 +66,18 @@ def fsharp_warnings(): action_mnemonic = "FSharpCompile", expected_partial_args = ["/warn:5"], ) + + fsharp_library( + name = "fsharp_nowarn", + srcs = ["warnings.fs"], + target_frameworks = ["net6.0"], + nowarn = ["FS0000", "FS1234"], + tags = ["manual"], + ) + + action_args_test( + name = "fsharp_nowarn_test", + target_under_test = ":fsharp_nowarn", + action_mnemonic = "FSharpCompile", + expected_partial_args = ["/nowarn:FS0000,FS1234"], + ) From db1bb4145e46ebbf15a2a4d90bfb8e4ddbfd04cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=C3=ADel=20P=2E=20Purkh=C3=BAs?= Date: Wed, 3 Apr 2024 14:12:06 +0000 Subject: [PATCH 3/4] * Remove strict_deps attributes --- docs/README.md | 7 +++- docs/csharp_binary.md | 9 ++--- docs/csharp_library.md | 7 +--- docs/csharp_test.md | 8 ++-- docs/defs.md | 50 +++++++++---------------- docs/fsharp_binary.md | 9 ++--- docs/fsharp_library.md | 8 ++-- docs/fsharp_test.md | 9 ++--- dotnet/private/rules/common/attrs.bzl | 11 ------ dotnet/private/rules/csharp/binary.bzl | 2 +- dotnet/private/rules/csharp/library.bzl | 2 +- dotnet/private/rules/csharp/test.bzl | 2 +- dotnet/private/rules/fsharp/binary.bzl | 2 +- dotnet/private/rules/fsharp/library.bzl | 2 +- dotnet/private/rules/fsharp/test.bzl | 2 +- 15 files changed, 45 insertions(+), 85 deletions(-) diff --git a/docs/README.md b/docs/README.md index ab44ba86..b140a29c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,8 +12,11 @@ these rules do not propagate transitive dependencies to compilation actions. This is similar to setting `true` in MSBuild. -Transitive dependency propagation can be configured on per-target basis -and when the toolchain is configured. +This behaviour can be overridden by using the following flag when invoking bazel: +``` +--@rules_dotnet//dotnet/settings:strict_deps=false +``` +You can add this flag to your `.bazelrc` file to make it the default. ## Unsupported workloads diff --git a/docs/csharp_binary.md b/docs/csharp_binary.md index 35501938..796e9ca9 100644 --- a/docs/csharp_binary.md +++ b/docs/csharp_binary.md @@ -11,10 +11,9 @@ Rule for compiling C# binaries.
 csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
               generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nowarn, nullable, out, override_strict_deps, project_sdk, resources,
-              roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
-              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-              winexe)
+              langversion, nowarn, nullable, out, project_sdk, resources, roll_forward_behavior,
+              run_analyzers, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+              warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a C# exe @@ -39,13 +38,11 @@ Compile a C# exe | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/csharp_library.md b/docs/csharp_library.md index 73117506..710fe7c1 100644 --- a/docs/csharp_library.md +++ b/docs/csharp_library.md @@ -11,9 +11,8 @@ Rule for compiling C# libraries.
 csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
                exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nowarn, nullable, out, override_strict_deps, project_sdk, resources, run_analyzers,
-               srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-               warnings_as_errors, warnings_not_as_errors)
+               nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs, target_frameworks,
+               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors)
 
Compile a C# DLL @@ -38,12 +37,10 @@ Compile a C# DLL | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/csharp_test.md b/docs/csharp_test.md index 38ca150c..8c89998a 100644 --- a/docs/csharp_test.md +++ b/docs/csharp_test.md @@ -14,9 +14,9 @@ a Bazel test.
 csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
             generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
-            out, override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers,
-            srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-            warnings_as_errors, warnings_not_as_errors, winexe)
+            out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+            target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+            warnings_not_as_errors, winexe)
 
Compiles a C# executable and runs it as a test @@ -40,13 +40,11 @@ Compiles a C# executable and runs it as a test | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/defs.md b/docs/defs.md index c535278c..68e1447c 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -12,10 +12,9 @@ Users should not load files under "/dotnet"
 csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
               generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nowarn, nullable, out, override_strict_deps, project_sdk, resources,
-              roll_forward_behavior, run_analyzers, srcs, strict_deps, target_frameworks,
-              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-              winexe)
+              langversion, nowarn, nullable, out, project_sdk, resources, roll_forward_behavior,
+              run_analyzers, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+              warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a C# exe @@ -40,13 +39,11 @@ Compile a C# exe | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | @@ -62,9 +59,8 @@ Compile a C# exe
 csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
                exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nowarn, nullable, out, override_strict_deps, project_sdk, resources, run_analyzers,
-               srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-               warnings_as_errors, warnings_not_as_errors)
+               nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs, target_frameworks,
+               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors)
 
Compile a C# DLL @@ -89,12 +85,10 @@ Compile a C# DLL | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | @@ -109,9 +103,9 @@ Compile a C# DLL
 csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
             generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
-            out, override_strict_deps, project_sdk, resources, roll_forward_behavior, run_analyzers,
-            srcs, strict_deps, target_frameworks, treat_warnings_as_errors, warning_level,
-            warnings_as_errors, warnings_not_as_errors, winexe)
+            out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+            target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+            warnings_not_as_errors, winexe)
 
Compiles a C# executable and runs it as a test @@ -135,13 +129,11 @@ Compiles a C# executable and runs it as a test | nowarn | List of warnings that should be ignored | List of strings | optional | ["CS1701", "CS1702"] | | nullable | Enable nullable context, or nullable warnings. | String | optional | "disable" | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | run_analyzers | Controls whether analyzers run at build time. | Boolean | optional | True | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | @@ -156,10 +148,9 @@ Compiles a C# executable and runs it as a test
 fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-              project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
-              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-              winexe)
+              internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
+              roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+              warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a F# exe @@ -180,12 +171,10 @@ Compile a F# exe | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | @@ -200,9 +189,9 @@ Compile a F# exe
 fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-               project_sdk, resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
-               warning_level, warnings_as_errors, warnings_not_as_errors)
+               internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources, srcs,
+               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+               warnings_not_as_errors)
 
Compile a F# DLL @@ -224,11 +213,9 @@ Compile a F# DLL | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | @@ -242,10 +229,9 @@ Compile a F# DLL
 fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
-            internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-            project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
-            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-            winexe)
+            internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
+            roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+            warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a F# executable and runs it as a test @@ -266,12 +252,10 @@ Compile a F# executable and runs it as a test | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/fsharp_binary.md b/docs/fsharp_binary.md index 1c97347d..910a4b26 100644 --- a/docs/fsharp_binary.md +++ b/docs/fsharp_binary.md @@ -10,10 +10,9 @@ Rule for compiling F# binaries.
 fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-              project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
-              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-              winexe)
+              internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
+              roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+              warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a F# exe @@ -34,12 +33,10 @@ Compile a F# exe | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/fsharp_library.md b/docs/fsharp_library.md index 74f4e327..bebcf0d3 100644 --- a/docs/fsharp_library.md +++ b/docs/fsharp_library.md @@ -10,9 +10,9 @@ Rule for compiling F# libraries.
 fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-               project_sdk, resources, srcs, strict_deps, target_frameworks, treat_warnings_as_errors,
-               warning_level, warnings_as_errors, warnings_not_as_errors)
+               internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources, srcs,
+               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+               warnings_not_as_errors)
 
Compile a F# DLL @@ -34,11 +34,9 @@ Compile a F# DLL | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/docs/fsharp_test.md b/docs/fsharp_test.md index a0628160..2001e5ea 100644 --- a/docs/fsharp_test.md +++ b/docs/fsharp_test.md @@ -13,10 +13,9 @@ a Bazel test.
 fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
-            internals_visible_to, keyfile, langversion, nowarn, out, override_strict_deps,
-            project_sdk, resources, roll_forward_behavior, srcs, strict_deps, target_frameworks,
-            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
-            winexe)
+            internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
+            roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
+            warnings_as_errors, warnings_not_as_errors, winexe)
 
Compile a F# executable and runs it as a test @@ -37,12 +36,10 @@ Compile a F# executable and runs it as a test | langversion | The version string for the language. | String | optional | "" | | nowarn | List of warnings that should be ignored | List of strings | optional | [] | | out | File name, without extension, of the built assembly. | String | optional | "" | -| override_strict_deps | Whether or not to override the strict_deps attribute. | Boolean | optional | False | | project_sdk | The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview | String | optional | "default" | | resources | A list of files to embed in the DLL as resources. | List of labels | optional | [] | | roll_forward_behavior | The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior | String | optional | "Major" | | srcs | The source files used in the compilation. | List of labels | optional | [] | -| strict_deps | Whether to use strict dependencies or not.

This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. The default setting of this attribute can be overridden in the toolchain configuration | Boolean | optional | True | | target_frameworks | A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks | List of strings | required | | | treat_warnings_as_errors | Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. | Boolean | optional | False | | warning_level | The warning level that should be used by the compiler. | Integer | optional | 3 | diff --git a/dotnet/private/rules/common/attrs.bzl b/dotnet/private/rules/common/attrs.bzl index ed0b33d1..f073e62c 100644 --- a/dotnet/private/rules/common/attrs.bzl +++ b/dotnet/private/rules/common/attrs.bzl @@ -94,17 +94,6 @@ COMMON_ATTRS = { values = [0, 1, 2, 3, 4, 5], default = 3, ), - "strict_deps": attr.bool( - doc = """Whether to use strict dependencies or not. - - This attribute mirrors the DisableTransitiveProjectReferences in MSBuild. - The default setting of this attribute can be overridden in the toolchain configuration""", - default = True, - ), - "override_strict_deps": attr.bool( - doc = "Whether or not to override the strict_deps attribute.", - mandatory = False, - ), "generate_documentation_file": attr.bool( doc = "Whether or not to generate a documentation file.", default = True, diff --git a/dotnet/private/rules/csharp/binary.bzl b/dotnet/private/rules/csharp/binary.bzl index 45d176a9..e255ea0a 100644 --- a/dotnet/private/rules/csharp/binary.bzl +++ b/dotnet/private/rules/csharp/binary.bzl @@ -36,7 +36,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = ctx.attr.include_host_model_dll, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, diff --git a/dotnet/private/rules/csharp/library.bzl b/dotnet/private/rules/csharp/library.bzl index 7fe109e8..208febe4 100644 --- a/dotnet/private/rules/csharp/library.bzl +++ b/dotnet/private/rules/csharp/library.bzl @@ -35,7 +35,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = False, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, diff --git a/dotnet/private/rules/csharp/test.bzl b/dotnet/private/rules/csharp/test.bzl index c449282c..1592defb 100644 --- a/dotnet/private/rules/csharp/test.bzl +++ b/dotnet/private/rules/csharp/test.bzl @@ -38,7 +38,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, include_host_model_dll = False, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, diff --git a/dotnet/private/rules/fsharp/binary.bzl b/dotnet/private/rules/fsharp/binary.bzl index b82892dd..f4c18057 100644 --- a/dotnet/private/rules/fsharp/binary.bzl +++ b/dotnet/private/rules/fsharp/binary.bzl @@ -34,7 +34,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, warnings_as_errors = ctx.attr.warnings_as_errors, diff --git a/dotnet/private/rules/fsharp/library.bzl b/dotnet/private/rules/fsharp/library.bzl index a07c0eff..c49816bf 100644 --- a/dotnet/private/rules/fsharp/library.bzl +++ b/dotnet/private/rules/fsharp/library.bzl @@ -35,7 +35,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, warnings_as_errors = ctx.attr.warnings_as_errors, diff --git a/dotnet/private/rules/fsharp/test.bzl b/dotnet/private/rules/fsharp/test.bzl index 4b58a053..7cc8ea22 100644 --- a/dotnet/private/rules/fsharp/test.bzl +++ b/dotnet/private/rules/fsharp/test.bzl @@ -37,7 +37,7 @@ def _compile_action(ctx, tfm): target_name = ctx.attr.name, target_framework = tfm, toolchain = toolchain, - strict_deps = ctx.attr.strict_deps if ctx.attr.override_strict_deps else toolchain.strict_deps[BuildSettingInfo].value, + strict_deps = toolchain.strict_deps[BuildSettingInfo].value, generate_documentation_file = ctx.attr.generate_documentation_file, treat_warnings_as_errors = ctx.attr.treat_warnings_as_errors, warnings_as_errors = ctx.attr.warnings_as_errors, From 1bbbd7b297f79243f64b7deba6c7373a48afbe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=C3=ADel=20P=2E=20Purkh=C3=BAs?= Date: Wed, 3 Apr 2024 14:49:12 +0000 Subject: [PATCH 4/4] * Add `compiler_options` attribute for additional compiler options --- docs/csharp_binary.md | 12 +++-- docs/csharp_library.md | 10 ++-- docs/csharp_test.md | 7 +-- docs/defs.md | 51 +++++++++++-------- docs/fsharp_binary.md | 10 ++-- docs/fsharp_library.md | 9 ++-- docs/fsharp_test.md | 3 +- dotnet/private/rules/common/attrs.bzl | 5 ++ .../rules/csharp/actions/csharp_assembly.bzl | 12 ++++- dotnet/private/rules/csharp/binary.bzl | 1 + dotnet/private/rules/csharp/library.bzl | 1 + dotnet/private/rules/csharp/test.bzl | 1 + .../rules/fsharp/actions/fsharp_assembly.bzl | 12 ++++- dotnet/private/rules/fsharp/binary.bzl | 1 + dotnet/private/rules/fsharp/library.bzl | 1 + dotnet/private/rules/fsharp/test.bzl | 1 + .../additional_compiler_options/BUILD.bazel | 29 +++++++++++ .../additional_compiler_options.cs | 12 +++++ .../additional_compiler_options.fs | 9 ++++ .../csharp_additional_compiler_options.bzl | 22 ++++++++ .../fsharp_additional_compiler_options.bzl | 22 ++++++++ 21 files changed, 187 insertions(+), 44 deletions(-) create mode 100644 dotnet/private/tests/additional_compiler_options/BUILD.bazel create mode 100644 dotnet/private/tests/additional_compiler_options/additional_compiler_options.cs create mode 100644 dotnet/private/tests/additional_compiler_options/additional_compiler_options.fs create mode 100644 dotnet/private/tests/additional_compiler_options/csharp_additional_compiler_options.bzl create mode 100644 dotnet/private/tests/additional_compiler_options/fsharp_additional_compiler_options.bzl diff --git a/docs/csharp_binary.md b/docs/csharp_binary.md index 796e9ca9..7b54c59b 100644 --- a/docs/csharp_binary.md +++ b/docs/csharp_binary.md @@ -9,11 +9,12 @@ Rule for compiling C# binaries. ## csharp_binary
-csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-              generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nowarn, nullable, out, project_sdk, resources, roll_forward_behavior,
-              run_analyzers, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
-              warnings_as_errors, warnings_not_as_errors, winexe)
+csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+              defines, deps, generate_documentation_file, include_host_model_dll,
+              internals_visible_to, keyfile, langversion, nowarn, nullable, out, project_sdk,
+              resources, roll_forward_behavior, run_analyzers, srcs, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a C# exe @@ -27,6 +28,7 @@ Compile a C# exe | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | diff --git a/docs/csharp_library.md b/docs/csharp_library.md index 710fe7c1..782f885a 100644 --- a/docs/csharp_library.md +++ b/docs/csharp_library.md @@ -9,10 +9,11 @@ Rule for compiling C# libraries. ## csharp_library
-csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-               exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs, target_frameworks,
-               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors)
+csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+               defines, deps, exports, generate_documentation_file, internals_visible_to, keyfile,
+               langversion, nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs,
+               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+               warnings_not_as_errors)
 
Compile a C# DLL @@ -26,6 +27,7 @@ Compile a C# DLL | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | diff --git a/docs/csharp_test.md b/docs/csharp_test.md index 8c89998a..5a0c1e22 100644 --- a/docs/csharp_test.md +++ b/docs/csharp_test.md @@ -12,9 +12,9 @@ a Bazel test. ## csharp_test
-csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-            generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
-            out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+            defines, deps, generate_documentation_file, internals_visible_to, keyfile, langversion,
+            nowarn, nullable, out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
             target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
             warnings_not_as_errors, winexe)
 
@@ -30,6 +30,7 @@ Compiles a C# executable and runs it as a test | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | diff --git a/docs/defs.md b/docs/defs.md index 68e1447c..8be2592c 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -10,11 +10,12 @@ Users should not load files under "/dotnet" ## csharp_binary
-csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-              generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
-              langversion, nowarn, nullable, out, project_sdk, resources, roll_forward_behavior,
-              run_analyzers, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
-              warnings_as_errors, warnings_not_as_errors, winexe)
+csharp_binary(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+              defines, deps, generate_documentation_file, include_host_model_dll,
+              internals_visible_to, keyfile, langversion, nowarn, nullable, out, project_sdk,
+              resources, roll_forward_behavior, run_analyzers, srcs, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a C# exe @@ -28,6 +29,7 @@ Compile a C# exe | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | @@ -57,10 +59,11 @@ Compile a C# exe ## csharp_library
-csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-               exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
-               nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs, target_frameworks,
-               treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors)
+csharp_library(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+               defines, deps, exports, generate_documentation_file, internals_visible_to, keyfile,
+               langversion, nowarn, nullable, out, project_sdk, resources, run_analyzers, srcs,
+               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
+               warnings_not_as_errors)
 
Compile a C# DLL @@ -74,6 +77,7 @@ Compile a C# DLL | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | @@ -101,9 +105,9 @@ Compile a C# DLL ## csharp_test
-csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, data, defines, deps,
-            generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
-            out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
+csharp_test(name, additionalfiles, allow_unsafe_blocks, compile_data, compiler_options, data,
+            defines, deps, generate_documentation_file, internals_visible_to, keyfile, langversion,
+            nowarn, nullable, out, project_sdk, resources, roll_forward_behavior, run_analyzers, srcs,
             target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
             warnings_not_as_errors, winexe)
 
@@ -119,6 +123,7 @@ Compiles a C# executable and runs it as a test | additionalfiles | Extra files to configure analyzers. | List of labels | optional | [] | | allow_unsafe_blocks | Allow compiling unsafe code. It true, /unsafe is passed to the compiler. | Boolean | optional | False | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | @@ -147,10 +152,11 @@ Compiles a C# executable and runs it as a test ## fsharp_binary
-fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
-              roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
-              warnings_as_errors, warnings_not_as_errors, winexe)
+fsharp_binary(name, compile_data, compiler_options, data, defines, deps,
+              generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, out,
+              project_sdk, resources, roll_forward_behavior, srcs, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a F# exe @@ -162,6 +168,7 @@ Compile a F# exe | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | @@ -188,10 +195,10 @@ Compile a F# exe ## fsharp_library
-fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources, srcs,
-               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
-               warnings_not_as_errors)
+fsharp_library(name, compile_data, compiler_options, data, defines, deps, exports,
+               generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, out,
+               project_sdk, resources, srcs, target_frameworks, treat_warnings_as_errors,
+               warning_level, warnings_as_errors, warnings_not_as_errors)
 
Compile a F# DLL @@ -203,6 +210,7 @@ Compile a F# DLL | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | @@ -228,7 +236,7 @@ Compile a F# DLL ## fsharp_test
-fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
+fsharp_test(name, compile_data, compiler_options, data, defines, deps, generate_documentation_file,
             internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
             roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
             warnings_as_errors, warnings_not_as_errors, winexe)
@@ -243,6 +251,7 @@ Compile a F# executable and runs it as a test
 | :------------- | :------------- | :------------- | :------------- | :------------- |
 | name |  A unique name for this target.   | Name | required |  |
 | compile_data |  Additional compile time files.   | List of labels | optional | [] |
+| compiler_options |  Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute.   | List of strings | optional | [] |
 | data |  Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files.   | List of labels | optional | [] |
 | defines |  A list of preprocessor directive symbols to define.   | List of strings | optional | [] |
 | deps |  Other libraries, binaries, or imported DLLs   | List of labels | optional | [] |
diff --git a/docs/fsharp_binary.md b/docs/fsharp_binary.md
index 910a4b26..03f00df5 100644
--- a/docs/fsharp_binary.md
+++ b/docs/fsharp_binary.md
@@ -9,10 +9,11 @@ Rule for compiling F# binaries.
 ## fsharp_binary
 
 
-fsharp_binary(name, compile_data, data, defines, deps, generate_documentation_file,
-              internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
-              roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
-              warnings_as_errors, warnings_not_as_errors, winexe)
+fsharp_binary(name, compile_data, compiler_options, data, defines, deps,
+              generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, out,
+              project_sdk, resources, roll_forward_behavior, srcs, target_frameworks,
+              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
+              winexe)
 
Compile a F# exe @@ -24,6 +25,7 @@ Compile a F# exe | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | diff --git a/docs/fsharp_library.md b/docs/fsharp_library.md index bebcf0d3..f6a804c3 100644 --- a/docs/fsharp_library.md +++ b/docs/fsharp_library.md @@ -9,10 +9,10 @@ Rule for compiling F# libraries. ## fsharp_library
-fsharp_library(name, compile_data, data, defines, deps, exports, generate_documentation_file,
-               internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources, srcs,
-               target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
-               warnings_not_as_errors)
+fsharp_library(name, compile_data, compiler_options, data, defines, deps, exports,
+               generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, out,
+               project_sdk, resources, srcs, target_frameworks, treat_warnings_as_errors,
+               warning_level, warnings_as_errors, warnings_not_as_errors)
 
Compile a F# DLL @@ -24,6 +24,7 @@ Compile a F# DLL | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | compile_data | Additional compile time files. | List of labels | optional | [] | +| compiler_options | Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. | List of strings | optional | [] | | data | Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. | List of labels | optional | [] | | defines | A list of preprocessor directive symbols to define. | List of strings | optional | [] | | deps | Other libraries, binaries, or imported DLLs | List of labels | optional | [] | diff --git a/docs/fsharp_test.md b/docs/fsharp_test.md index 2001e5ea..8b0f1fb8 100644 --- a/docs/fsharp_test.md +++ b/docs/fsharp_test.md @@ -12,7 +12,7 @@ a Bazel test. ## fsharp_test
-fsharp_test(name, compile_data, data, defines, deps, generate_documentation_file,
+fsharp_test(name, compile_data, compiler_options, data, defines, deps, generate_documentation_file,
             internals_visible_to, keyfile, langversion, nowarn, out, project_sdk, resources,
             roll_forward_behavior, srcs, target_frameworks, treat_warnings_as_errors, warning_level,
             warnings_as_errors, warnings_not_as_errors, winexe)
@@ -27,6 +27,7 @@ Compile a F# executable and runs it as a test
 | :------------- | :------------- | :------------- | :------------- | :------------- |
 | name |  A unique name for this target.   | Name | required |  |
 | compile_data |  Additional compile time files.   | List of labels | optional | [] |
+| compiler_options |  Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute.   | List of strings | optional | [] |
 | data |  Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files.   | List of labels | optional | [] |
 | defines |  A list of preprocessor directive symbols to define.   | List of strings | optional | [] |
 | deps |  Other libraries, binaries, or imported DLLs   | List of labels | optional | [] |
diff --git a/dotnet/private/rules/common/attrs.bzl b/dotnet/private/rules/common/attrs.bzl
index f073e62c..20d5ef48 100644
--- a/dotnet/private/rules/common/attrs.bzl
+++ b/dotnet/private/rules/common/attrs.bzl
@@ -98,6 +98,11 @@ COMMON_ATTRS = {
         doc = "Whether or not to generate a documentation file.",
         default = True,
     ),
+    "compiler_options": attr.string_list(
+        doc = "Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute.",
+        mandatory = False,
+        default = [],
+    ),
     "_target_framework": attr.label(
         default = "//dotnet:target_framework",
     ),
diff --git a/dotnet/private/rules/csharp/actions/csharp_assembly.bzl b/dotnet/private/rules/csharp/actions/csharp_assembly.bzl
index 3a2b5cf6..8f158380 100644
--- a/dotnet/private/rules/csharp/actions/csharp_assembly.bzl
+++ b/dotnet/private/rules/csharp/actions/csharp_assembly.bzl
@@ -83,7 +83,8 @@ def AssemblyAction(
         project_sdk,
         allow_unsafe_blocks,
         nullable,
-        run_analyzers):
+        run_analyzers,
+        compiler_options):
     """Creates an action that runs the CSharp compiler with the specified inputs.
 
     This macro aims to match the [C# compiler](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-alphabetically), with the inputs mapping to compiler options.
@@ -121,6 +122,7 @@ def AssemblyAction(
         allow_unsafe_blocks: Compiles the target with /unsafe
         nullable: Enable nullable context, or nullable warnings.
         run_analyzers: Enable analyzers.
+        compiler_options: Additional options to pass to the compiler.
     Returns:
         The compiled csharp artifacts.
     """
@@ -182,6 +184,7 @@ def AssemblyAction(
             allow_unsafe_blocks,
             nullable,
             run_analyzers,
+            compiler_options,
             out_dll = out_dll,
             out_ref = out_ref,
             out_pdb = out_pdb,
@@ -228,6 +231,7 @@ def AssemblyAction(
             allow_unsafe_blocks,
             nullable,
             run_analyzers,
+            compiler_options,
             out_ref = out_iref,
             out_dll = out_dll,
             out_pdb = out_pdb,
@@ -263,6 +267,7 @@ def AssemblyAction(
             allow_unsafe_blocks,
             nullable,
             run_analyzers,
+            compiler_options,
             out_dll = None,
             out_ref = out_ref,
             out_pdb = None,
@@ -323,6 +328,7 @@ def _compile(
         allow_unsafe_blocks,
         nullable,
         run_analyzers,
+        compiler_options,
         out_dll = None,
         out_ref = None,
         out_pdb = None,
@@ -421,6 +427,10 @@ def _compile(
     if keyfile != None:
         args.add("/keyfile:" + keyfile.path)
 
+    # Additional compiler flags
+    for option in compiler_options:
+        args.add(option)
+
     # spill to a "response file" when the argument list gets too big (Bazel
     # makes that call based on limitations of the OS).
     args.set_param_file_format("multiline")
diff --git a/dotnet/private/rules/csharp/binary.bzl b/dotnet/private/rules/csharp/binary.bzl
index e255ea0a..06af1536 100644
--- a/dotnet/private/rules/csharp/binary.bzl
+++ b/dotnet/private/rules/csharp/binary.bzl
@@ -48,6 +48,7 @@ def _compile_action(ctx, tfm):
         allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks,
         nullable = ctx.attr.nullable,
         run_analyzers = ctx.attr.run_analyzers,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _binary_private_impl(ctx):
diff --git a/dotnet/private/rules/csharp/library.bzl b/dotnet/private/rules/csharp/library.bzl
index 208febe4..3faf7688 100644
--- a/dotnet/private/rules/csharp/library.bzl
+++ b/dotnet/private/rules/csharp/library.bzl
@@ -47,6 +47,7 @@ def _compile_action(ctx, tfm):
         allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks,
         nullable = ctx.attr.nullable,
         run_analyzers = ctx.attr.run_analyzers,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _library_impl(ctx):
diff --git a/dotnet/private/rules/csharp/test.bzl b/dotnet/private/rules/csharp/test.bzl
index 1592defb..d7694ca0 100644
--- a/dotnet/private/rules/csharp/test.bzl
+++ b/dotnet/private/rules/csharp/test.bzl
@@ -50,6 +50,7 @@ def _compile_action(ctx, tfm):
         allow_unsafe_blocks = ctx.attr.allow_unsafe_blocks,
         nullable = ctx.attr.nullable,
         run_analyzers = ctx.attr.run_analyzers,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _csharp_test_impl(ctx):
diff --git a/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl b/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl
index a8adaf5f..d32b0ab4 100644
--- a/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl
+++ b/dotnet/private/rules/fsharp/actions/fsharp_assembly.bzl
@@ -97,7 +97,8 @@ def AssemblyAction(
         warnings_not_as_errors,
         warning_level,
         nowarn,
-        project_sdk):
+        project_sdk,
+        compiler_options):
     """Creates an action that runs the F# compiler with the specified inputs.
 
     This macro aims to match the [F# compiler](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-options), with the inputs mapping to compiler options.
@@ -130,6 +131,7 @@ def AssemblyAction(
         warning_level: The warning level to use.
         nowarn: List of warnings to suppress.
         project_sdk: The project SDK being targeted
+        compiler_options: Additional compiler options to pass to the compiler.
 
     Returns:
         The compiled fsharp artifacts.
@@ -184,6 +186,7 @@ def AssemblyAction(
             warnings_not_as_errors,
             warning_level,
             nowarn,
+            compiler_options,
             out_dll = out_dll,
             out_ref = out_ref,
             out_pdb = out_pdb,
@@ -223,6 +226,7 @@ def AssemblyAction(
             warnings_not_as_errors,
             warning_level,
             nowarn,
+            compiler_options,
             out_ref = out_iref,
             out_dll = out_dll,
             out_pdb = out_pdb,
@@ -253,6 +257,7 @@ def AssemblyAction(
                 warnings_not_as_errors,
                 warning_level,
                 nowarn,
+                compiler_options,
                 out_dll = None,
                 out_ref = out_ref,
                 out_pdb = None,
@@ -307,6 +312,7 @@ def _compile(
         warnings_not_as_errors,
         warning_level,
         nowarn,
+        compiler_options,
         out_dll = None,
         out_ref = None,
         out_pdb = None,
@@ -393,6 +399,10 @@ def _compile(
     if keyfile != None:
         args.add("--keyfile:" + keyfile.path)
 
+    # Additional compiler options
+    for option in compiler_options:
+        args.add(option)
+
     # spill to a "response file" when the argument list gets too big (Bazel
     # makes that call based on limitations of the OS).
     args.set_param_file_format("multiline")
diff --git a/dotnet/private/rules/fsharp/binary.bzl b/dotnet/private/rules/fsharp/binary.bzl
index f4c18057..a06df74e 100644
--- a/dotnet/private/rules/fsharp/binary.bzl
+++ b/dotnet/private/rules/fsharp/binary.bzl
@@ -42,6 +42,7 @@ def _compile_action(ctx, tfm):
         warning_level = ctx.attr.warning_level,
         nowarn = ctx.attr.nowarn,
         project_sdk = ctx.attr.project_sdk,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _binary_private_impl(ctx):
diff --git a/dotnet/private/rules/fsharp/library.bzl b/dotnet/private/rules/fsharp/library.bzl
index c49816bf..01d68217 100644
--- a/dotnet/private/rules/fsharp/library.bzl
+++ b/dotnet/private/rules/fsharp/library.bzl
@@ -43,6 +43,7 @@ def _compile_action(ctx, tfm):
         warning_level = ctx.attr.warning_level,
         nowarn = ctx.attr.nowarn,
         project_sdk = ctx.attr.project_sdk,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _library_impl(ctx):
diff --git a/dotnet/private/rules/fsharp/test.bzl b/dotnet/private/rules/fsharp/test.bzl
index 7cc8ea22..81ad4341 100644
--- a/dotnet/private/rules/fsharp/test.bzl
+++ b/dotnet/private/rules/fsharp/test.bzl
@@ -45,6 +45,7 @@ def _compile_action(ctx, tfm):
         warning_level = ctx.attr.warning_level,
         nowarn = ctx.attr.nowarn,
         project_sdk = ctx.attr.project_sdk,
+        compiler_options = ctx.attr.compiler_options,
     )
 
 def _fsharp_test_impl(ctx):
diff --git a/dotnet/private/tests/additional_compiler_options/BUILD.bazel b/dotnet/private/tests/additional_compiler_options/BUILD.bazel
new file mode 100644
index 00000000..f6815a59
--- /dev/null
+++ b/dotnet/private/tests/additional_compiler_options/BUILD.bazel
@@ -0,0 +1,29 @@
+load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load(":csharp_additional_compiler_options.bzl", "csharp_additional_compiler_options")
+load(":fsharp_additional_compiler_options.bzl", "fsharp_additional_compiler_options")
+
+fsharp_additional_compiler_options()
+
+csharp_additional_compiler_options()
+
+bzl_library(
+    name = "csharp_additional_compiler_options",
+    srcs = ["csharp_additional_compiler_options.bzl"],
+    visibility = ["//dotnet:__subpackages__"],
+    deps = [
+        "//dotnet:defs",
+        "//dotnet/private/tests:utils",
+        "@bazel_skylib//lib:unittest",
+    ],
+)
+
+bzl_library(
+    name = "fsharp_additional_compiler_options",
+    srcs = ["fsharp_additional_compiler_options.bzl"],
+    visibility = ["//dotnet:__subpackages__"],
+    deps = [
+        "//dotnet:defs",
+        "//dotnet/private/tests:utils",
+        "@bazel_skylib//lib:unittest",
+    ],
+)
diff --git a/dotnet/private/tests/additional_compiler_options/additional_compiler_options.cs b/dotnet/private/tests/additional_compiler_options/additional_compiler_options.cs
new file mode 100644
index 00000000..c872aeb3
--- /dev/null
+++ b/dotnet/private/tests/additional_compiler_options/additional_compiler_options.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Hello
+{
+    public static class Program
+    {
+        public static void Main()
+        {
+            Console.WriteLine("Hello, world!");
+        }
+    }
+}
diff --git a/dotnet/private/tests/additional_compiler_options/additional_compiler_options.fs b/dotnet/private/tests/additional_compiler_options/additional_compiler_options.fs
new file mode 100644
index 00000000..1d6ab680
--- /dev/null
+++ b/dotnet/private/tests/additional_compiler_options/additional_compiler_options.fs
@@ -0,0 +1,9 @@
+module Warnings
+
+type DasUnion =
+| Case1 of string
+| Case2 of int
+
+let matchOnDasUnion union =
+    match union with
+    | Case1 s -> s
diff --git a/dotnet/private/tests/additional_compiler_options/csharp_additional_compiler_options.bzl b/dotnet/private/tests/additional_compiler_options/csharp_additional_compiler_options.bzl
new file mode 100644
index 00000000..1190413d
--- /dev/null
+++ b/dotnet/private/tests/additional_compiler_options/csharp_additional_compiler_options.bzl
@@ -0,0 +1,22 @@
+"C# Warning settings"
+
+load("//dotnet:defs.bzl", "csharp_library")
+load("//dotnet/private/tests:utils.bzl", "action_args_test")
+
+# buildifier: disable=function-docstring
+# buildifier: disable=unnamed-macro
+def csharp_additional_compiler_options():
+    csharp_library(
+        name = "csharp_all_additional_compiler_options",
+        srcs = ["additional_compiler_options.cs"],
+        target_frameworks = ["net6.0"],
+        compiler_options = ["/warnnotaserror:CS1234", "/warnnotaserror:CS0000"],
+        tags = ["manual"],
+    )
+
+    action_args_test(
+        name = "csharp_all_additional_compiler_options_test",
+        target_under_test = ":csharp_all_additional_compiler_options",
+        action_mnemonic = "CSharpCompile",
+        expected_partial_args = ["/warnnotaserror:CS1234", "/warnnotaserror:CS0000"],
+    )
diff --git a/dotnet/private/tests/additional_compiler_options/fsharp_additional_compiler_options.bzl b/dotnet/private/tests/additional_compiler_options/fsharp_additional_compiler_options.bzl
new file mode 100644
index 00000000..d0bbd86e
--- /dev/null
+++ b/dotnet/private/tests/additional_compiler_options/fsharp_additional_compiler_options.bzl
@@ -0,0 +1,22 @@
+"F# Warning settings"
+
+load("//dotnet:defs.bzl", "fsharp_library")
+load("//dotnet/private/tests:utils.bzl", "action_args_test")
+
+# buildifier: disable=function-docstring
+# buildifier: disable=unnamed-macro
+def fsharp_additional_compiler_options():
+    fsharp_library(
+        name = "fsharp_all_additional_compiler_options",
+        srcs = ["additional_compiler_options.fs"],
+        target_frameworks = ["net6.0"],
+        compiler_options = ["/warnnotaserror:CS1234", "/warnnotaserror:CS0000"],
+        tags = ["manual"],
+    )
+
+    action_args_test(
+        name = "fsharp_all_additional_compiler_options_test",
+        target_under_test = ":fsharp_all_additional_compiler_options",
+        action_mnemonic = "FSharpCompile",
+        expected_partial_args = ["/warnnotaserror:CS1234", "/warnnotaserror:CS0000"],
+    )