32 Commits
Author SHA1 Message Date
Stephen Toub c256e409c9 More Corelib cleanup (dotnet/coreclr#26872)
* Remove unnecessary asserts

* Make several classes static

* Use is instead of as+null check

* Use T? instead of Nullable<T>

* more static classes

* Mark locals as const

* Merge declaration and initialization of some variables

* Remove unnecessary casts

* Remove unnecessary "unsafe"s

* Simplify several lambda expressions

* Remove redundant parentheses

* Remove redundant '== true'

* Remove redundant empty lines

* Simplify boolean comparison with '== false'

* Replace if-statement with return statement

* Use while for infinite loop

* Add static to all partial static class declarations

* Use ++/-- operator instead of assignment

* Use string.IsNullOrEmpty

* Use coalesce expression

* Simplify lazy initialization

* Use coalese expression

* Join string expressions

* Use regular string literal instead of verbatim string literal

* Optimize StringBuilder.Append calls

* Remove redundant assignment

* Remove unnecessary unsafe context

* Merge processor directives

* Use String.Equals instead of String.Compare

* Use Debug.Fail instead of Debug.Assert(false

* Remove Attribute suffix

* Use predefined type

* Use compound assignment

* Use while statement to create an infinite loop

* Remove redundant base ctor call

* Avoid using catch (Exception)

* Remove empty regions

* Span comparison to null

* Avoid unnecessary boxing of value type

* Expression is always equal to 'true'

* Remove unused method

* update coalesce assignment

* fix unsafe

* fix redundant parens

* Fix whitespace errors introduced

Signed-off-by: dotnet-bot <[email protected]>
2019-09-25 20:13:47 +02:00
Vladimir Sadov 88ac3856eb Do not use AllocateUninitializedArray in private array pools. (#26338)
User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.

Signed-off-by: dotnet-bot <[email protected]>
2019-08-27 01:24:57 +02:00
Stephen Toub 2f11eff09b Contribute to StyleCop SA1002 (semicolon spacing)
However, I'm not enabling the rule permanently, as it disagrees with VS IDE0055 about the spacing around semicolons at the end of empty while and for loops.

Because this also impacts `for (;;)` loops, I also searched and replaced those with `while (true)`, to standardize on that across the codebase.

Signed-off-by: dotnet-bot <[email protected]>
2019-08-26 13:56:53 +02:00
Stephen Toub 35d8ca894b Fix StyleCop warning SA1005 (single line comment spacing)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-22 20:21:18 +02:00
Stephen Toub e23c35f730 Fix StyleCop warning SA1024 (colon spacing)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-22 20:21:18 +02:00
Stephen Toub f83a8da0ce Fix StyleCop warning SA1002 (semicolon spacing)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-22 20:21:18 +02:00
Stephen Toub 5f38497e19 Remove unused usings from Corlib (dotnet/coreclr#26250)
* Fix IDE0065 (misplaced using)

* Fix IDE0005 (remove unnecessary usings)

Signed-off-by: dotnet-bot <[email protected]>
2019-08-20 19:45:30 +02:00
Stephen Toub 9595189a0a Fix IDE0054 (use compound assignment)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-18 07:01:54 +02:00
Stephen Toub 20adb69c73 Fix IDE0008 (use explicit type instead of var)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-18 07:01:54 +02:00
Stephen Toub 50d3fc69d8 Convert several static readonly byte[]s to ReadOnlySpan<byte> (#26138)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-13 21:35:04 +02:00
Stephen Toub d927c98e03 Contribute to IDE0059 (unnecessary assignment)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-13 21:35:04 +02:00
Stephen Toub d82bc555c9 Contribute to IDE0019 (use pattern matching) and IDE0066 (use switch expression)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-13 21:35:04 +02:00
Stephen Toub 9c3037fc59 Fix StyleCop warning SA1200 (cref prefixes)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-09 16:23:42 +02:00
Stephen Toub da2c1cde97 Re-enable StyleCop warnings SA1028 and SA1518 (trailing whitespace and blank lines) (#40113)
Mechanical/automated change.  The only manual changes were a) removing the two rules from the CodeAnalysis.ruleset file, b) removing spaces from one line of a .targets file that is used to generate a .cs file, and c) reverting the changes in a few test files where the naive replacement happened in the middle of a verbatim string where the whitespace actually mattered.

Signed-off-by: dotnet-bot <[email protected]>
2019-08-08 23:44:46 +02:00
Stephen Toub 3385433b60 Enable several StyleCopAnalyzers (dotnet/corefx#39921)
* Fix ordering of keywords in member signatures

* Add StyeCop.Analyzers

Most rules are disabled.  Many of them we'll want to leave disabled, however there are a handful it'll be good to enable over time.

* Use built-in type alias

* Fix straggling stylecop warnings in all configurations

* Replace tabs with spaces

Signed-off-by: dotnet-bot <[email protected]>
2019-08-03 20:55:40 +02:00
Tanner Gooding c471996c8b Updating Dragon4 to ensure the number buffer always provides a significant digit if one exists. (#25096)
* Updating Dragon4 to ensure the number buffer always provides a significant digit if one exists.

* Changing System.Number.RoundNumber to not round up floating-point numbers.

* Re-enabling the RealFormatterTestsBase CoreFX tests

* Updating Number.RoundNumber to take a isCorrectlyRounded parameter and to use IEEE compliant rounding for floating-point numbers.

* Change SinglePrecisionCustomFormat to 7, ensuring it matches the value used in netcoreapp2.1

Signed-off-by: dotnet-bot <[email protected]>
2019-07-01 23:01:13 +02:00
Vladimir Sadov 76dee58018 Using AllocateUninitializedArray in array pool (dotnet/coreclr#24504)
* Just use `new T[]` when elements are not pointer-free

* reduce zeroing out when not necessary.

* use AllocateUninitializedArray in ArrayPool

Signed-off-by: dotnet-bot <[email protected]>
2019-05-29 22:14:22 +02:00
Stephen Toub b31b703b89 Turn on nullability for all of Corelib (dotnet/coreclr#24497)
* Enable nullable at the project level

* Remove `#nullable enable` from individual files

Removes `#nullable enable` from almost all .cs files in System.Private.CoreLib. I left it only in the ~30 files (out of ~1480 that had it) that are mirrored to corefx, that are built into projects by corefx that don't yet set NullableContextOptions at the project level, and that use nullable annotations; otherwise, they'd break the corefx build.

Signed-off-by: dotnet-bot <[email protected]>
2019-05-10 10:51:17 +02:00
dotnet-maestro-bot ba4e9450aa Update BuildTools, CoreClr to preview4-03917-01, preview5-27618-71, respectively (master) (#24060)
* Update BuildTools, CoreClr to preview4-03917-01, preview5-27618-71, respectively

* Fix build errors

* Disable warning with pragma and linked issue

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:49:47 +00:00
Raz Friman 791139bead Remove unused offset calculation (dotnet/coreclr#23793)
Utf8Parser has a redundant calculation of date time offset.

Fix #21834

Signed-off-by: dotnet-bot <[email protected]>
2019-04-15 08:32:36 +02:00
Ludovic Henry 1271a16b46 Make GC.GetGCMemoryInfo public (dotnet/coreclr#23779)
* Make GC.GetGCMemoryInfo public

This is to be used to allow users to optimize memory consumption based
on what's available to the GC and on the system.

This is based on https://github.com/dotnet/corefx/issues/34631

* Address reviews

- Pass GCMemoryInfo struct to native in place of many arguments
- Make GCMemoryInfo.HeapSize and GCMemoryInfo.Fragmentation long in place of IntPtr

* Address reviews

- Mark GCMemoryInfo readonly

* Rearrange fields and match managed/native names

* Fix compilation

* Use getter shorthand

* Address API Design Review

https://github.com/dotnet/corefx/issues/34631#issuecomment-481358549

* Fix comments

* Fix comments

* Do everything in managed

* Address review

 - Remove unecessary [StructLayout.Sequential]
 - Remove "_" prefix for parameters variables

Signed-off-by: dotnet-bot <[email protected]>
2019-04-12 23:45:22 +02:00
Stephen Toub e5828e1a8d Nullable: System.Buffers (dotnet/coreclr#23619)
* Nullable: System.Buffers

* Address PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-04-09 13:23:12 -07:00
Tanner Gooding cde76c1521 Fixing a couple of issues in the Utf8Parsing/Formatting code (#23134)
* Fixing NumberToSingle and NumberToDouble to handle DigitsCount == 0

* Fixing Utf8Formatter.Float to transcode non ASCII bytes

* Responding to PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-03-12 22:42:53 +01:00
Filip Navara d14b15f502 Move Thread to shared CoreLib (dotnet/coreclr#22744)
* Move Thread to shared CoreLib

* Remove all local variables from Thread in shared code

* Remove duplicate checks

* Port back CoreRT changes needed for shared code

* Fix missing culture initialization in ThreadStart()

* Adjust for shared WaitHandle

Signed-off-by: dotnet-bot <[email protected]>
2019-02-28 22:41:40 +01:00
Grant 448fd6ac62 Make BitOperations public (CoreCLR) (dotnet/coreclr#22864)
* Make BitOps public

* Update name to BitOperations

* Change namespace to System.Numerics

* Fix file name

* Alphabetical

Signed-off-by: dotnet-bot <[email protected]>
2019-02-27 21:24:21 +01:00
Grant d91a227cba Consolidate implementation of Rotate and PopCount (dotnet/coreclr#22584)
* Perf: BitOps.LeadingZeroCount

* Remove redundant MSIL cast, conv.u8

* Use local functions for SoftwareFallback

* Target BIT32/64

Signed-off-by: dotnet-bot <[email protected]>
2019-02-14 23:00:36 +01:00
Grant 572d9928c0 Perf: Consolidate implementation of LeadingZeroCount (dotnet/coreclr#22497)
* Perf: BitOps.LeadingZeroCount

* CR fix

* CR fixes

* Optimization

* Revert

* Confirmed fix

* Simplify

* Return int

* Fixes

* Simplify

* CR fixes

* CR fixes

* Fix unit failure on Linux-musl x64 Debug

* CR fixes

* CR fixes

* Cleanup

Signed-off-by: dotnet-bot <[email protected]>
2019-02-14 22:38:32 +01:00
Tanner Gooding 321e0b511f Fixing Utf8Formatter.Float to support all the same format specifiers as the utf16 formatter. (#22434)
* Fixing Utf8Formatter.Float to support all the same format specifiers as the utf16 formatter.

* Disabling some outdated CoreFX tests.

* Fixing TryFormatFloatingPoint to special-case format.IsDefault

Signed-off-by: dotnet-bot <[email protected]>
2019-02-07 18:47:19 +01:00
Tanner Gooding 68606a1c30 Reverting "Fixing up the UTF8Formatter and some tests to properly handle -0.0" (#22300)
Signed-off-by: dotnet-bot <[email protected]>
2019-01-31 08:33:33 +01:00
Stephen Toub d4d6122008 Avoid allocations in Utf8Formatter.TryFormat(float/double, ...) (#22011)
* Avoid allocations in Utf8Formatter.TryFormat(float/double, ...)

Currently every call to Utf8Formatter.TryFormat for a float or a double allocates two strings, one for the format string and one for the resulting number.   This avoids those in the common case where we can use float/double.TryFormat and format directly into a stack buffer.  Also removes some unsafe code; the performance of StandardFormat.ToString isn't currently worth the extra nanoseconds gained by using unsafe code.

* Delete assert

There's a test that uses unsafe code to cause this to fail and validate that no exception is thrown.

Signed-off-by: dotnet-bot <[email protected]>
2019-01-17 22:38:25 +01:00
Levi Broderick baa8cf7312 Move OperationStatus into shared source (dotnet/coreclr#21912)
This is the first step to moving OperationStatus from corefx into coreclr. It'll be used by the transcoding APIs which live in System.Private.CoreLib.

Signed-off-by: dotnet-bot <[email protected]>
2019-01-10 10:41:03 +01:00
dotnet bot ccd7b52ca8 Add System.Private.CoreLib shared sources (#12162)
Taken from corefx commit 5956ad35864352b38c53aa8c2d1ce012c96b168d. Subsequent updates will happen via a mirroring bot.
2018-12-20 18:51:17 +01:00