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

Move into Shared SqlNotificationEventArgs.cs #1314

Merged

Conversation

lcheunglci
Copy link
Contributor

Relates to #1261. Merge the netcore version into shared src and update the reference in the csproj.

@lcheunglci lcheunglci changed the title Move into Shared SqlNotificationEventArgs Move into Shared SqlNotificationEventArgs.cs Oct 4, 2021
@Wraith2
Copy link
Contributor

Wraith2 commented Oct 4, 2021

Can this use init setters to avoid the fields entirely?

@lcheunglci
Copy link
Contributor Author

lcheunglci commented Oct 5, 2021

I just realized that C#9 introduced init-only setter. It's a pretty neat syntax to remove the fields and constructor. I'm down with that if it's ok with everyone.

@DavoudEshtehari DavoudEshtehari added the ➕ Code Health Changes related to source code improvements label Oct 5, 2021
@DavoudEshtehari DavoudEshtehari added this to the 4.0.0-preview3 milestone Oct 5, 2021
@cheenamalhotra
Copy link
Member

I just realized that C#9 introduced init-only setter. It's a pretty neat syntax to remove the fields and constructor. I'm down with that if it's ok with everyone.

We only need to ensure the scope of APIs does not change. i.e. Private setters should stay private and same for public.

@lcheunglci
Copy link
Contributor Author

lcheunglci commented Oct 5, 2021

I just tried to use the new init syntax

public SqlNotificationType Type { get; init; }
public SqlNotificationInfo Info { get; init; }
public SqlNotificationSource Source { get; init; }

and I got compiler errors for netcore and netfx projects. 1>D:\git\SqlClient\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs(23,48,23,52): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported

Then I found out that C#9 is only available in .NET5 and above and since the project is built using .net framework 4.6.1 and .net core 3.1, we won't be able to use init only setters.

@Wraith2
Copy link
Contributor

Wraith2 commented Oct 5, 2021

Thats a shame, thanks for checking.

@johnnypham
Copy link
Contributor

Both old files can be deleted too?

@lcheunglci
Copy link
Contributor Author

Both old files can be deleted too?

Thanks for catching that, I missed that for some reason. I usually merge netfx into netcore first, delete netfx version, update the ref in the netfx csproj verify it builds and then move it over to shared src and update the references before I do the doc path updates, and IDE fixes and when I commit it, it will automatically marks the one for netcore as rename, but somehow it got missed.

@cheenamalhotra cheenamalhotra merged commit 73919ca into dotnet:main Oct 14, 2021
@lcheunglci lcheunglci deleted the MergeShared-SqlNotificationEventArgs branch October 14, 2021 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
➕ Code Health Changes related to source code improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants