Repository navigation
Conversation
|
|
|
|
|
Hm will add a parameter into the constructor to enable nullbased(default) and 1-based enumerations from list or similar to be used. So StorageExtension would then tell it 1-based enumeration because if we have lines numbered in vs editor they are starting by 1 and so the user would provide its values 1 based. |
32f6ad2 to
9f99304
Compare
Overloads allows providing specific lines for the return. Useful in cases its for example txt file, which has no ISerializer like for Json or xaml format.
072e76f to
779a278
Compare
|
@jeromelaban could someone take a look and tell if there is anything left to do? |
| /// An enumerable collection of strings, where each string represents the items within a specified range. | ||
| /// If a range is invalid (e.g. start is greater than the last one), an empty string is returned for that range. | ||
| /// </returns> | ||
| public static IEnumerable<string> SelectItemsByRanges(this IEnumerable<string> source, IEnumerable<(int Start, int End)> ranges, bool isNullBased = true) |
There was a problem hiding this comment.
@kazoo maybe you would see a more serialization friendly way than IEnumerable<(int,int)> here? In my Gallery App, I defined a "Lines" type with this propertys like this:
public record Lines
{
public int Start { get; init; }
public int End { get; init; }
}But maybe you would know a better way or setup to get the same result?
I would see a usecase for non serialization friendly files to be better handle able using the IStorage Extensions.
… to extension based The functionallity should extend the capabilities of IStorage, not introduce a change requirement for Implementing Classes of course
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new overload method for reading package files with line range specification, allowing developers to extract specific lines from text files without needing to handle streams directly. The changes provide more granular control over file reading operations while improving documentation.
- Added
ReadLinesFromPackageFileextension method with line range selection capability - Introduced enumerable extension utilities for range-based item selection
- Enhanced documentation with missing XML comments and return type descriptions
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.Extensions.Storage/Uno.Extensions.Storage.csproj | Added Uno.Core package dependencies for enumerable extensions |
| src/Uno.Extensions.Storage/StorageExtensions.cs | Added new overload method for reading specific lines from package files |
| src/Uno.Extensions.Storage/GlobalUsings.cs | Added global using for new enumerable extensions namespace |
| src/Uno.Extensions.Storage/EnumerableExtensions.string.cs | New utility class providing range-based selection methods for string collections |
| src/Uno.Extensions.Storage.UI/HostBuilderExtensions.cs | Fixed missing XML documentation return tag |
| src/Uno.Extensions.Storage.UI/GlobalUsings.cs | Added global using for enumerable extensions namespace |
| src/Uno.Extensions.Storage.UI/FileStorage.cs | Added missing inheritdoc comments for interface implementations |
| { | ||
| string fileContent = await storage.ReadPackageFileAsync(filePath) ?? string.Empty; | ||
|
|
||
| if (!(lineRanges.Any())) |
There was a problem hiding this comment.
[nitpick] The negation operator should be applied directly to the method call for better readability. Use !lineRanges.Any() instead of !(lineRanges.Any()).
| if (!(lineRanges.Any())) | |
| if (!lineRanges.Any()) |
| max: list.Count); // Ensure 'End' does not exceed available lines | ||
|
|
||
| return list.Skip(startIndex) | ||
| .Take(endIndex - startIndex) |
There was a problem hiding this comment.
The Take operation should use (endIndex - startIndex + 1) to include the end index line, since the documentation states ranges are inclusive on both ends.
| .Take(endIndex - startIndex) | |
| .Take(endIndex - startIndex + 1) |
| public static string GetItemsWithinRange(this IEnumerable<string> source, (int Start, int End) range, bool isNullBased = true) // TODO: Consider to limit int to min 0 value instead of implicit allowing negative. | ||
| { |
There was a problem hiding this comment.
Remove the TODO comment from production code. Either implement the validation for negative values or create a proper issue to track this enhancement.
| public static string GetItemsWithinRange(this IEnumerable<string> source, (int Start, int End) range, bool isNullBased = true) // TODO: Consider to limit int to min 0 value instead of implicit allowing negative. | |
| { | |
| public static string GetItemsWithinRange(this IEnumerable<string> source, (int Start, int End) range, bool isNullBased = true) | |
| { | |
| if (range.Start < 0 || range.End < 0) | |
| { | |
| return string.Empty; | |
| } |
Co-authored-by: Copilot <[email protected]>
|
@kazo0 could you please check which of the copilot change requests are valid? I had it suggesting false logic also while writing and it was constantly changing its advise, so it would be great to have some non-AI check this before just accepting those... |
|
@kazo0 small update for this PR here: I reworked and fully xUnit test covered my Extension on my SampleApps Repo branch here: But I am not finding the right way/place to add this to a Uno Test Project and assuming you wouldn't want to add another Test Project for this? Could you maybe introduce me to the place you want this to be added? Or let me know, if Uno don't want to add non-Secret-Vault Extensions to be added to their Storage Extensions, then I would at some point in the future simply add this package under my own name to nuget, so you dont have more Work with this 🤷 But infinity-duration pending PR would be nothing I would want and could think of, you neither 👍 |
GitHub Issue (If applicable): closes #2710 #2630 #unoplatform/uno#19088
PR Type
What kind of change does this PR introduce?
What is the current behavior?
only Json or Xml formats are having existing ISerializers, so when it comes to native file formats like txt or similar, the string from the existing function has get looped or a stream return would have to get considered.
Stream would then mean to pay attention to closing this stream again afterwards.
Storage Documentation almoast completly missing
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
not able to run tests because of runtimetests.csproj having 255.255.255.255 value and only uno.ui tests are documented. the linked readme file above does not even contain the header "supported" maybe to be fixed?
Screenshots Compare Test Runresults. => not possible because of above problemFeature Template is not applyable, since its no control feature, but yes, I added Usage Samples for all IStorage Functions available
Other information
please tell how to edit ReleaseNotes suitable, did not found a guide in the docs to this
Internal Issue (If applicable):