dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

Questions about ICorDebugEval2::NewParameterizedObjectNoConstructor #50949

Open viewizard opened 3 years ago

viewizard commented 3 years ago

Hello,

I am refactor netcoredbg debugger code and would like ask your help in clarification of ICorDebugEval2::NewParameterizedObjectNoConstructor work.

I found https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/debugging/icordebugeval2-newparameterizedobjectnoconstructor-method with description provided Instantiates a new parameterized type object of the specified class without attempting to call a constructor method.. My test shows, that this method call static constructor, is not this mean that "NoConstructor" really call constructor? I am just confused by this method name, could you please confirm that static constructor are called?

I would like use it at static fields evaluation by ICorDebugType::GetStaticFieldValue and I found, that ICorDebugType::GetStaticFieldValue return S_OK even if static constructor was not previously called for type. Is the any way I could detect this? If no, is it safe call ICorDebugEval2::NewParameterizedObjectNoConstructor (that I believe call static constructor only once for type) unlimited times?

Just to be sure, I am right that ICorDebugEval2::NewParameterizedObjectNoConstructor don't execute normal constructor or finalizer by some reason in some case (I see we have ICorDebugEval2::NewParameterizedObject for this, but I better ask), and will not change debuggee process state in any way except user code execution in static constructor?

CC @alpencolt

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 3 years ago

Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.

Issue Details
Hello, I am refactor netcoredbg debugger code and would like ask your help in clarification of `ICorDebugEval2::NewParameterizedObjectNoConstructor` work. I found https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/debugging/icordebugeval2-newparameterizedobjectnoconstructor-method with description provided `Instantiates a new parameterized type object of the specified class without attempting to call a constructor method.`. My test shows, that this method call static constructor, is not this mean that "NoConstructor" really call constructor? I am just confused by this method name, could you please confirm that static constructor are called? I would like use it at static fields evaluation by `ICorDebugType::GetStaticFieldValue` and I found, that `ICorDebugType::GetStaticFieldValue` return `S_OK` even if static constructor was not previously called for type. Is the any way I could detect this? If no, is it safe call `ICorDebugEval2::NewParameterizedObjectNoConstructor` (that I believe call static constructor only once for type) unlimited times? Just to be sure, I am right that `ICorDebugEval2::NewParameterizedObjectNoConstructor` don't execute normal constructor or finalizer by some reason in some case (I see we have `ICorDebugEval2::NewParameterizedObject` for this, but I better ask), and will not change debuggee process state in any way except user code execution in static constructor? CC @alpencolt
Author: viewizard
Assignees: -
Labels: `area-Diagnostics-coreclr`, `question`, `untriaged`
Milestone: -
viewizard commented 1 year ago

CC @gbalykov