Skip to content

v1 fix #1588: передача пропущенных параметров в COM-объекты#1589

Merged
EvilBeaver merged 3 commits intoEvilBeaver:latestfrom
Mr-Rm:v1/fix-1588
Oct 20, 2025
Merged

v1 fix #1588: передача пропущенных параметров в COM-объекты#1589
EvilBeaver merged 3 commits intoEvilBeaver:latestfrom
Mr-Rm:v1/fix-1588

Conversation

@Mr-Rm
Copy link
Collaborator

@Mr-Rm Mr-Rm commented Sep 26, 2025

Остается вопрос, какие еще динамические объекты отличают передачу Неопределено от пропущенного параметра. Возможно, потребуется модификация PrepareDynamicArgs()

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nixel2007 nixel2007 requested a review from Copilot September 27, 2025 18:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fixes handling of missing parameters when calling COM objects by distinguishing between undefined values and truly missing parameters. The change ensures COM objects receive proper Missing.Value for omitted parameters instead of null values.

  • Modified PrepareDynamicArgs to accept context and skip processing for COM objects
  • Updated ConvertToCLRObject to handle NotAValidValue type and return Missing.Value
  • Simplified COM marshalling logic by removing redundant null coalescing

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
MachineInstance.cs Added context parameter to PrepareDynamicArgs and special handling for COM objects
ContextValuesMarshaller.cs Added NotAValidValue case returning Missing.Value and simplified object conversion logic
COMWrapperContext.cs Removed redundant null coalescing in MarshalIValue method

Comment on lines +257 to +259
if (val.GetRawValue() is IObjectWrapper wrapped)
result = wrapped.UnderlyingObject;
else
throw ValueMarshallingException.NoConversionToCLR(val.GetType());

return result;
return wrapped.UnderlyingObject;

Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

The code assumes that if val.DataType is not one of the handled primitive types and val.GetRawValue() is not IObjectWrapper, then it should throw an exception. However, the original code had a specific check for DataType.Object before checking for IObjectWrapper. This change may cause exceptions for valid Object types that are not IObjectWrapper instances.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

В исходном коде результат присваивания result = val.AsObject(); после проверки val.DataType == DataType.Object либо перезаписывался, либо терялся при исключении.
Исправленный код не меняет это поведение, но возможно, логика преобразования была неверной изначально.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot оцени ответ выше

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ах блин, ты же тупой, не умеешь отвечать на комменты по ревью.

Copy link
Collaborator

@nixel2007 nixel2007 Sep 29, 2025

Choose a reason for hiding this comment

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

@coderabbitai оцени изначальный комментарий от @copilot на правильность и ответ на него от Mr-Rm

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Mr-Rm @EvilBeaver мои полномочия здесь всё :D

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Owner

Choose a reason for hiding this comment

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

@Mr-Rm что скажешь?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Судя по использованию ConvertToCLRObject внутри движка, нужно добавить обработку DataType.Object. Но раньше влияние этой ошибки вылезало ли где-нибудь?
А вот что будет с передачей полученного object'а по COM, судить не возьмусь. Впрочем, wrapped так бы и передался как отмаршаленный CLR-object. Некоторые подробности есть здесь
Предложение: пофиксить DataType.Object, а COM-серверы пусть сами разбираются с тем, что пришло.

Copy link
Owner

@EvilBeaver EvilBeaver Oct 4, 2025

Choose a reason for hiding this comment

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

раньше влияние этой ошибки вылезало ли где-нибудь

нет, не сталкивался

Предложение: пофиксить DataType.Object, а COM-серверы пусть сами разбираются с тем, что пришло.

Я вообще мало что понял в ошибке, уверен ты знаешь лучше меня

@EvilBeaver
Copy link
Owner

@Mr-Rm прости за задержку, я довольно надолго выпал. Что с этим PR? Его вливать, не вливать, надо разрешить какие-то вопросы?

@Mr-Rm
Copy link
Collaborator Author

Mr-Rm commented Oct 14, 2025

(Прошу прощения, я сам отключался и пока непонятно, надолго ли)
К #1588 добавилась проблема с возвратом значений Неопределено из COM
Этот PR можно влить, а с возвратом разобраться отдельно.

@EvilBeaver EvilBeaver merged commit b6d2874 into EvilBeaver:latest Oct 20, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants