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

Introduce #!set magic command #2654

Merged
merged 8 commits into from
Jan 30, 2023
Merged

Introduce #!set magic command #2654

merged 8 commits into from
Jan 30, 2023

Conversation

colombod
Copy link
Member

@colombod colombod commented Jan 27, 2023

Implements #2652.

@colombod colombod linked an issue Jan 27, 2023 that may be closed by this pull request
@jonsequitur jonsequitur changed the title set magic command Introduce #!set magic command Jan 27, 2023
@jonsequitur
Copy link
Contributor

jonsequitur commented Jan 27, 2023

Additional test cases we'll want:

  • Is the behavior re: reference values consistent with #!share when --mime-type is specified?
  • What happens when --set-result is used specifying a variable that already exists within the current kernel? Should this be an error? Overwrite?

@@ -208,6 +209,194 @@ public static T UseLogMagicCommand<T>(this T kernel)
return kernel;
}

public static T UseSet<T>(this T kernel) where T : Kernel
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static T UseSet<T>(this T kernel) where T : Kernel
public static T UseSetMagicCommand<T>(this T kernel) where T : Kernel

Copy link
Contributor

Choose a reason for hiding this comment

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

This naming would be more informative and consistent but on second thought, I think this functionality should just be part of UseValueSharing. It's the same core functionality and there's no use case for enabling one and not the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved this as part of turning on ValueSharing, refactored some code to become reused (sendValue for example)

}
}

private static void HandleSetMagicCommand<T>(
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should be leveraging and/or refactoring the existing GetValueAndSendTo method.

#!share --from csharp x should be the same code path (after interpolation is done) as #!set --name x --value @csharp:x.

@colombod
Copy link
Member Author

Additional test cases we'll want:

  • Is the behavior re: reference values consistent with #!share when --mime-type is specified?
  • What happens when --set-result is used specifying a variable that already exists within the current kernel? Should this be an error? Overwrite?

I think we should overwrite, same is already happening with running #!share. users will want to be able to refresh imported values.


set.SetHandler(cmdLineContext =>
{
HandleSetMagicCommand(kernel, cmdLineContext, fromResultOption, nameOption, fromValueOption, mimeTypeOption);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is also being used by #!share, a more generalized name for HandleSetMagicCommand would be clearer.

@colombod colombod marked this pull request as ready for review January 30, 2023 17:13
@colombod colombod merged commit 8fd25fa into dotnet:main Jan 30, 2023
@colombod colombod deleted the set_command branch January 30, 2023 17:14
@colombod colombod added the enhancement New feature or request label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#!set magic command
3 participants