Conversation
- Added `System.Text.RegularExpressions` for regex support. - Improved readability in `MakeValidIdentifier` method. - Updated `ProvisionProjectStructure` to collect MSBuild properties. - Refactored `PackageReferences` and `ProjectReferences` methods for better flexibility. - Introduced `MsBuildConditionEvaluator` for handling MSBuild conditions. - Added unit tests in `ConditionalDependenciesTests` for condition evaluations. - Updated test project configuration in `AXSharp.CompilerTests.csproj`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of PR #436
Title: [BUG] IXC Parsing csproj files does not take attribs into consideration.
Implements conditional-aware csproj dependency parsing (handling Condition attributes, multi-target frameworks, and property aggregation) to fix missing references.
Purpose: Fixes incorrect dependency discovery where conditional PackageReference / ProjectReference entries (with Condition attributes or within conditional ItemGroup blocks) were previously ignored. Closes issue #435.
Key Changes:
Adds a lightweight MsBuildConditionEvaluator embedded in CsProject.cs:
Collects properties from cascading Directory.Build.props plus the project’s PropertyGroup elements.
Derives TargetFramework / TargetFrameworks (falls back to netstandard2.0 if absent).
Evaluates simple Condition expressions (==, !=, And, Or) with $(Property) expansion (not a full MSBuild interpreter).
Applies condition checks to ItemGroup, PackageReference, and ProjectReference nodes.
Refactors PackageReferences(...) and ProjectReferences(...) to iterate per target framework and filter by passing conditions.
Adds debug logging for condition evaluation and guarded failure logging on bad PackageReference parsing.
Adds handling for multi-target frameworks and basic property precedence.
Test project updated:
Adds new conditional sample content (samples/conditional/**) copied to output.
Introduces / updates tests (e.g., ConditionalDependenciesTests.cs) to assert conditional dependency resolution.
Removes unused Castle.Core.Resource using.
Minor cosmetic/whitespace adjustments.
Files Changed (4 total):
CsProject.cs (major: +~300 lines; new evaluator + refactors).
ConditionalDependenciesTests.cs (new or expanded tests for conditional references).
AXSharp.CompilerTests.csproj (adds conditional sample content include).
IxProjectTests.IntegrationCs.cs (removes unused using).
Diff Stats: Approx. +413 / -21 overall (dominant additions in CsProject.cs).
Benefits:
Correctly includes/excludes dependencies based on common Condition patterns.
Supports multi-target evaluation to gather the union of conditional dependencies.
Improves resilience (try/catch around individual PackageReference parsing).
Limitations / Risks:
Condition evaluator is naïve: no support for complex MSBuild functions, property redefinitions inside conditional PropertyGroups, string operations, Exists(), etc.
Defaults netstandard2.0 if no TF specified—could mask configuration issues.
Logical parsing is simplistic (no nested parentheses beyond single outer removal; may mis-handle complex mixed AND/OR precedence).
Returns false on evaluation exceptions (could hide valid references if a condition is slightly more complex).
Review Suggestions:
Consider unit tests covering mixed And/Or with parentheses, inequality cases, multiple TargetFrameworks, and ignored conditional PropertyGroup overrides.
Validate behavior when both TargetFramework and TargetFrameworks exist (current logic prefers single TF—intended?).
Assess whether returning false on evaluation failure is too strict; maybe fallback to true with a warning?
Potential extraction of MsBuildConditionEvaluator into its own file for clarity and future extension.
Follow-Up Opportunities:
Expand condition parser (parentheses nesting, property redefinitions, common MSBuild functions).
Cache property evaluation results per project to reduce repeated parsing.
Add verbose mode toggle for debug logs.
Status: Open, 2 commits, marked ready for review, awaiting at least one approval. No labels assigned yet.
closes #435