-
Notifications
You must be signed in to change notification settings - Fork 19
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
Upgrade .NET version and harmonize versions of referenced packages #237
base: main
Are you sure you want to change the base?
Conversation
This commit makes several changes to the .NET projects and their dependencies. The main changes include upgrading the projects to target newer versions of .NET (.NET 6.0, 7.0 and 8.0), and harmonize versions of referenced packages. The package versions are now based on the target framework. The git diff shows the removal and addition of PackageReference tags that ensure packages have different versions based on the targeted framework. For example, `Microsoft.NET.Test.Sdk` is upgraded from 16.9.4 to 17.9.0 if the target framework is not net6.0. In addition, the commit modifies the projects to produce an executable as the output type instead of a class library and removes constructors in exception classes which are obsolete from .net8 onwards (dotnet/docs#34893). Finally, some refactoring is done to comply with the latest .net requirements regarding value and ref types. Overall, this commit ensures the projects align with the latest .NET platform, benefiting from performance improvements and other advancements, while keeping the project dependencies clean and consistent.
Thanks for submitting the PR @devtekve. Changing target version is a breaking change. I'm ok with doing that but we'll need to think about all breaking changes we want to make and bundle them into a single release. And before doing an upgrade I would like to release already implemented features to make sure we don't block anyone waiting for them. And couple of notes about the update itself:
Overall, I think we need to bump the version to .net 8 but I'm not sure that right now is the best moment to do it. If you're up to it, let's leave your PR open and update it to only target .NET 8. And we can merge it after doing all necessary preparations. |
Definitely up for it. Only reason I added the multiple frameworks was to keep it somewhat backwards compatible. But I'd simply target .net8.0 as it's the latest LTS. Also I am agree it's a breaking change, but in the other hand, the other runtimes are no longer supported. (Well, .netstandard2.1 is, but I found one bug regarding passing value types as references... latest .net8 is against it and yet .netstandard2.1 seems happy with it ) We can leave it open and polish it, get it ready and properly flagged as breaking change... to be honest, none of the PRs I made had the expectation of being merged as is, I expected some discussion since I am brand new to the project and still getting the hang of it but I'm really loving what you've done here hahahah |
This commit removes the targeting of .NET 7.0 and 6.0 in all projects, and updates them to target .NET 8.0 only. It also updates the versions of package references according to this change.
…ss (we should maybe format it once, as it is inconsistent, but doesn't really matter much)
<PackageReference Include="EfficientDynamoDb" Version="0.9.2-alpha.0.4" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1"> | ||
<PackageReference Include="AWSSDK.Core" Version="3.7.303.28" /> | ||
<PackageReference Include="EfficientDynamoDb" Version="0.9.15" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reference the package from local instead of a versioned package here? or doesn't matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EfficientDynamoDb.Credentials.AWSSDK
should be updated separately after the main project is released. It will require a newly released version of EfficientDynamoDb because it's based on dotnet 8. Since it's coming from nuget we need to release the main library first.
So I'd suggest reverting changes to this project and bringing them back in another PR after the release.
@firenero I've updated the PR removing many whitespaces changes on the csprojs, and removed the multiple .net frameworks from the targets, leaving only .net8 |
<PackageReference Include="EfficientDynamoDb" Version="0.9.2-alpha.0.4" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1"> | ||
<PackageReference Include="AWSSDK.Core" Version="3.7.303.28" /> | ||
<PackageReference Include="EfficientDynamoDb" Version="0.9.15" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EfficientDynamoDb.Credentials.AWSSDK
should be updated separately after the main project is released. It will require a newly released version of EfficientDynamoDb because it's based on dotnet 8. Since it's coming from nuget we need to release the main library first.
So I'd suggest reverting changes to this project and bringing them back in another PR after the release.
private JsonReaderState _initialReaderState; | ||
private DdbEntityReadStack _state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converters are supposed to be thread-safe because they are cached across multiple calls. This state will be shared with multiple callers that makes it impossible to use the converter from multiple threads.
|
||
_state = reader.State; | ||
var originalSpan = new ReadOnlySpan<byte>(_state.Buffer, _state.BufferStart, _state.BufferLength); | ||
reader = new DdbReader(originalSpan[offset..], reader.JsonReaderValue.IsFinalBlock, ref _initialReaderState, ref _state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you were getting compilation errors here that "forced" you to create fields. I think the proper solution would be remove the creation of the new DdbReader
struct and instead reset the reader.JsonReaderValue
field:
reader.JsonReaderValue = new(originalSpan[offset..], reader.JsonReaderValue.IsFinalBlock, initialReaderState);
reader.State.BufferStart += offset;
reader.State.BufferLength -= offset;
ref initialReaderState, ref reader.State); | ||
|
||
var span = originalSpan[offset..]; | ||
reader = new DdbReader(span, reader.JsonReaderValue.IsFinalBlock, initialReaderState, reader.State); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to another case, it's better to reset the reader.JsonReaderValue
field instead of recreating the whole DdbReader
struct.
State = readStack; | ||
} | ||
|
||
internal DdbReader(ReadOnlySpan<byte> buffer, bool isFinalBlock, JsonReaderState readerState, DdbEntityReadStack readStack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After previous changes, there won't be a need for constructor without ref params because it won't be used.
@@ -118,7 +118,7 @@ private DdbConverter GetOrAddCachedConverter(Type propertyType, Type? converterT | |||
return converter; | |||
|
|||
var nullableConverterType = typeof(NullableValueTypeDdbConverter<>).MakeGenericType(type); | |||
return (DdbConverter) Activator.CreateInstance(nullableConverterType, converter); | |||
return Activator.CreateInstance(nullableConverterType, converter) as DdbConverter ?? throw new DdbException("Can't create nullable value type converter."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my understanding, is there any other reason for this change except having a nicer exception message?
This commit makes several changes to the .NET projects and their dependencies. The main changes include upgrading the projects to target newer versions of .NET (.NET 6.0, 7.0 and 8.0), and harmonize versions of referenced packages.
The package versions are now based on the target framework. The git diff shows the removal and addition of PackageReference tags that ensure packages have different versions based on the targeted framework. For example,
Microsoft.NET.Test.Sdk
is upgraded from 16.9.4 to 17.9.0 if the target framework is not net6.0.In addition, the commit modifies the projects to produce an executable as the output type instead of a class library and removes constructors in exception classes which are obsolete from .net8 onwards (dotnet/docs#34893).
Finally, some refactoring is done to comply with the latest .net requirements regarding value and ref types.
Overall, this commit ensures the projects align with the latest .NET platform, benefiting from performance improvements and other advancements, while keeping the project dependencies clean and consistent.
Benchmark
.net7.0
.net8.0
Note:
I don't have available a proper x86 setup where I could run the benchmark for the older dotnet versions, so I can't provide a proper comparison between current .netstandard2.1 and latest .net8. The improvement is still in line with the comparison against aws sdk, which also sees improvements by bumping the framework. So I see an overall performance gain.
If anyone is able to, can you please run the benchmarks on your system to see how it compares against the current version used? thank you :)