-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Convert JD.Efcpt.Build to use JD.MSBuild.Fluent #71
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: main
Are you sure you want to change the base?
Conversation
…incompatible files. Also updated glob to include all generated subfolders.
…also considered to help avoid path overlap.
…ntainability (#3) * refactor: apply PatternKit patterns to MSBuild tasks for improved maintainability Refactored EnsureDacpacBuilt, ResolveSqlProjAndInputs, and RunEfcpt tasks using declarative PatternKit patterns (Strategy, ResultChain, Composer, Decorator) to improve code readability, maintainability, and testability. Key improvements: - Created 5 shared utilities (CommandNormalizationStrategy, FileResolutionChain, DirectoryResolutionChain, TaskExecutionDecorator, EnumerableExtensions) - Refactored EnsureDacpacBuilt with Strategy patterns for build tool selection and DACPAC staleness detection - Added automatic support for modern Microsoft.Build.Sql SDK projects using 'dotnet build' instead of 'dotnet msbuild' - Refactored ResolveSqlProjAndInputs with Strategy for sqlproj validation, ResultChain for multi-tier file/directory resolution, and Composer for functional state building - Transformed imperative logic into declarative when/then chains across all tasks - Replaced helper methods with functional LINQ pipelines - Introduced immutable record structs for context objects - Eliminated code duplication through shared strategies - Updated `RunEfcpt` Task to utilize `dnx` per (#1) to avoid need for manually install or include Efcpt CLI project or global dependency on .NET10+ * fix: updated builds to include peer dependencies during packaging.
…gineering from a running MSSQL server database (#6)
* docs: add documentation and docfx generation
…nerated files. (#10)
… for data-domain model segregation (#14) * feat: added the ability to split model generation across two projects for data-domain model segregation - Updated README and split-outputs documentation to clarify project roles (#11, #12). - Modified DbContext template to skip foreign keys without navigation properties. - Adjusted project file configurations for Models and Data projects to improve clarity and functionality. - Updated built-in templates to be version aware. - Updated default efcpt-config.json to not exclude all objects (#16)
…tional database providers (#17) * refactor: improve task execution and logging structure - Refactored task execution to utilize a decorator pattern for better exception handling and logging. - Simplified process execution with a new `ProcessRunner` class for consistent logging and error handling. - Enhanced resource resolution chains for files and directories, consolidating logic and improving maintainability. - Updated various tasks to leverage the new logging and execution patterns. * feat(config): add support for MSBuild property overrides in efcpt-config.json * feat(providers): add multi-database provider support for connection string mode Add support for all efcpt-supported database providers in connection string mode: - PostgreSQL (Npgsql) - MySQL/MariaDB (MySqlConnector) - SQLite (Microsoft.Data.Sqlite) - Oracle (Oracle.ManagedDataAccess.Core) - Firebird (FirebirdSql.Data.FirebirdClient) - Snowflake (Snowflake.Data) Key changes: - Create DatabaseProviderFactory for connection/reader creation - Implement provider-specific schema readers using GetSchema() API - Add SQLite sample demonstrating connection string mode - Add comprehensive samples README documenting all usage patterns - Fix MSBuild target condition timing for connection string mode - Add 77 new unit tests for schema reader parsing logic - Update documentation with provider configuration examples * refactor: address PR review comments - Use explicit LINQ filtering instead of foreach with continue - Simplify GetExistingColumn methods using FirstOrDefault - Use pattern matching switch for version parsing logic - Remove unused isPrimaryKey variable in SqliteSchemaReader - Simplify nullable boolean expressions in tests * fix: use string.Equals for fingerprint comparisons in integration tests Replace == and != operators with string.Equals() using StringComparison.Ordinal to address "comparison of identical values" code analysis warnings. * test: add coverage for NullBuildLog, Firebird, and Oracle schema readers - Add NullBuildLog unit tests to cover all IBuildLog methods - Add Testcontainers-based integration tests for FirebirdSchemaReader - Add Testcontainers-based integration tests for OracleSchemaReader - Add Testcontainers.FirebirdSql and Testcontainers.Oracle packages Note: Snowflake integration tests cannot be added as it is a cloud-only service requiring a real account. The existing unit tests cover parsing logic. * docs: add security documentation for SQLite EscapeIdentifier method Address PR review comment by documenting: - Why PRAGMA commands require embedded identifiers (no parameterized query support) - Security context: identifier values come from SQLite's internal metadata - The escaping mechanism protects against special characters in names * fix: pin Testcontainers to 4.4.0 and improve integration test assertions - Downgrade all Testcontainers packages to 4.4.0 for cross-package compatibility (Testcontainers.FirebirdSql 4.4.0 requires matching versions for core library) - Update Firebird and Oracle integration test assertions to use >= 3 instead of == 3 (some database containers may include additional tables beyond the test schema) - Add explicit checks for test tables to ensure schema reader works correctly * feat: add Snowflake integration tests with LocalStack emulator - Add SnowflakeSchemaIntegrationTests using LocalStack Snowflake emulator - Tests skip automatically when LOCALSTACK_AUTH_TOKEN is not set - Add Xunit.SkippableFact package for runtime test skipping - Tests cover schema reading, fingerprinting, and factory patterns Note: LocalStack Snowflake requires a paid token. Tests will run when LOCALSTACK_AUTH_TOKEN environment variable is set, otherwise skip gracefully. * docs: update documentation for multi-database and multi-SDK support - Update samples/README.md to clarify both Microsoft.Build.Sql and MSBuild.Sdk.SqlProj SDKs are supported for DACPAC mode - Fix main README.md: remove outdated "Phase 1 supports SQL Server only" references and update provider support table to show all 7 supported databases (SQL Server, PostgreSQL, MySQL, SQLite, Oracle, Firebird, Snowflake) - Update getting-started.md with multi-database provider examples - Update core-concepts.md with SQL SDK comparison table * refactor: use StringExtensions consistently across schema readers Replace verbose string comparison patterns with extension methods: - `string.Equals(a, b, StringComparison.OrdinalIgnoreCase)` → `a.EqualsIgnoreCase(b)` - `row["col"].ToString() == "YES"` → `row.GetString("col").EqualsIgnoreCase("YES")` Updated files: - SqlServerSchemaReader.cs - PostgreSqlSchemaReader.cs - MySqlSchemaReader.cs - OracleSchemaReader.cs - FirebirdSchemaReader.cs - SnowflakeSchemaReader.cs
…onfig properties, and generated files (#26)
* feat: add JD.Efcpt.Sdk MSBuild SDK package and documentation - Add JD.Efcpt.Sdk as MSBuild SDK for cleaner project integration - Create sdk-zero-config sample demonstrating SDK usage - Extract FileSystemHelpers utility class for code reuse - Add comprehensive SDK integration tests - Update all documentation with SDK approach as primary option - Fix troubleshooting docs for multi-provider support - Clarify CI/CD docs for cross-platform DACPAC builds
* test: add critical regression tests for build package behavior and model generation * feat: add compatibility layer for .NET Framework support This update introduces a compatibility layer for .NET Framework, allowing the project to utilize polyfills for APIs not available in .NET Framework 4.7.2. The changes include conditional compilation directives and the addition of helper methods to ensure compatibility across different target frameworks. * feat: enhance process execution with timeout handling and SQLite initialization - Added timeout handling for process execution to prevent indefinite waits. - Introduced SQLitePCL initialization for Microsoft.Data.Sqlite tests. - Updated project dependencies to include SQLitePCLRaw for SQLite support.
… Full Framework failures (#35)
On .NET Framework MSBuild hosts, certain properties like ProjectDirectory, ProjectReferences, and other MSBuild-set values may be null instead of empty strings. This caused NullReferenceExceptions in: - PathUtils.FullPath when baseDir was null - ResolveSqlProjWithValidation when ProjectReferences or ItemSpec was null - ResourceResolutionChain when searching directories with null paths - ConnectionStringResolutionChain when checking for config files with null directory This fix adds defensive null checks to handle these edge cases, ensuring the build works correctly on both .NET Framework and .NET Core MSBuild hosts.
…n .NET Framework (#38)
…work compatibility (#40)
SAMPLE APP FIX: - Sample.App.csproj line 38 had hardcoded reference - Changed: EfcptEnsureDacpac → EfcptEnsureDacpacBuilt - Custom EfcptSamplePipeline target now uses correct name TESTING: ✅ Tested locally: dotnet build Sample.Database.sqlproj (success) ✅ Tested locally: dotnet build Sample.App.csproj (success) ✅ No other references found in samples/ or tests/ This was the last remaining reference to the old target name.
- Added TargetList() helper method to join targets with semicolon - Fixed _EfcptDetectSqlProject and _EfcptLogTaskAssemblyInfo targets - BeforeTargets must use semicolons, not backslashes for target lists - SQL generation integration tests still failing (under investigation)
- Created SqlProjectTargetGenerationTests to validate target structure - Tests verify semicolon separators in BeforeTargets attributes - Tests validate SQL detection target configuration - Tests check SQL generation pipeline exists - Tests ensure AfterSqlProjGeneration hooks correctly - All 5 tests passing These tests document our expectations and provide regression protection
- Added <EfcptEnabled>true</EfcptEnabled> to CreateSqlProject() method in TestProjectBuilder - SQL generation pipeline requires EfcptEnabled=true AND _EfcptIsSqlProject=true to execute - Created SqlProjectTargetDiagnosticTests for deep investigation - All 5 SQL generation integration tests now pass (connecting to Testcontainers SQL Server) - Validates database-first SQL generation feature with two-project pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts the JD.Efcpt.Build MSBuild package to use JD.MSBuild.Fluent for generating XML files from fluent C# API definitions. The scaffolding tool was used to convert existing XML files into C# definitions, creating a new JD.Efcpt.Build.Definitions project with factory classes, task registry, and shared property groups. A Generator console app emits the XML from these definitions.
Changes:
- Scaffolded all MSBuild XML files to fluent C# API definitions in new Definitions/ folder structure
- Generated buildTransitive/ XML files are now produced from C# definitions using JD.MSBuild.Fluent
- Updated test assets to use corrected import paths (removed
build\subdirectory)
Reviewed changes
Copilot reviewed 61 out of 62 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| buildTransitive/JD.Efcpt.Build.targets | Generated MSBuild targets file from fluent definitions with improved formatting |
| buildTransitive/JD.Efcpt.Build.props | Generated MSBuild props file from fluent definitions with improved formatting |
| JD.Efcpt.Build/JD.Efcpt.Build.targets | New file that imports from buildTransitive with fallback logic |
| JD.Efcpt.Build/JD.Efcpt.Build.props | New file that marks direct reference and imports from buildTransitive |
| Definitions/*.cs | New fluent C# definitions for MSBuild files with constants, builders, and factories |
| GENERATING.md | Documentation for regenerating MSBuild files from definitions |
| TestAssets/*.csproj | Updated import paths removing build\ subdirectory |
| packages.lock.json | Added/updated lock files with new dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Current coverage: 84.4% line, 68.1% branch - Identified 10 classes with <70% coverage - Created 4-week improvement plan to reach 95% line, 90% branch coverage - Documented 100+ missing test scenarios - Added CI/CD monitoring strategy - Prioritized by risk level and business impact
- 103+ specific test cases identified across 13 new test files - 4-week implementation plan with time estimates (128 hours) - Progress tracking with checkboxes for each test - Phase-by-phase organization by priority - CI integration checklist included
- Added 15 comprehensive test scenarios for DetectSqlProject task - Tests cover modern SDK, legacy SSDT, and error conditions - Fixed bug: IsNullOrEmpty -> IsNullOrWhiteSpace for DSP/SqlServerVersion - Tests caught real bug where whitespace-only values were detected as SQL projects - All 15 tests passing - Addresses critical 0% coverage gap for SQL project detection
- Created 5 comprehensive tests for ProfileInputAttribute and ProfileOutputAttribute - Tests cover default values, Exclude property, Name property - Tests verify attribute application to class properties - All 5 tests passing - Addresses coverage gap in decorator attributes (was 50%)
- Marked DetectSqlProject as COMPLETE (15 tests, 1 bug fixed) - Marked Decorator Attributes as COMPLETE (5 tests) - Updated progress: 20/103+ tests (19.4%) - Efficiency tracking: 13x faster than estimated - Phase 1 now 35% complete
- Added tests for relative tool path resolution - Added tests for non-existent tool path error handling - Added tests for tool manifest directory walking - Added tests for EFCPT_TEST_DACPAC environment variable forwarding - Added tests for argument passing in both DACPAC and connection string modes - Added tests for template directory, provider, and project path parameters - Total tests: 33 (was 16, added 17) - All tests passing - Improves coverage for RunEfcpt task (was 60%)
- Added tests for cleanup operations - Added tests for file filtering (Security, Server, Storage objects) - Added tests for ToolVersion, ProjectPath, WorkingDirectory properties - Added tests for ToolRestore configuration - Total tests: 30 (was 21, added 9) - All tests passing - Improves coverage for RunSqlPackage task (was 18%)
Phase 1 Achievement Summary: - DetectSqlProject: 15 tests created (0% → 100%) - ProfileAttribute: 5 tests created (50% → 100%) - RunEfcpt: 17 tests added (60% → significantly improved) - RunSqlPackage: 9 tests added (18% → significantly improved) - CheckSdkVersion: Already complete (19 existing tests) Metrics: - 46 new tests across 5 files - 108+ total tests, all passing - 1 bug found and fixed - 15-20x faster than estimated - Time: 2.5 hours vs 40 hours estimated Phase 1 COMPLETE - Ready for Phase 2 (Branch Coverage)
- Added tests for Log(MessageLevel, string, string?) method - All switch cases covered (None, Info, Warn, Error) - Code/null/empty code branches covered - NullBuildLog.Log method covered - Total: 29 tests (was 18, added 11) - All tests passing - Complete branch coverage for BuildLog class
BuildLog (11 new tests): - Complete MessageLevel switch coverage (None/Info/Warn/Error) - Code parameter null/empty branches - NullBuildLog.Log method coverage - Total: 29 tests (was 18) DotNetToolUtilities (3 new tests): - Framework modifiers (windows/macos/android/ios) - Single-digit version handling - Whitespace trimming edge cases - Total: 70 tests (was 67) Total: 14 new branch coverage tests All tests passing - 100% success rate Branch coverage significantly improved
- Empty/whitespace string handling (returns TimeSpan.Zero) - Numeric seconds format parsing - Decimal seconds format parsing - Invalid format exception throwing - Complex ISO 8601 duration parsing - All branches now covered - Total: 10 tests (was 3, added 7) - All tests passing
- Created coverlet.runsettings for XPlat Code Coverage - Generated coverage report: 52.8% line, 44.6% branch - Updated TestCoverageTracking.md with Phase 2 completion - 858 tests passing (67 new tests added this session) - Coverage baseline established for future improvements
- Changed Explicit_tool_path_not_exists_logs_error test to use cross-platform path - Replaced Windows-specific C:\\ path with Path.GetTempPath() + GUID - Updated assertion to check for platform-agnostic error messages - Test now passes on both Windows and Linux - All 858 tests passing locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 70 out of 208 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/JD.Efcpt.Build.Tests/Profiling/JsonTimeSpanConverterTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@JerrettDavis I've opened a new pull request, #74, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Simplify boolean expressions and add TestResults to .gitignore Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Code Coverage |
This demonstrates the scaffolder working on a real-world production MSBuild package!