-
-
Notifications
You must be signed in to change notification settings - Fork 84
[WIP] Gazelle plugin #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[WIP] Gazelle plugin #381
Conversation
I've created a basic working example of rules_dotnet Gazelle integration at https://github.com/LavaToaster/monorepo/blob/main/README.dotnet.md. It implements:
My goal is to make the .NET development experience as seamless as possible with Bazel. Ideally, developers should be able to:
@purkhusid - Could you review this implementation and suggest what improvements I should make before attempting to upstream this to the main rules_dotnet repository? I would keep in mind that the gazelle generator and the nuget2bazel tool are quite coupled in their output expectations. The gazelle generator isn't currently F# aware, nor compatible with the paket2bazel tool. |
I'm on vacation for the next couple of weeks but I'll definitely take a look once I'm back! |
@LavaToaster I took a quick look at the Gazelle plugin and it looks pretty straight forward to me. One thing that I think might make sense instead of using XML parsing is to use the The upside of this is that it will take into account all MSBuild quirks like e.g. if you have a More info on the MSBuild CLI here: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2022 |
Hey @purkhusid, I can certainly do that! Didn't realise I could query via msbuild so that looks promising. 👀 I have pulled out a few issues in this project with rules_dotnet:
It's been a little bit since I've been in context but might be worth having a quick call with you to understand a little better what I can do to ensure that either I'm fixing something in rules_dotnet, or fixing the gazelle generator. Any small guidance should be able to push me in the right direction. patch.diffdiff --git a/dotnet/private/common.bzl b/dotnet/private/common.bzl
index c330647..e531010 100644
--- a/dotnet/private/common.bzl
+++ b/dotnet/private/common.bzl
@@ -215,7 +215,7 @@ def _format_ref_with_overrides(assembly):
return "-r:" + assembly.path
def format_ref_arg(args, refs):
- """Takes
+ """Takes
Args:
args: The args object that will be sent into the compilation action
@@ -267,6 +267,10 @@ def collect_compile_info(name, deps, targeting_pack, exports, strict_deps):
targeting_pack_overrides = {}
framework_list = {}
framework_files = []
+ targeting_pack_analyzers = {}
+ targeting_pack_analyzers_csharp = {}
+ targeting_pack_analyzers_fsharp = {}
+ targeting_pack_analyzers_vb = {}
if targeting_pack:
targeting_pack_info = targeting_pack[DotnetTargetingPackInfo]
@@ -282,10 +286,16 @@ def collect_compile_info(name, deps, targeting_pack, exports, strict_deps):
if len(nuget_info.framework_list) == 0:
framework_files.extend(compile_info.irefs)
- direct_analyzers.extend(compile_info.analyzers)
- direct_analyzers_csharp.extend(compile_info.analyzers_csharp)
- direct_analyzers_fsharp.extend(compile_info.analyzers_fsharp)
- direct_analyzers_vb.extend(compile_info.analyzers_vb)
+ # Store targeting pack analyzers separately so they can be overridden by direct deps
+ for analyzer in compile_info.analyzers:
+ targeting_pack_analyzers[analyzer.basename] = analyzer
+ for analyzer in compile_info.analyzers_csharp:
+ targeting_pack_analyzers_csharp[analyzer.basename] = analyzer
+ for analyzer in compile_info.analyzers_fsharp:
+ targeting_pack_analyzers_fsharp[analyzer.basename] = analyzer
+ for analyzer in compile_info.analyzers_vb:
+ targeting_pack_analyzers_vb[analyzer.basename] = analyzer
+
direct_compile_data.extend(compile_info.compile_data)
for dep in deps:
@@ -294,24 +304,52 @@ def collect_compile_info(name, deps, targeting_pack, exports, strict_deps):
add_to_output = True
if assembly.name.lower() in targeting_pack_overrides:
if semver.to_comparable(assembly.version) > semver.to_comparable(targeting_pack_overrides[assembly.name.lower()], relaxed = True):
- framework_list.pop(assembly.name.lower())
+ framework_list.pop(assembly.name.lower(), None)
add_to_output = True
else:
add_to_output = False
elif assembly.name.lower() in framework_list:
if semver.to_comparable(assembly.version) > semver.to_comparable(framework_list[assembly.name.lower()].get("version"), relaxed = True):
- framework_list.pop(assembly.name.lower())
+ framework_list.pop(assembly.name.lower(), None)
add_to_output = True
else:
add_to_output = False
+ if name == "DBot.Bot" and assembly.name.lower() == "microsoft.extensions.configuration.binder":
+ print("Assembly: {}, Version: {}, Targeting pack: {}, Add to output: {}".format(assembly.name, assembly.version, targeting_pack_overrides.get(assembly.name.lower()), add_to_output))
+ print(assembly.name.lower() in targeting_pack_overrides)
+ print(assembly.name.lower() in framework_list)
+ print(direct_analyzers)
+ print(direct_analyzers_csharp)
+ print(direct_analyzers_fsharp)
+ print(direct_analyzers_vb)
+ print(direct_compile_data)
+
if add_to_output:
direct_iref.extend(assembly.irefs if name in assembly.internals_visible_to else assembly.refs)
direct_ref.extend(assembly.refs)
- direct_analyzers.extend(assembly.analyzers)
- direct_analyzers_csharp.extend(assembly.analyzers_csharp)
- direct_analyzers_fsharp.extend(assembly.analyzers_fsharp)
- direct_analyzers_vb.extend(assembly.analyzers_vb)
+
+ # For each direct dependency, override targeting pack analyzers with the same name
+ for analyzer in assembly.analyzers:
+ if analyzer.basename in targeting_pack_analyzers:
+ targeting_pack_analyzers.pop(analyzer.basename)
+ direct_analyzers.append(analyzer)
+
+ for analyzer in assembly.analyzers_csharp:
+ if analyzer.basename in targeting_pack_analyzers_csharp:
+ targeting_pack_analyzers_csharp.pop(analyzer.basename)
+ direct_analyzers_csharp.append(analyzer)
+
+ for analyzer in assembly.analyzers_fsharp:
+ if analyzer.basename in targeting_pack_analyzers_fsharp:
+ targeting_pack_analyzers_fsharp.pop(analyzer.basename)
+ direct_analyzers_fsharp.append(analyzer)
+
+ for analyzer in assembly.analyzers_vb:
+ if analyzer.basename in targeting_pack_analyzers_vb:
+ targeting_pack_analyzers_vb.pop(analyzer.basename)
+ direct_analyzers_vb.append(analyzer)
+
direct_compile_data.extend(assembly.compile_data)
# We take all the exports of each dependency and add them |
@LavaToaster Could you create a minimal reproduction of the issue and link it in #467 ? Have you looked into what version of the rules_dotnet/dotnet/private/common.bzl Line 296 in 5989daa
|
No description provided.