-
Notifications
You must be signed in to change notification settings - Fork 518
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
[Rgen] Share DataModel between the generator and the transformer. #22015
Conversation
In this change we are making the necesary changes to share the data model code between the generator and the transformer. When we talk about sharing code in C# the average dotnet developer would create a csproj with the shared code and would reference it. In normal circumtances this is not a bad option, but our case is different and here are some of the reasons we cannot take that path: 1. Roslyn code generators with more than one dll are problematic to distribute. You can already see how bad it is by looking at the dll shared between the code generator and the analyzer. The shared library has to be added as an analyzer so that it loads with the generator. We want to keep the number of dlls to a minimun. 2. While the data models are similar, they are not identical. The attributes used by the code generator and the old api defintions are different. We would around this by splitting the definitions in 2 files: a - A common file with all date that does not depend on the attributes. b - A application specific file that contains the properties needed by the common parts BUT that uses structures specific for the application. An example is the ExportData. The ExportData is a generic in the generator (which contains flags) while it is not in the transformer. We also split the TryCreate and Constructor methods since those need to init the application specific parths. In this commit we do not implement the transformer parts since that would make the diff hader. We are only moving code around and adding dummy implementations for the transformer project to compile.
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.
Copilot reviewed 12 out of 27 changed files in this pull request and generated 2 comments.
Files not reviewed (15)
- src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/CodeChanges.Generator.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Property.Generator.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Constructor.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Event.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/EnumMember.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/CodeChanges.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Accessor.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Transformer/DataModel/Accessor.Transformer.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Transformer/Attributes/FieldData.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/EnumMember.Generator.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Accessor.Generator.cs: Evaluated as low risk
- src/rgen/Microsoft.Macios.Generator/DataModel/Method.Generator.cs: Evaluated as low risk
Comments suppressed due to low confidence (4)
src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.Generator.cs:1
- The word 'necesary' is misspelled. It should be 'necessary'.
// In this change we are making the necesary changes to share the data model code between the generator and the transformer.
src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.Generator.cs:1
- The word 'minimun' is misspelled. It should be 'minimum'.
// We want to keep the number of dlls to a minimun.
src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.Generator.cs:29
- The variable 'isNSObject' should follow camelCase naming convention. It should be renamed to 'isNSObject'.
isNSObject: out isNSObject,
src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.Generator.cs:30
- The variable 'isINativeObject' should follow camelCase naming convention. It should be renamed to 'isNativeObject'.
isNativeObject: out isINativeObject,
/// <inheritdoc /> | ||
public bool Equals (BindingInfo other) | ||
{ | ||
throw new NotImplementedException(); |
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.
The Equals method should not throw NotImplementedException. It should compare the relevant fields of the BindingInfo struct.
throw new NotImplementedException(); | |
// Implement comparison logic here |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
/// <inheritdoc /> | ||
public override int GetHashCode () | ||
{ | ||
throw new NotImplementedException (); |
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.
The GetHashCode method should not throw NotImplementedException. It should return a hash code based on the relevant fields of the BindingInfo struct.
throw new NotImplementedException (); | |
// Implement the hash code generation logic here |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 this is a good approach as it allows us to both share code but also when needed have specific DataModel code files for each project without #if's everywhere so it ends up being cleaner
This comment has been minimized.
This comment has been minimized.
✅ [CI Build] Build passed (Build packages) ✅Pipeline on Agent |
✅ [CI Build] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
✅ API diff for current PR / commit.NET ( No breaking changes )❗ API diff vs stable (Breaking changes).NET ( ❗ Breaking changes ❗ )ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: test results 1 tests crashed, 0 tests failed, 111 tests passed. Failures❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
In this change we are making the necesary changes to share the data model code between the generator and the transformer.
When we talk about sharing code in C# the average dotnet developer would create a csproj with the shared code and would reference it. In normal circumtances this is not a bad option, but our case is different and here are some of the reasons we cannot take that path:
a - A common file with all date that does not depend on the attributes.
b - A application specific file that contains the properties needed by the common parts BUT that uses structures specific for the application. An example is the ExportData. The ExportData is a generic in the generator (which contains flags) while it is not in the transformer. We also split the TryCreate and Constructor methods since those need to init the application specific parths.
In this commit we do not implement the transformer parts since that would make the diff hader. We are only moving code around and adding dummy implementations for the transformer project to compile.