Commit Graph
858 Commits
Author SHA1 Message Date
Stephen Toub 76b5b76ceb Enable IDE0074 (Use compound assignment) (#70402) 2022-06-08 21:23:35 -07:00
Adeel Mujahid 4141913109 Fix typos (#69011) 2022-05-07 11:55:53 -07:00
Viktor Hofer 24cabc6eb0 Update solution files to include missing deps (#68668) 2022-05-02 20:14:05 +02:00
Viktor HoferandJeremy Barton ba055bd94e Minimize the build graph by deleting unnecessary references (#68603)
* Minimize the build graph by deleting references

Minimizing projects' dependency graph. There are tons of unnecessary
Reference and ProjectReference items which aren't required anymore as
the referenced projects became full facade assemblies. Removing those
from a leaf's graph makes the graph smaller and therefore the project's
evaluation and build faster.

* Update src/libraries/System.Net.Quic/ref/System.Net.Quic.csproj

Co-authored-by: Jeremy Barton <[email protected]>

* Update Versions.props

Co-authored-by: Jeremy Barton <[email protected]>
2022-04-28 15:04:26 +02:00
Eric Erhardt 18be907176 Change Nullable to default to enable in libraries src and ref projects (#68102)
* Change the default Nullable to enabled for src projects

* Set Nullable=enable as the default for ref projects

* Fixup merge conflicts

* Disable nullable on shim projects and EventLog.Messages

* Set Nullable to blank on EventLog.Messages

This way no CodeAnalysis attributes are emitted into the assembly.
2022-04-25 11:15:37 -05:00
Stephen Toub 4db986ef65 Use generic math to dedup Enumerable.Sum/Average (#68226)
* Use generic math in Enumerable.Sum/Average

* Address PR feedback
2022-04-20 16:11:41 -04:00
Stephen Toub f2f4bba80a Use generic math to dedup Enumerable.Min/Max (#68183)
* Use generic math to dedup Enumerable.Min/Max

* Address PR feedback
2022-04-20 16:11:30 -04:00
madelson d9b8a09041 Avoid pre-allocating large arrays in some scenarios for Enumerable.Chunk (#67210)
* Avoid pre-allocating large arrays in some scenarios for Enumerable.Chunk().

Fix #67132

* Switch Chunk() to use List-based implementation.

See discussion here:
https://github.com/dotnet/runtime/pull/67210#discussion_r836561697

* Address feedback from https://github.com/dotnet/runtime/pull/67210/files
2022-04-04 12:59:23 +01:00
Marek Safar 6a889d2342 Enable CA1822 (Mark members as static) analyzer (#66333) 2022-03-25 12:06:33 +01:00
Günther FoidlandStephen Toub 466b0f66aa Use C# 10's enhanced struct initialization features (#63131)
* Use C# 10's enhanced struct initialization features

* Addressed usages

* Remove #pragmas

* Fixed build

Cf. https://github.com/dotnet/runtime/pull/63131#discussion_r812406673

* Update src/libraries/Common/src/System/Collections/Generic/EnumerableHelpers.Linq.cs

Co-authored-by: Stephen Toub <[email protected]>
2022-03-15 09:35:23 -04:00
Elinor Fung a0635832f1 Rename DllImportGenerator project to LibraryImportGenerator (#66029) 2022-03-03 22:17:23 -08:00
Viktor Hofer 7671b5084a Use TargetFramework singular for tests
Use TargetFramework instead of TargetFrameworks property whenever a
test project targets a single target framework only.
This avoid unnecessary outer builds and evaluations and makes the build
faster.
2022-02-24 12:32:04 +01:00
Viktor Hofer febaf76743 Fix slngen.proj and update solution files (#65711)
* Fix slngen.proj

The SolutionName property is defined by the SDK and hence the condition was always true. Also the star (*) didn't expand when using the ValurOrDefault msbuild function. Fixing this by using a different name `SolutionNameOverride` and avoiding the ValueOrDefault msbuild function.

* Update solution files

Updating the solution files as those changed because of
microsoft/slngen@cb57e28 and apparently the solution files never were
updated.
2022-02-22 17:18:54 +01:00
WraithandVlad Brezae ddb22ef2ac Remove S.R.CS.Unsafe and Intrinsify Unsafe (#64861)
* private assemblies moved from Internal to System Runtime.CompilerServices

* reformat existing unsafe vm intrinsics

* implement Copy, CopyBlock, CopyBlockUnaligned, InitBlock, InitBlockUnaligned, Unbox, Add, Subtract, SubtractByteOffset

* remove System.Runtime.CompilerServices.Unsafe il project and replace with forward only cs project

* change all ilproj references to csproj

* remove nativeaot Unsafe

* add conditional package reference for S.R.CS.Unsafe on netcoreapp 6.0

* regenerate solutions

* mono interp

* [mono][interp] Implement Copy and Unbox intrinsics

* [mono][jit] Implement Copy and Unbox intrinsics

Co-authored-by: Vlad Brezae <[email protected]>
2022-02-19 21:50:14 -08:00
Viktor Hofer 20e8f905d0 Don't use Targets* helper properties in libs (#64500)
* Don't use Targets* helper properties in libs projs

This change makes it possible to migrate 200+ (ref+src) projects to use
TargetFramework instead of TargetFrameworks which avoids the additional
outer build evaluation and invocation which ultimately makes the overall
build faster.

Targets* properties (i.e. TargetsWindows, TargetsAnyOS, TargetsUnix,
etc.) rely on the TargetFramework property which usually are set
inside a project. The TargetFramework property is only
available before a project specifies it if it's explicitly set in a props
file or if the project is cross-targeting and the outer-build dispatches
into the inner-build. During the dispatch, the TargetFramework property
is passed in as a global property.

Until now that behavior wasn't a problem because every libraries project
cross-targeted (by setting the TargetFrameworks property) even though
many only include a single TargetFramework (i.e. NetCoreAppCurrent).

To allow projects to use the TargetFramework property instead of
TargetFrameworks, the Targets* helper properties can't be calculated
anymore early in a props file as the TargetFramework property isn't set
at that time.

In general, the guidance by the SDK/msbuild team is to not read from the
TargetFramework property before the project sets it
(in a property group). That effectively means that the TargetFramework
property shouldn't be used in props files at all.

Therefore these helper properties can't be used anymore for property
conditions and I'm replacing their usage with TargetPlatformIdentifier
comparisons for both properties and items.
In nearly all cases, the Targets* helper properties can be replaced with
TargetPlatformIdentifier checks on items and in the few cases where
TargetsUnix or TargetsLinux marks multiple tfms as compatible, the exact
tfms must be used instead for the TargetPlatformIdentifier comparison.

Whenever a project needs to condition properties on the platform, I'm
first setting the TargetPlatformIdentifier the same way the SDK sets it
so that the SDK later doesn't need to set it again to avoid the
additional expensive msbuild function call.

* Use TargetFramework singular to avoid outer builds

Use TargetFramework instead of TargetFrameworks property whenever a
projects only targets a single target framework. This avoid unnecessary
outer builds and evaluations and makes the build faster.
2022-02-12 13:07:16 +01:00
Stephen Toub e5faab09dd Improve perf of Enumerable.Sum/Average/Max/Min for arrays and lists (#64624)
* Improve perf of Enumerable.Sum/Average/Max/Min for arrays and lists

It's very common to use these terminal functions for quick stats on arrays and lists of values.  Just the overhead of enumerating as an enumerable (involving multiple interface dispatch) per iteration is significant, and it's much faster to directly enumerate the contents of the array or the list.  In some cases, we can further use vectorization to speed up the processing.

This change:
- Adds a helper that does a fast check to see if it can extract a span from an enumerable that's actually an array or a list.  It could be augmented to detect other interesting types, but `T[]` and `List<T>` are the most relevant from the data I've seen, and we can fairly quickly do type checks to get the most benefit for a small amount of cost.
- Uses that helper in the int/long/float/double/decimal overloads of Sum/Average/Min/Max to add a span-based path.
- Vectorizes Sum for float and double
- Vectorizes Average for int, float, and double (the latter two via use of Sum)

* Address PR feedback
2022-02-04 13:49:34 -05:00
Stephen Toub 096c8d55d5 Add array-fast path in Enumerable.Min/Max(int/long) (#64470)
In looking through usage data, it's pretty common to call Enumerable.Min/Max with an array.  At the cost of a type check when the source isn't an array, we can speed up the cases where it is, at a minimum by avoiding interface dispatch and in the best case by vectorizing.
2022-01-31 11:52:27 -05:00
Eirik Tsarpalis 61d603f506 Ensure MaxBy/MinBy return first element if all keys are null. (#61364) 2021-11-09 16:30:26 +00:00
Andrii Kurdiumov 5588f94924 Remove usused rd.xml files (#59201)
Closes #51112
2021-09-16 16:53:54 -06:00
Eirik Tsarpalis 03d92024f9 Add missing System.Linq API docs (#59038) 2021-09-14 15:22:41 +01:00
Viktor Hofer 36b6247cc7 Update solution files for correct ordering of elements (#58655)
With the newest udpate of slngen, the order of elements (configuration, folders, etc.) is in sync with how Visual Studio arranges them.
Also the order is now deterministic.

Based on that, updating all solution files to have the correct ordering of elements. This change also unblocks adding CI protection for
making sure that solution files are up-to-date in regards to their dependencies as slngen is now generating the files deterministically.
2021-09-04 00:16:15 +02:00
MaledongandMaledong 63f6461600 Extend test coverage for Enumerable.Any (#57550)
Co-authored-by: Maledong <[email protected]>
2021-08-18 14:03:26 +01:00
Eric Erhardt 577d079a72 Move ILLink.LinkAttributes to shared and support NullabilityInfoContext with trimming nullability attributes (#56475)
* Copy ILLink.LinkAttributes from mono to shared.

* Update ILLink.LinkAttributes that are now shared between mono and coreclr

- Move IntrinsicAttribute to mono only
- Introduce feature switches for NullabilityInfoContext and AggressiveAttributeTrimming
- Minor other cleanup

* Respect the NullabilityInfoContext.IsSupported feature switch in NullabilityInfoContext.

* Document new feature switches

* Add trimming tests for NullabilityInfoContextSupport

* Move NonVersionableAttribute to mono-only

* Fix Linq tests now that the ExtensionAttribute isn't being trimmed all the time on mono WASM
2021-07-30 14:07:01 -05:00
Viktor Hofer a6b9a63f35 Update libraries solution and NuGet.config files (#56430)
* Update slngen and invocation

* Update NuGet.config files

* Update solution files with slngen
2021-07-28 18:44:17 +02:00
Eirik Tsarpalis ebba1d4acb add missing documentation from #47231. (#54837) 2021-07-03 20:40:58 +03:00
Stephen Toub 6fdb82aea9 Reduce overhead of Enumerable.Chunk (#54782)
Avoid passing the array by ref and yielding inside the loop, which defeat various optimizations (e.g. bounds checking elimination).
2021-06-28 10:42:53 -04:00
Eirik Tsarpalis dbb05eba3b Fix MinBy and MaxBy handling of empty sources (#53544)
Addresses a bug where the empty source behaviour
is determined by the key type rather than the source type.
2021-06-02 08:56:50 +03:00
Levi Broderick b759ac9716 Expose Array.Clear(Array) as public API (#53388) 2021-05-27 21:08:53 -07:00
6ca3d9105d Shift Most of Wasm AOT test build to helix (#48226)
Since AOT'ing each test suite takes between 3-9 min, we need to shift the burden over to helix.

## This is done by:
1. building the test assemblies on the build machine
   - the wasm part of the build is not executed on the build machine,
      because it has the AOT build part
2. Zip up the test assembly+friends, *and* any bits required to run the wasm
    app build for that on helix (eg. emsdk, wasm app targets, cross compiler etc)
3. Send all this to helix, and use a custom `aot-build.proj`
     - which recreates all the build inputs for the `WasmBuildApp` target
        using the paths for the assets on helix
     - then we can run `WasmBuildApp` for the build, resulting in a wasm app
       bundle.
4. Run the tests!

- We already have the bits required for building wasm apps on helix, supported
for `Wasm.Build.Tests`, which we can use here too.

## Trimming:

- Since, AOT can be so expensive, we use `EnableAggressiveTrimming=true`(EAT), but
   that means that we could have issues due to trimming.
- And it can sometimes be unclear whether the build/test failures are due to trimming
     or AOT.

- Because these builds+test runs are different from other builds, owing to the
   "build partially on helix" step, a normal EAT build would not be the same as 
- to help with testing this, we add two lanes to `runtime-staging`:
   - `*_Mono_AOT`: builds AOT+EAT on helix
   - `*_Mono_EAT`: builds EAT, on helix
      - this is required because we want to run almost the same kinda
         build: 1. build test assembly; *2. send to helix; 3. build wasm app;* 4. run tests

- This should effectively mean that we can see which errors might be due to EAT, and
   which are clearly because of EAT+AOT.

Co-authored-by: Steve Pfister <[email protected]>
Co-authored-by: Marek Safar <[email protected]>
Co-authored-by: Mitchell Hwang <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
2021-04-21 20:58:25 -04:00
Eirik TsarpalisandStephen Toub abd01f5440 Implement Enumerable.*By methods (DistinctBy, ExceptBy, IntersectBy, UnionBy, MinBy, MaxBy) (#50335)
* Implement Enumerable.*By operators

* apply feedback

* Update src/libraries/System.Linq/src/System/Linq/Distinct.cs

Co-authored-by: Stephen Toub <[email protected]>

Co-authored-by: Stephen Toub <[email protected]>
2021-04-09 22:32:27 +01:00
Eric Erhardt 349abefb28 Rename ILLinkTrim files to ILLink.Descriptors (#50216)
* Rename ILLinkTrim files to ILLink.Descriptors.

Fix #37651
2021-03-26 15:22:38 -05:00
kronicandkronic 62170c1147 remove repetitions ';' (#50236)
Co-authored-by: kronic <[email protected]>
2021-03-25 20:59:08 -04:00
Stephen Toub 0817e748b7 Seal internal types in libraries (#50225) 2021-03-25 20:50:33 -04:00
Foxtrek_64andEirik Tsarpalis 122c438e09 Allow for specify return value on System.Linq.Enumerable.*OrDefault methods (#48886)
* Fix #20064

* Add API to ref assembly

* Make overloads with defaultValue not nullable

* Add unit tests, simplify implementation

* Add LastOrDefault tests

* Add Queryable tests

* Additional tests. Reformatting TryGet Methods.

* Update src/libraries/System.Linq.Queryable/tests/FirstOrDefaultTests.cs

* Apply suggestions from code review

Co-authored-by: Eirik Tsarpalis <[email protected]>

* Fix ref methods

* Further adjust nullability

* Fix more nullables

* fix failing tests

* Restore coding style

Co-authored-by: Eirik Tsarpalis <[email protected]>
2021-03-18 11:36:40 +00:00
Stephen Toub 2ee54f78dd Replace LINQ's custom Set with HashSet (#49591) 2021-03-15 09:02:57 -04:00
Eirik TsarpalisandStephen Toub f7308f03ed Apply optimizations and fixes to Enumerable.Take(Range) (#48634)
* optimize Take(Range) for countable enumerables

* Implement TakeLast over Take(Range)

* Implement SkipLast over Take(Range)

* remove unneeded checked increment

* fix typo in tests

* remove ToLookup inputs from NonEnumeratedCount tests

work around an xunit issue binding inputs with nested
generics to generic theories.

* remove leftover code

* Revert "remove ToLookup inputs from NonEnumeratedCount tests"

This reverts commit 6d160f618c54abb77c602840a5ecd359477468d4.

* try debugging test failure

* remove ToLookup inputs from NonEnumeratedCount tests

work around an xunit issue binding inputs with nested
generics to generic theories.

* Revert "try debugging test failure"

This reverts commit d7b11dab001b82cc533449c7f23e2bb90ec2515d.

* Update src/libraries/System.Linq/src/System/Linq/Take.cs

Co-authored-by: Stephen Toub <[email protected]>

* eliminate redundant yield breaks

* remove accidentally reverted change

Co-authored-by: Stephen Toub <[email protected]>
2021-03-01 13:56:13 +00:00
Stephen Toub 831c061e03 Add new MemoryExtensions.SequenceEqual overloads (#48677)
* Add new MemoryExtensions.SequenceEqual overloads

* Use MemoryExtensions.SequenceEqual in Enumerable.SequenceEqual

* Use MemoryExtensions.SequenceEqual in a few more places
2021-02-26 14:21:44 -05:00
Stephen Toub 24f1acda4c Special-case Enumerable.SequenceEqual for byte[] (#48287) 2021-02-22 20:43:50 -05:00
Dixin c63f06cd16 Add LINQ APIs for Index and Range (#28776) (#48559)
* Implement dotnet/runtime#28776: Implement LINQ APIs for index and range.

* Implement dotnet#28776: Implement LINQ APIs for index and range.

* Implement dotnet#28776: LINQ APIs for index and range.

* Implement dotnet#28776: LINQ APIs for index and range.

* Implement dotnet#28776: LINQ APIs for index and range.

* Implement dotnet#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Code review update.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Code review update.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Code review update.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update ElementAt, keep the original behavior.

* Implement dotnet#28776: LINQ APIs for index and range. Update ElementAt, keep the original behavior.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update ElementAt, keep the original behavior.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Add unit tests for ElementAt, ElementAtOrDefault.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update unit tests.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update unit tests.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update unit tests.

* Implement dotnet/runtime#28776: LINQ APIs for index and range. Update for merge.

* Implement #28776: LINQ APIs for index and range. Update unit tests.
2021-02-22 13:43:14 +00:00
Eirik Tsarpalis d68754424e Add Enumerable.TryGetNonEnumeratedCount (Implements #27183) (#48239)
* implement Enumerable.TryGetEnumeratingCount

* address feedback

* update consistency tests

* Replace EnumerableHelpers.TryGetCount with new method

* Rename to method name as approved

* make method is renamed in all projects
2021-02-15 17:15:15 +00:00
Stephen Toub 6c8f9fff6a Follow-up to Enumerable.Min/Max Comparer<T>.Default optimization (#48289)
I didn't notice the same pattern was employed in the `Func<TSource, TResult>` overloads, so changing them, too.
2021-02-15 09:06:31 -05:00
Stephen Toub 65b923ac88 Optimize Enumerable.Min/Max<T> with Comparer<T>.Default intrinsic (#48273) 2021-02-14 08:45:54 -05:00
Robert Andersson 515bfafb35 Add System.Linq Chunk extension method (#47965)
* Add System.Linq Chunk extension method

Fix #27449

* Use explicit types instead of type inference

* Seperate inner and outer loop

* Rename parameter maxSize to size

* Add missing license header

* Remove Chunk.SpeedOpt.cs

* Add tests to verify Chunk works after mutations

* Add/remove before getting enumerator in tests

* Test content of chunk method for IQueryable<T>
2021-02-10 19:41:59 +00:00
Stephen Toub 835f5b4fb8 Enable size-optimized LINQ build for Browser (#47918)
* Enable size-optimized LINQ build for Browser

Re-enable the size-optimized variant of LINQ and use it for the Browser build of the library.

* Opt more targets into size optimizations, per PR feedback
2021-02-09 09:30:41 -05:00
6fb9985a53 More arities for tuple returning zip extension method (#47147)
* Implementation.

* ref source

* Tests for Zip3.

* Implement queryable.zip3

* ref source for Queryable.Zip3

* Test for Queryable.Zip3

* xml doc

* Add to ILLink supression.

* Fix argument name in copied tests.

* PR feedbacks

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Eirik Tsarpalis <[email protected]>

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Eirik Tsarpalis <[email protected]>
2021-01-19 15:32:24 +00:00
Rikki Gibson 6cb16e12fd Remove unnecessary suppression (#44811) 2020-11-18 15:16:49 +00:00
Viktor Hofer ed295782bf Add workflow to update solution files with SlnGen and update them initially (#44703)
* Add slngen infra

* Update all solution files
2020-11-17 18:23:30 +01:00
Charles Stoner c1a21a0319 Resolve warnings for assignment or explicit cast of possibly null type parameter value (#43925) 2020-11-09 20:11:57 -08:00
Krzysztof Wicher c871e237b0 Fix/remove TODO-NULLABLEs (#44300)
* Fix/remove TODO-NULLABLEs

* remove redundant !

* apply Jozkee's feedback

* address feedback
2020-11-09 13:07:15 +01:00
Layomi Akinrinade 994dca6f34 Add granular suppressions for linker warnings (#40691)
* Add granular suppressions for linker warnings

* Add suppressions for mono SPC

* Misc additions

* Add suppressions for Debug config

* Fix Android xml file

* Include System.ComponentModel.Annotations suppressions

* Add suppressions for System.Security.Cryptography.X509Certificates on Linux

* Fix TargetOs exists check

* Add IL2077 to System.Security.Cryptography.X509Certificates on Android

* Generalize some System.Security.Cryptography.X509Certificates suppressions to 'NonWindows'

* Remove ref to catch-all System.Security.Cryptography.X509Certificates file

* Misc clean up and some feedback

* Use ILLinkDirectory in CreateRuntimeRootILLinkDescriptorFile.targets

* Update paths for directories

* Set TargetPath as part of include

* Delete bin-placing TODO

* Include more xml files during per-library run

* Include more xml files during per-library run, pt 2

* Include more xml files during per-library run, pt 3

* Try including System.ComponentModel.Annotations based on BuildingNETCoreAppVertical

* Switch to BuildAllConfigurations

* Include xml extension in file paths

* Remove version number from assembly suppression files

* Delete ILLink.Suppressions.xml

* Try removing IL2035 nowarn

* Remove version from Microsoft.VisualBasic.Core assemly name
2020-09-30 09:06:25 -05:00