-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix MilCodeGen #6135
base: main
Are you sure you want to change the base?
Fix MilCodeGen #6135
Conversation
@@ -21,17 +21,8 @@ pushd %~dp0\.. | |||
|
|||
call %~dp0\SetClrPath.cmd | |||
|
|||
copy %CspExePath%\csp.exe %clrpath% |
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.
I don't know the context for copying csp to clrpath but it seemed unnecessary.
@@ -1,6 +1 @@ | |||
set clrpath=%MANAGED_TOOLS_ROOT%\%MANAGED_REFS_VERSION% |
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.
I didn't know how to get clrpath automatically. It's the path used by sn.exe but I couldn't find where to get it.
|
||
:: Revert any generated files which haven't changed | ||
if {%_NoRevertFlag%} EQU {} call %~dp0\tf_GeneratedFiles %OutputDir% %~dp0\GeneratedElements.txt revert -a | ||
call %~dp0\InvokeCSP.cmd %Options% -rsp:main\Elements.rsp -enableCsPrime -r:"System.Xml.dll" -- %_SdFlag% -xmlFile:xml\Elements.xml -dataType:MS.Internal.MilCodeGen.ResourceModel.CG -o:"%OutputDir%" |
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.
I removed the argument -clrdir
and the full path in the argument -r
. It works without it and avoids the need of finding the path for .Net Framework reference assemblies.
@@ -0,0 +1,19 @@ | |||
-s:main\SimpleGenerator.cs |
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.
I created this file and Resources.rsp by hand because they didn't exist. They were probably missed when adding the code in this repo because *.rsp files are excluded in the gitignore.
@@ -96,7 +96,7 @@ Parameters parameters | |||
|
|||
// Add some implicit referenced assemblies. | |||
|
|||
referencedAssemblies.Add(Path.Combine(parameters.ClrDir, "System.dll")); | |||
referencedAssemblies.Add(string.IsNullOrEmpty(parameters.ClrDir) ? "System.dll" : Path.Combine(parameters.ClrDir, "System.dll")); |
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.
It says in the usage of this project that parameters.ClrDir
is optional but it failed here.
You stole my next target 😄 |
I pushed a bunch of commit to try to reduce the diff but I couldn't reduce it much further because the bulk of the changes in generated code come from whitespace added because of conditional code which adds an empty line (Example: This code generates these whitespaces). |
With 308 changed files it's almost impossible to understand what has changed :/ |
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.
I think would be worth to keep build changes from style formatting changes separately. I have hopes that this allow speedup of the review, or at least schedule it for testing.
@@ -250,12 +250,15 @@ internal void RemoveAtWithoutFiringPublicEvents(int index) | |||
|
|||
WritePreamble(); | |||
|
|||
if (!Object.ReferenceEquals(_collection[index], value)) | |||
if (!Object.ReferenceEquals(_collection[ index ], value)) |
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.
These kind of changes is against current code style. I assume that it would be hard to convince WPF team on this kind of changes. Also they are reduce ability understand what's going on.
OnFreezablePropertyChanged(oldValue, value); | ||
|
||
_collection[index] = value; | ||
_collection[ index ] = value; | ||
|
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.
Do these empty lines needed?
@@ -236,8 +245,11 @@ void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel) | |||
|
|||
if (_duceResource.ReleaseOnChannel(channel)) | |||
{ | |||
|
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.
Why these two lines? I see these a lot. That's confusing.
@kant2002 @omariom Sorry about the delay, I forgot about this PR. All the files are generated using MilCodeGen without any modifications by hand so all the changes are necessary. It looks like a lot of generated files were formatted when adding the files to this repo. |
3b939e3
to
4fdf462
Compare
I rebased, fixed the conflicts and synced MilCodeGen to the generated code since changes to generated files was merged into main. @dotnet/wpf-developers: Could this be considered for the next test pass ? MilCodeGen is outdated compared to the generated files in the main branch because generated files get changed manually because we cannot run MilCodeGen. |
Description
This PR aims to fix MilCodeGen which seems to be very outdated and it doesn't seem like it ever worked in this repo (It probably worked in the internal repo for Microsoft).
Since it does not seem like it ever worked, I did these changes just by deducing how it's supposed to work so this PR might be totally wrong.
I noticed a couple of changes in the generated code other than white-space and license header where I don't know whether the source of truth is the new generated code or the existing generated code (It's mostly comments that differ between both).
This PR unblocks PRs like this one: #5651.
Customer Impact
None.
Regression
No.
Testing
I tested this fix locally using this command
build -projects "src\Microsoft.DotNet.Wpf\src\WpfGfx\codegen\mcg\mcg.proj"
and by looking at the changes and doing a normal build afterwards.Risk
I think the risk is pretty low since it's only used for development in this repo and the worse that can happen is to be unable to run MilCodeGen (It didn't work before this PR so it can only be an improvement). All the generated code is checked out in Git so it's easier to validate that the generated code is good.