77 Commits
Author SHA1 Message Date
Dotnet-GitSync-Bot 759a8c1847 Mirror changes from mono/corefx,coreclr,corert (#17761)
* Add EventWaitHandle creation extension method that takes an ACL (#42213)

* Add EventWaitHandle creation extension method that takes an ACL

* Call OpenExisting, add basic unit tests, move MAX_PATH in csproj for all Windows platforms, ensure same exceptions are thrown in both netcore and netfx.

* Address suggestions: using for the created handle, simplify try finally, merge methods, remove an unnecessary Debug.Assert

* simplify using, reorganize PInvokes a bit, let VS format resx as it expects it, remove BOM from csproj

* Add more unit tests

* Save basic access rights in a constant, generate name randomly

* Use FullControl (EVENT_ALL_ACCESS); update unit tests to use EventWaitHandleRights

* Apply suggestion of creating an EWH, then replacing its SWH.

* Remove using causing chaos, add more unit tests, remove null string unit test.

* spacing

* Address comments

* Remove unnecessary checks/exceptions, update unit tests

* Fix netfx x86 ut failure - different exception for mode validation.

* Small documentation fix

* Remove documentation for exception thrown with null security

* more documentation fixes

* New file for unit tests

* Dispose and remove windows only attributes in tests

* suggestion to not use var

* Remove duplicate resx after merge

* Readd cs files lost during merge

* Remove resx modification since it was untouched for this PR

* Address test comments

Signed-off-by: dotnet-bot <[email protected]>

* Move NativeLibrary.Free null check to managed (dotnet/coreclr#27744)

Signed-off-by: dotnet-bot <[email protected]>

* Arm64: Add S.P.CoreLib instrinsics UnzipEven and UnzipOdd (#27731)

Signed-off-by: dotnet-bot <[email protected]>
2019-11-08 07:11:13 -05:00
Carlos Sanchez Lopez 229d3cc097 Add Semaphore creation extension methods that take an ACL (#42377)
Approved API Proposal: #41662

Description
We don't currently have a way to create a Semaphore with a given ACL in .NET Core. We can modify the ACL, but it would be more secure to have the proper ACL on the object from the start.

Customer impact
Before this change, customers had to create a Semaphore, then set its ACLs. This presents a few problems:
- Potential security hole as semaphores can be accessed between creation and modification.
- Porting difficulties as there isn't a 1-1 API replacement
This change addresses those problems by adding a new extension method that allows creating a Semaphore and ensuring the provided ACLs are set during creation.

Signed-off-by: dotnet-bot <[email protected]>
2019-11-08 01:59:07 +01:00
Carlos Sanchez Lopez 3c84633c7c Add Mutex creation extension methods that take an ACL (#42281)
Approved API Proposal: #41662

Description
We don't currently have a way to create a Mutex with a given ACL in .NET Core. We can modify the ACL, but it would be more secure to have the proper ACL on the object from the start.

Customer impact
Before this change, customers had to create a Mutex, then set its ACLs. This presents a few problems:

Potential security hole as mutexes can be accessed between creation and modification.
Porting difficulties as there isn't a 1-1 API replacement
This change addresses those problems by adding a new extension method that allows creating a Mutex and ensuring the provided ACLs are set during creation.

Signed-off-by: dotnet-bot <[email protected]>
2019-11-07 12:27:50 +01:00
Dotnet-GitSync-Bot 3695d8704e Mirror changes from mono/coreclr,corefx (#17609)
* Revert removal of SuppressGCTransition from SystemNative_GetTimestamp() (#27473)

* Revert removal of SuppressGCTransition from SystemNative_GetTimestamp()

* Insert GC_POLL before statement with unmanaged call.

* JIT test for insertion of GCPoll

Signed-off-by: dotnet-bot <[email protected]>

* Add file creation method that takes an ACL (dotnet/corefx#42099)

Approved API Proposal: #41614
Related change for directory creation method that takes an ACL: #41834 -merged and ported to 3.1 Prev2

Description
We have extension methods in System.IO.FileSystem.AclExtensions that let the user get and set ACLs for existing files, but we do not have methods that create files with predefined ACLs.
.NET ACL (Access Control List) support is Windows specific. This change will reside inside the System.IO.FileSystem.AccessControl assembly.

Customer impact
Before this change, customers had to create a file or filestream, then set its ACLs. This presents a few problems:

Potential security hole as files can be accessed between creation and modification.
Porting difficulties as there isn't a 1-1 API replacement
Stability issues with background processes (file filters) can prevent modifying ACLs right after creation (typically surfaces as a security exception).
This change addresses those problems by adding a new extension method that allows creating a file and ensuring the provided ACLs are set during creation.
This change is expected to be backported to 3.1.

Signed-off-by: dotnet-bot <[email protected]>
2019-10-30 00:03:47 -04:00
Filip Navara db02ebc88b Fix building portable thread pool on Windows (dotnet/corert#7849)
Signed-off-by: dotnet-bot <[email protected]>
2019-10-29 23:34:11 +01:00
dotnet-maestro[bot] 6f04054541 Update dependencies from dotnet/corefx (dotnet/coreclr#27431)
* Update dependencies from https://github.com/dotnet/corefx build 20191024.13

- Microsoft.NETCore.Platforms - 5.0.0-alpha.1.19524.13
- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19524.13

* Update dependencies from https://github.com/dotnet/corefx build 20191024.14

- Microsoft.NETCore.Platforms - 5.0.0-alpha.1.19524.14
- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19524.14

* Update dependencies from https://github.com/dotnet/corefx build 20191025.6

- Microsoft.NETCore.Platforms - 5.0.0-alpha.1.19525.6
- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19525.6

* Workaround https://github.com/dotnet/coreclr/issues/27465

Signed-off-by: dotnet-bot <[email protected]>
2019-10-27 17:54:12 +01:00
Dotnet-GitSync-Bot e5d88dbd04 Mirror changes from mono/coreclr,corefx,corert (#17526)
* Apply SuppressGCAttribute to some SPCL functions. (dotnet/coreclr#27369)

Apply SuppressGCAttribute to some SPCL functions.

Only insert GC_POLL in first morph call.

Signed-off-by: dotnet-bot <[email protected]>

* Remove unused methods (dotnet/coreclr#27370)

Signed-off-by: dotnet-bot <[email protected]>

* Move Matrix3x2/4x4, Plan, and Quaternion to the shared CoreLib partition (#42021)

Signed-off-by: dotnet-bot <[email protected]>

* Remove Socket.InnerSafeCloseSocket (dotnet/corefx#41888)

* Remove Socket.InnerSafeCloseSocket

* Move IsInvalid checks in SetHandle function

* PR feedback

* Remove unnecessary 'SocketPal.'

* Remove SafeSocketHandle.SetHandle

Signed-off-by: dotnet-bot <[email protected]>
2019-10-23 23:01:00 -04:00
Jan Kotas b98911d4f8 Delete Uap quirks from CoreLib (dotnet/coreclr#27356)
This matches cleanup done in CoreFX.

Signed-off-by: dotnet-bot <[email protected]>
2019-10-22 14:48:34 -04:00
Jan Kotas 64c3405594 Cleanup memory copy helpers (dotnet/coreclr#27307)
- Merge RuntimeImports that has just a few FCalls into Buffer.
- Delete assembly implementation of memcpy for ARM. The implementation was outdated and it was used only on Windows ARM and only for fraction of memcpy callsites.
- Delete unnecessary PInvoke into SysStringLen. We have a managed equivalent on System.Runtime.InteropServices.Marshal.
- Delete large amount of redundant code between SecureString.Windows.cs and SecureString.Unix.cs, and switch SecureString to use Spans
- Fold null check into IsWin32Atom

Signed-off-by: dotnet-bot <[email protected]>
2019-10-22 09:46:29 -04:00
Jan Kotas 113d855adb Delete ENABLE_WINRT define (dotnet/coreclr#27240)
.NET Native specific code not needed anymore

Signed-off-by: dotnet-bot <[email protected]>
2019-10-22 09:46:29 -04:00
Stephen Toub 1e3d017479 More corelib cleanup (dotnet/coreclr#26993)
* Make relevant types static (mostly Interop)

* Fix a few stray semicolons

* Remove unnecessary locals

Some can be removed entirely, some can be replaced by discards.

* Remove unnecessary usings

* Move Unix-specific helper method to TimeZoneInfo.Unix.cs

* Remove duplicated code

* Remove duplicative checks

* Remove [ThreadStatic] initialization

These are all the default values and wouldn't be necessary for any static, but inline initialization for [ThreadStatic]s is particularly unuseful (and in non-default cases problematic) because the fields are only set to these values on the initializing thread.

* Fix methods whose return value is never used

* Use string.IsNullOrEmpty

* Remove unnecessary field initialization

All ctors overwrite these values.

* Address PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-10-05 14:09:54 +02:00
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
Sung Yoon Whang 3f26b9aa6c Improve the performance of Environment.WorkingSet in Windows (#26522)
* Use win32 api directly for workingset counter

* Fix build warnings

* Removing useless code

* more cleanup

* remove size annotation

* remove useless comment

* Move all the changes to Environment.WorkingSet and remove it from RuntimeEventSourceHelper

* removing useless usings

* Use kernel32.dll instead of psapi.dll

* Code review feedback

* Remove newline change

* More code review nits

Signed-off-by: dotnet-bot <[email protected]>
2019-09-12 13:27:35 -05:00
Tarek Mahmoud Sayed f97ceb5c3e Fix Running .NET Core Under Windows App Compat Shim (dotnet/coreclr#26605)
* Fix Running .NET Core Under Winndows App Compat Shim

.NET Core uses Windows features called sort handles for perf reason to speed up the collation operations (e.g. string comparisons). When enabling Windows app compat shim (e.g. Windows 7 compatibility mode), the calls uses sort handles will fail which cause all collation operations to fail.
The fix here is to detect if the sort handles work before using it to ensure successful run.

* Address the feedback

* More feedback addressing

Signed-off-by: dotnet-bot <[email protected]>
2019-09-11 09:05:40 +02:00
Stephen Toub e2c7b4200a Fix (mostly) IDE0055 (formatting)
Lots of various spacing issues.  I say "mostly" because I explicitly undid some changes that added to rather than reduced inconsistency, e.g. region indents.  We can revisit that later.

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 3803a00421 Fix StyleCop warnings for rules enabled in corefx
Signed-off-by: dotnet-bot <[email protected]>
2019-08-14 10:15:38 +02:00
Stephen Toub 6c95cbadf9 Fix StyleCop warning SA1400 (missing access modifiers)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-13 21:35:04 +02:00
Aaron Robinson 66f7436d6f Remove unnecessary error check for QueryUnbiasedInterruptTime call (#26120)
Signed-off-by: dotnet-bot <[email protected]>
2019-08-12 19:46:54 +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 f532f93ea6 Enable stylecop warnings 1205, 1212, and 1617 (dotnet/corefx#39941)
* Enable stylecop warning 1617 (void return value should not be documented)

* Enable stylecop warning 1212 (get/set accessor ordering)

* Enable stylecop warning 1205 (modifier ordering)

Signed-off-by: dotnet-bot <[email protected]>
2019-08-03 20:55:40 +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
Stephen Toub 4ec5b8de98 Remove now unnecessary !s / TODO-NULLABLE comments (dotnet/coreclr#25749)
* Remove !s and TODO-NULLABLE comments for [DoesNotReturn]

* Remove !s and TODO-NULLABLE comments for [NotNullIfNotNull]

* Remove !s and TODO-NULLABLE comments for writes via Interlocked.CompareExchange

* Remove !s and TODO-NULLABLE comments for Debug.Assert on fields

* Update/add several TODO-NULLABLE comments

Signed-off-by: dotnet-bot <[email protected]>
2019-07-24 09:45:03 +02:00
Stephen Toub c465ad1e80 Remove stale nullable !s and pragmas (dotnet/coreclr#25640)
Also update TODO-NULLABLE comments to be more specific where appropriate.

Signed-off-by: dotnet-bot <[email protected]>
2019-07-24 09:45:03 +02:00
Adam SitnikandJan Kotas 62f597ea23 Apply suggestions from code review
Co-Authored-By: Jan Kotas <[email protected]>

Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:09 +00:00
Adam Sitnik 2597806f5f set the charset to Ansi
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:08 +00:00
Adam Sitnik a22d66c98c simplify the code
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:07 +00:00
Adam Sitnik d7506847fe use IntPtr instead of CriticalHandle to avoid resurrection issues. It's ok to never free the handle
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:05 +00:00
Adam Sitnik ba42c41536 seal the CriticalSortHandle class
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:04 +00:00
Adam Sitnik 67e2d3ff62 change SafeSortHandle to be CriticalSortHandle to avoid expensive ref counting
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:37:03 +00:00
Stephen Toub 4a29e94abb Update Corelib to adapt to compiler nullability updates
Signed-off-by: dotnet-bot <[email protected]>
2019-06-17 22:36:59 +00:00
Carlos Sanchez Lopez 132969ee3e Fix issue in NamedPipeServerStream.GetImpersonationUserName() (#37676)
Fix for issue where NamedPipeServerStream.GetImpersonationUserName() throws unexpected InvalidationOperationException("The operation completed successfully") when impersonation is not allowed, when in fact it should simply return an empty string.

The fix will call GetNamedPipeHandleStateW once. If it fails, it will try to load sspicli.dll if it was not loaded, and will reattempt the call to GetNamedPipeHandleStateW.

This fix is only for Win32: UAP does not allow calling LoadLibraryEx, and Windows Nano says denies access to GetNamedPipeHandleStateW even after attempting to load sspicli.dll.

Signed-off-by: dotnet-bot <[email protected]>
2019-06-08 08:52:42 +02:00
Stephen Toub a67c6a2b52 Add and apply nullable attributes (dotnet/coreclr#24679)
* Add and apply nullable attributes

* Adapt to API review decisions

* Address PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-05-28 18:14:19 +02:00
David Wrighton 30fb72969e Fewer ilstubs in corelib from reflection apis (dotnet/coreclr#24708)
Rework use of marshalling for RuntimeTypeHandle, RuntimeModule, RuntimeAssembly, and IRuntimeMethodInfo as used by QCalls
- Remove special QCall only used marshallers for RuntimeAssembly, RuntimeModule and IRuntimeMethodInfo
- Following the pattern of ObjectHandleOnStack, implement QCall handle types for RuntimeAssembly/Module/TypeHandle. Use these in all QCalls that once passed the types directly.
- For uses of IRuntimeMethodInfo, follow the existing RuntimeMethodHandleInternal pattern

Also perform some replacement of bool marshalling with use of Interop.BOOL, and a few cases of using pointers instead of byref arguments.

Fix delivers a relatively small win on startup, and small throughput gains around reflection as IL stubs are no longer necessary for many functions in reflection that once needed them.

Reduces methods jitted on powershell startup from 422 to 399, (About 5%) but performance win is only about 5ms on ~400ms as the methods removed are simple.

Signed-off-by: dotnet-bot <[email protected]>
2019-05-24 10:00:05 +02:00
Stephen Toub f5c8b3f7e9 Implement AppDomain.Monitoring*MemorySize (dotnet/coreclr#24610)
* Implement AppDomain.MonitoringTotalAllocatedMemorySize

* Change precise:true back to precise:false in GetTotalAllocatedBytes

Signed-off-by: dotnet-bot <[email protected]>
2019-05-22 09:33:36 +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
Krzysztof Wicher e09ca81503 Nullable: Interop and src/System remainder (dotnet/coreclr#24328)
* Nullable: Interop and src/System remainder

* apply feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-05-02 20:34:11 +02:00
Anipik c94f194278 synving with coreclr 2019-04-29 22:10:14 +02:00
Marek Safar c6c25db0c2 Mirror changes from mono/coreclr,corefx,corert (#14163)
Mirror changes from mono/coreclr,corefx,corert
2019-04-29 19:30:57 +02:00
Santiago Fernandez Madero 7bd9e122aa Fix build errors in Interop.Errors
Signed-off-by: dotnet-bot <[email protected]>
2019-04-24 11:02:06 +02:00
Krzysztof Wicher a97a684f25 Nullable: couple of missing #nullable enable (dotnet/coreclr#24094)
Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:45:46 +00:00
Stephen Toub f1901501e8 Nullable: Runtime serialization, COM, Vector, remaining IO, and other (#23895)
Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:42:05 +00:00
Krzysztof Wicher 2126d5a92c Nullable: Globalization native interop + some missing files (#23914)
* Nullable: globalization native + some missing files

* address feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:38:00 +00:00
Anirudh Agnihotry 452db22237 Nullable: Interop.Adavapi32 (dotnet/coreclr#23875)
* interop definations nullified

* reverting null check and adding arguments nullable to match win32 function definations

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:37:57 +00:00
Krzysztof Wicher b4ed8f6782 Nullable: Interop: Kernel32 and few others (dotnet/coreclr#23880)
* Nullable: Interop: Kernel32 and few others

* fix compile errors (new compiler)

* address feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:35:22 +00:00
Stephen Toub 3418f9c1f8 Nullable: System (most of it) (dotnet/coreclr#23774)
* Nullable: shared\System (most of it)

And some other things it touches.

* Nullable: src\System (most of it)

* Address PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:32:38 +00:00
Stephen Toub 074f8a9e6c Nullable: Attributes, SafeHandles, and misc (dotnet/coreclr#23810)
* Nullable: Attributes, SafeHandles, and misc

* Address PR feedback

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:28:28 +00:00
Tanner Gooding a7e61a0a10 Nullable: System.Runtime.InteropServices.Marshal (dotnet/coreclr#23699)
* Nullable: System.Runtime.InteropServices.Marshal

* Fixing the nullable annotations for BindToMoniker and GetObjectForIUnknown

* Fixing the nullability of PtrToStringAuto(IntPtr, int)

Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:26:04 +00:00
Stephen Toub 2996c13498 Nullable: Array (dotnet/coreclr#23746)
Signed-off-by: dotnet-bot <[email protected]>
2019-04-22 16:24:07 +00:00
Filip Navara d5a4f9b8a9 Move EventSource to shared CoreLib partition (dotnet/coreclr#23925)
* Move most of EventSource to shared CoreLib partition

* Reenable some code that can be shared with Microsoft.Diagnostics.Tracing.EventSource.Redist in CoreFX

* Remove unused functions

* Fix placement of #endregion

* Clean up P/Invoke prototypes

* Move remaining code from EventSource_CoreCLR to shared partition (guarded by !CORERT)

* Remove more unnecessary marshalling attributes

* Move remaining CoreRT/ProjectN code to shared partition

* Avoid using Windows errors on non-Windows platforms

Signed-off-by: dotnet-bot <[email protected]>
2019-04-16 19:24:43 +02:00