Skip to content
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

Add EnumBuilder implementation and other changes #88503

Merged
merged 4 commits into from
Jul 13, 2023

Conversation

buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Jul 7, 2023

Contributes to #62956

Tested AB.Save implementation with TlbImp3.exe with a sample *.tlb files. Adding/updating following based on the test result:

  • Add implementation for TypeBuilderImpl.FullName ( this needed TypeNameBuilder which copied from Corelib)
  • Add implementation for TypeBuilderImpl.CreateTypeInfoCore() - for now just returning the TypeBuilderImp itself, might need some update after IL implementation added;
  • Added EnumBuiderImpl, mostly using TypeBuilderImpl code for writing to file
  • EnumBuiderImpl needs FieldBuilderImp.SetConstantCore(object? defaultValue) implementation, so added it

@ghost
Copy link

ghost commented Jul 7, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection-emit
See info in area-owners.md if you want to be subscribed.

Issue Details

Contributes to https://github.com/dotnet/runtime/issues/

Tested AB.Save implementation with TlbImp3.exe with a sample *.tlb files. Adding/updating following based on the test result:

  • Add implementation for TypeBuilderImpl.FullName ( this needed TypeNameBuilder which copied from Corelib)
  • Add implementation for TypeBuilderImpl.CreateTypeInfoCore() - for now just returning the TypeBuilderImp itself, might need some update after IL implementation added;
  • Added EnumBuiderImpl, mostly using TypeBuilderImpl code for writing to file
  • EnumBuiderImpl needs FieldBuilderImp.SetConstantCore(object? defaultValue) implementation, so added it
Author: buyaa-n
Assignees: buyaa-n
Labels:

area-System.Reflection.Emit

Milestone: -

…t/EnumBuilderImpl.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copy link
Member

@steveharter steveharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; some minor nits\questions.

<data name="Argument_ConstantDoesntMatch" xml:space="preserve">
<value>Constant does not match the defined type.</value>
</data>
<data name="Argument_ConstantNull" xml:space="preserve">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need the differentiation here - the one above may be acceptable for null as well, plus considering there is only one case for the null check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the above acceptable, but it might be cleared than the above, also the exception messages and throwing logic copied from corelib, it might be better to be consistent with corelib messaging, let me know if you think otherwise.

@buyaa-n
Copy link
Contributor Author

buyaa-n commented Jul 13, 2023

All failures are not related and known

@buyaa-n buyaa-n merged commit 3eb6eef into dotnet:main Jul 13, 2023
@buyaa-n buyaa-n deleted the enum-builder branch July 13, 2023 17:27

namespace System.Reflection.Emit
{
internal sealed class TypeNameBuilder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is line-to-line identical to https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs except for deleted comment and unused method.

Would it be better to just include the CoreLib in the .csproj file instead of copying it the file over?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is line-to-line identical to https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs except for deleted comment and unused method.

Right, and I mentioned that in the description.

Would it be better to just include the CoreLib in the .csproj file instead of copying it the file over?

Was not aware of that was an option, I will try that out with my next PR which probably will not happen in .NET 8.0, would you like to update that within .NET 8?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have number of places where we borrow CoreLib code to avoid copying it around. Look for <Compile Include="$(CoreLibSharedDir)System.... This pattern is typically used for down-level configs, I do not see a problem with doing the same here.

This does not need to be in .NET 8. However, I do prefer smaller more frequent PRs that do just one thing - they are much easier to review and merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants