Markus codechefs feature/generatefileifactualchangewasmade - #133
Merged
rappen merged 6 commits intoJul 25, 2026
Merged
Conversation
Add functionality to check if only the time changed
There was a problem hiding this comment.
Pull request overview
This PR updates the generation pipeline to avoid rewriting output files when the actual generated content hasn’t changed (ignoring header fields like “Created” timestamp and “Filename”), and surfaces a “no changes” outcome to both the UI and command-line flows. It also adds unit tests and testdata to validate date/filename preservation behavior.
Changes:
- Update
Extensions.WriteFileto compare generated vs existing content (ignoring Created/Filename) and returnfalsewhen no write is needed. - Move exception handling up to
LCG.cs(UI) andLCGCmd/LCGHelper.cs(CLI) and add explicit “no changes” messaging when generation doesn’t save. - Add new test helper + template testdata and introduce
DatePreservationTeststo validate preservation/update behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| LCGTests/testdata/ExpectedTestContent.cs | Adds a template used to generate expected file content with parameterized filename/date. |
| LCGTests/TestContentHelper.cs | Adds helper methods to produce test input content and formatted expected output. |
| LCGTests/LCGTests.csproj | Includes new test files and ensures template testdata is copied to output. |
| LCGTests/DatePreservationTests.cs | Adds tests intended to validate timestamp/filename preservation and update behavior. |
| LCGCmd/LCGHelper.cs | Handles “no changes” and adds exception handling around generation in CLI flow. |
| LCG-UDG/LCG.cs | Handles “no changes” and adds exception handling around generation in UI flow. |
| LCG-UDG/LCG-UDG-Common.csproj | Adds new constants file to the build. |
| LCG-UDG/Generation/GenerationUtils.cs | Removes internal try/catch so errors propagate to the caller; preserves generation flow. |
| LCG-UDG/Generation/Extensions.cs | Implements “skip write if unchanged” behavior and refactors placeholder replacements via constants. |
| LCG-UDG/Constants/FileHeaderConstants.cs | Introduces constants for placeholders and header labels used during header/data generation. |
Comments suppressed due to low confidence (2)
LCGTests/DatePreservationTests.cs:45
- WriteFile now returns false when it detects the generated content is unchanged (it skips writing). This test currently expects true, so it will fail even though the behavior is correct.
Assert.IsTrue(result);
LCGTests/DatePreservationTests.cs:93
- WriteFile returns false when only header fields like filename differ and the file is not rewritten; this assertion should expect false to match the new contract ("saved" vs "no changes").
Assert.IsTrue(result);
Comment on lines
+13
to
+17
| [TestInitialize] | ||
| public void Setup() | ||
| { | ||
| _testFilePath = Path.GetTempFileName(); | ||
| } |
Comment on lines
+63
to
+72
| // Act - Write different content | ||
| var dataContent = TestContentHelper.GetModifiedTestDataContent(); | ||
| var result = dataContent.WriteFile(_testFilePath, "https://test.crm.dynamics.com", settings); | ||
|
|
||
| // Assert | ||
| Assert.IsTrue(result); | ||
| var finalContent = File.ReadAllText(_testFilePath); | ||
| Assert.IsFalse(finalContent.Contains(originalDate), "Original date should not be preserved when content changes"); | ||
| Assert.IsTrue(finalContent.Contains(DateTime.Now.ToString("yyyy-MM-dd")), "Current date should be used when content changes"); | ||
| Assert.IsTrue(finalContent.Contains("modified_entity"), "Modified content should be present"); |
Comment on lines
+61
to
64
| catch (Exception ex) | ||
| { | ||
| Console.WriteLine("Error"); | ||
| MessageBox.Show($"Error:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
| } |
Comment on lines
8
to
10
| using System.Text; | ||
| using System.Text.RegularExpressions; | ||
| using System.Windows.Forms; |
Comment on lines
+80
to
+85
| // Skip configuration section | ||
| if (line.Contains("LCG-configuration-BEGIN")) | ||
| { | ||
| skipConfiguration = true; | ||
| continue; | ||
| } |
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.
The idea and mainly the logic were from @markus-codechefs - thanks a LOT for that!
To know more: read his request #129 and his original PR #130