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

Null annotations and in string args #142

Merged
merged 5 commits into from
Jan 25, 2023

Conversation

GlebChili
Copy link
Member

Removes redundant in string parameters from the API surface and enables nullable annotations and nullable warnings as errors
for both GmodNET.API and core GmodNET.

Closes #141
Closes #84

@GlebChili GlebChili self-assigned this Jan 24, 2023
@GlebChili GlebChili added the pr-generate-docs-preview For labeled PRs, a live docs preview will be generated label Jan 24, 2023
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://ambitious-hill-0f19b7c03-142.westeurope.azurestaticapps.net

@SupinePandora43
Copy link
Member

This is cool, but what do you think about ReadOnlySpan<char> and ReadOnlySpan<byte> (utf8) ? Might improve performance in some scenarios.

Copy link
Member

@AaronJThompson AaronJThompson left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@GlebChili
Copy link
Member Author

@SupinePandora43 I like the idea about ReadOnlySpan, but I think it is a good idea to ship them as part of version 1.1.0. Open the issue, and I will also welcome PR from you.

Copy link
Member

@SupinePandora43 SupinePandora43 left a comment

Choose a reason for hiding this comment

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

I haven't been active lately (in general), I'll try to fix that

{
if (!String.IsNullOrEmpty(value))
if (!String.IsNullOrEmpty(value) && Msg is not null)
Copy link
Member

Choose a reason for hiding this comment

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

I think this is redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, but C# null checker is not satisfied otherwise.

@@ -20,11 +20,21 @@ internal Lua(IntPtr ptr)

public int Top()
{
if (top is null)
Copy link
Member

Choose a reason for hiding this comment

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

Can we not check it every call? Or is it eliminated by JIT?

Copy link
Member Author

Choose a reason for hiding this comment

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

JIT will eliminate checks after few iterations

Copy link
Member

Choose a reason for hiding this comment

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

I think we should check it. (Performance regressions)

Copy link
Member Author

Choose a reason for hiding this comment

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

gm_dotnet_managed/GmodNET/Startup.cs Outdated Show resolved Hide resolved
IModule current_module = (IModule)Activator.CreateInstance(t);
modules.Add(current_module);
gc_handles.Add(GCHandle.Alloc(current_module));
IModule? current_module = Activator.CreateInstance(t) as IModule;
Copy link
Member

Choose a reason for hiding this comment

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

Why it's nullable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Can you add ! somewhere to make it not nullable? 😅

Copy link
Member Author

@GlebChili GlebChili Jan 24, 2023

Choose a reason for hiding this comment

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

But why? We literally check if it is null in a next line. Let it be this way until Microsoft provide non-nulable guaranties for Activator (so until .NET 8, maybe?).

@SupinePandora43
Copy link
Member

SupinePandora43 commented Jan 24, 2023

@SupinePandora43 I like the idea about ReadOnlySpan, but I think it is a good idea to ship them as part of version 1.1.0. Open the issue, and I will also welcome PR from you.

I'll create few feature requests issues with ideas i came up with.
(Right now i simply can't code)

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://ambitious-hill-0f19b7c03-142.westeurope.azurestaticapps.net

Copy link
Member

@SupinePandora43 SupinePandora43 left a comment

Choose a reason for hiding this comment

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

LGTM

@GlebChili GlebChili merged commit a3708b6 into GmodNET:main Jan 25, 2023
@GlebChili GlebChili deleted the null-annotations-and-in-args branch January 25, 2023 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-generate-docs-preview For labeled PRs, a live docs preview will be generated
Projects
None yet
3 participants