Commit Graph
30 Commits
Author SHA1 Message Date
Stephen Toub 6072e4d3a7 Update license headers (#38793) 2020-07-08 09:23:11 -04:00
Stephen Toub 60d1224ddd Re-enable StyleCop warnings SA1028 and SA1518 (trailing whitespace and blank lines) (dotnet/corefx#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.

Commit migrated from https://github.com/dotnet/corefx/commit/09a6e66b0c2b31bd0f6e7e3170537d14027aeed0
2019-08-07 21:07:58 -04:00
Santiago Fernandez Madero 18c2fa114e Revert "Added Range Manipulation APIs to Collection<T> and ObservableCollection<T> (dotnet/corefx#35772)" (dotnet/corefx#38115)
* Revert "Added Range Manipulation APIs to Collection<T> and ObservableCollection<T> (dotnet/corefx#35772)"

This reverts commit dotnet/corefx@b705522753.

* Baseline API Compat errors

* Fix baseline vs netstandard


Commit migrated from https://github.com/dotnet/corefx/commit/d2506266dffcf6d83af11d192fa87435048614cb
2019-05-31 14:31:55 -07:00
Viktor Hofer b661c58b1c Replace netstandard test projects with tfms
Netstandard test projects are broken by design and don't support the
Microsoft.Net.Test.SDK. Replacing the netstandard tfm with the concrete
implementation tfms.


Commit migrated from https://github.com/dotnet/corefx/commit/d29c16c99c6045ee67444a7a693dd4476861c463
2019-05-30 16:18:41 +02:00
Andrew Hoefling 8253d5e7da Added Range Manipulation APIs to Collection<T> and ObservableCollection<T> (dotnet/corefx#35772)
* Added Collection<T> AddRange and InsertRange and added new XUnit tests to cover new APIs

Added missing APIs from Collection<T>; Added new unit tests for RemoveRange, ReplaceRange, InsertItemsRange and RemoveItemsRange

Updated AddRange in Collection<T> to add items to the end of the collection

Added CollectionChanged tests for ObservableCollection<T> for InsertRange, AddRange, RemoveRange and ReplaceRange

Removing API changes as these will be mirrored from CoreCLR

Updated array assertions to use Span<T> to simplify logic

Sorted order of new API methods

Simplified CollectionTests Assertion to use Span<T> instead of calling out each item in the array

Added missing API ReplaceItemsRange and updated unit tests for check for overflow errors on RemoveItems

Added overrides for ObservableCollection<T> ItemsRange API to only fire CollectionChanged once per API call. Before this was firing for each item in the collection which is not the desired result. Updated unit tests to verify this logic

Updated RemoveItemsRange to prevent int.MaxValue overflow errors

Added int.MaxValue overflow tests for Collection<T> and ObservableCollection<T> when invoking RemoveItemsRange API

Added additional RemoveRange unit tests to cover when Count is Less than 0 or when Count is 0

Updated RemoveRange overflow tests to check for ArgumentException for new business rules

Updated ObservableCollection overflow test to assert ArgumentException

Added try-finally block to ObservableCollection<T> to certify that _skipCollectionChanged is always set to false after a collection manipulation in case an exception is thrown in a subclass. Added new test class to test the new rules on the example of a NonNullObservableCollection<T>

CollectionChanged events do not fire on RemoveRange if the count == 0

Updated ObservableCollection<T> to only throw the 3 required events when ReplaceItemsRange is invoked. Updated OnChangedEvent methods to check for IList and cast as necessary. Added additional exception handling to reset _skipRaisingEvents bool. Added unit tests to verify event and event parameters are being passed correctly.

Added Collection<T> AddRange and InsertRange and added new XUnit tests to cover new APIs

Simplified CollectionTests Assertion to use Span<T> instead of calling out each item in the array

Added additional RemoveRange unit tests to cover when Count is Less than 0 or when Count is 0

Updated ObservableCollection<T> to only throw the 3 required events when ReplaceItemsRange is invoked. Updated OnChangedEvent methods to check for IList and cast as necessary. Added additional exception handling to reset _skipRaisingEvents bool. Added unit tests to verify event and event parameters are being passed correctly.

Updated ReplaceRange event to pass in the OldItems and NewItems to match the event docs

Simplified CollectionChanged 'NewItems for InsertItemsRange

Updated removedItems to use an array instead of a List<T>

Added new OnCollectionChanged overloads to reduce need for additional if checks.

Removed stale code

Optimized ReplaceItemsRange by simplifying the itemsToReplace which is no an array instead of a List<T>

Removed (IList) cast in ReplaceItemsRange when raising CollectionChanged

Removed temp array in RemoveRange which decreases memory allocation needed

* Removed redudent AsSpan parameter in test code

* Removed stale code in test code

* Removed redundent Assert.NotNull calls in several tests

* Added additional check in InsertRange to verify the input collection.Count is greater than 0 before raising the events

* Removed stale code from the `NonNullObservableCollection<T>` test harness

* Removed unnecessary whitespace

* Renamed new API tests to include the .netcoreapp extension; Updated .Tests.csproj file to only run them when the project is built under .NET core as net standard is the default

* Renamed CollectionTests -> CollectionTests.netcoreapp.cs and only run the test if it is a netcoreapp as the new APIs aren't in netstandard yet

* Added UAP and UAPAOT build configurations for System.ObjectModel tests

* Updated ObservableCollection/Collection tests that use new APIs to be in a partial class with the .netcoreapp.cs extension and existings tests to be in the .cs file.

* Added CollectionTestBase as parent class for CollectionTests for the use case where the other tests are ignored in netstandard builds

* Adding using statements back in which were failing the build

* Moving private classes from the netcoreapp tests to the regular CollectionTests as they were not available in the netstandard CI test run

* Added missing using statement for colleciton tests

* Added if-block that certifies we have replaced items before raising the Replace Event on ReplaceItemsRange

* Removed whitespace in System.Runtime.Tests.csproj

* Added negative test case for ReplaceRange when no items are replaced

* Fixed issue with failing test


Commit migrated from https://github.com/dotnet/corefx/commit/b705522753f09d501762cca6c45d6bd031c112d7
2019-05-01 20:57:56 -07:00
Hugh Bellamy 75920800c6 Cleanup ObjectModel code (dotnet/corefx#35047)
* Cleanup ObjectModel code

* Improve parameter names


Commit migrated from https://github.com/dotnet/corefx/commit/bab7da282613120288759dd7b7d3ff7d42dc00cf
2019-02-05 22:43:14 -05:00
Stephen Toub 4c9eb2ec25 Simplify built-in types across corefx tests (dotnet/corefx#30660)
Commit migrated from https://github.com/dotnet/corefx/commit/7ae1a252d7e68c5513d2658de7a401c37e9b0504
2018-06-25 22:42:04 -07:00
Viktor Hofer 98af3dbbd2 Reenable additional tests
Commit migrated from https://github.com/dotnet/corefx/commit/9ff35cf9bda7a74c2f9877d3858f229b203e5188
2017-08-04 22:12:10 +02:00
Jon Hanna 7816dc86f3 More thoroughly test System.ObjectModel collection debugger views. (dotnet/corefx#22859)
Have items in the instances tested against, and test contents are
reflected in debugger view objects.

Commit migrated from https://github.com/dotnet/corefx/commit/1fabf6a26a018a03778fe5ba9530b6df40e2e0b4
2017-08-02 11:42:24 -04:00
Hugh Bellamy 7cbcd5ed85 Convert most Assert.Throws<ArgumentException> without param name to AssertExtensions (dotnet/corefx#21455)
* Registry

* Collections

* ComponentModel

* Configuration

* Data

* Globalization

* Drawing

* Diagnostics

* IO

* Linq

* Add System.Net param names in tests

* Move ArgumentExceptions in System.Private.Xml to AssertExtensions

* Add System.Reflection.* ArgumentException param names

* Add param names for System.Runtime* ArgumentExceptions

* Add ArgumentException param names to System.Security.*

* Add ArgumentException param names to System.Text.*

* Add param names to ArgumentExceptions in misc projects

* Add System.Threading.* ArgumentException param names

* Fix missing files

* Fixes for unix and netfx

* Fix more failures and revert a IdnaConformance tests to avoid merge conflicts with dotnet/corefx#21463


Commit migrated from https://github.com/dotnet/corefx/commit/59915687bb261efeae70565d0ca8990ac45ceb9c
2017-06-23 12:33:47 -07:00
Viktor Hofer 65805739a9 Adding test to check if OnDeserialized doesn't throw if serialization… (dotnet/corefx#21357)
* Adding test to check if OnDeserialized doesn't throw if serialization fields aren't initialized yet. Relates to https://github.com/dotnet/corefx/pull/21322

* Skipping for netfx as this only tests core impl

* Update ObservableCollection_Serialization.cs


Commit migrated from https://github.com/dotnet/corefx/commit/ac9df95460b6edccbebdf4a33e7b910ae85c4676
2017-06-22 15:56:26 +02:00
Atsushi Kanamori ab64ae7f70 Get System.ObjectModel.Tests passing on UWP AOT
Commit migrated from https://github.com/dotnet/corefx/commit/13d3059699b47a00d40d0198ebd7e1f32c03ab31
2017-04-26 09:35:51 -07:00
Daniel Harvey 252cdc5e95 Bulk updates of tests for AssertExtensions (dotnet/corefx#18491)
Bulk update to AssertExtensions.Throws for AOT support. This doesn't disable Assert.Throws.

Commit migrated from https://github.com/dotnet/corefx/commit/b43b4df2e0e2182154bb0f425cb4a61bc1269828
2017-04-18 09:52:02 -07:00
Alex Perovich fc4bb66b9f Fold or rename *.netstandard.cs files (dotnet/corefx#17697)
* Win32.Primitives

* System.Collections.Specialized

* System.Diagnostics.Process

* System.Globalization

* System.Globalization.Calendars

* System.IO

* System.IO.Compression

* System.IO.FileSystem

* System.IO.FileSystem.Watcher

* System.IO.Pipes

* System.Linq.Expressions

* System.Net.Primitives

* System.Net.Requests

* System.Net.Sockets

* System.Net.WebHeaderCollection

* System.ObjectModel

* System.Reflection

* System.Reflection.Emit

* System.Resources.ResourceManager

* System.Runtime

* System.Runtime.Extensions

* System.Runtime.Handles

* System.Runtime.InteropServices

* System.Security.Cryptography.X509Certificates

* System.Text.Encoding

* System.Text.Encoding.CodePages

* System.Threading

* System.Threading.Tasks

* System.Threading.Thread

* System.Threading.Timer

* System.ValueTuple


Commit migrated from https://github.com/dotnet/corefx/commit/023b6bdd6086271cbb6ca932c33d7783f8406062
2017-03-30 17:28:22 -05:00
Paul Harrington 79d26b7560 Fix typos: occurred/occurrence (dotnet/corefx#16459)
Commit migrated from https://github.com/dotnet/corefx/commit/94a4ddf3f8f04ef2dc0486afcb62ef873bec2530
2017-02-24 23:56:39 -08:00
Jose Perez Rodriguez 24a5aef91d Merge master into dev/eng
Commit migrated from https://github.com/dotnet/corefx/commit/a9dd06b73bdd71038217bb263decf2b7285fb8db
2017-01-12 10:09:09 -08:00
Tarek Mahmoud Sayed c41fdd41c2 Fix System.ObjectModel test to run on desktop
Commit migrated from https://github.com/dotnet/corefx/commit/8e72ff3d2429a164571168513ca8fb735e6e2bb0
2017-01-11 11:02:50 -08:00
Alex Perovich ae1810f29c Automated rename of tfm specific files
Commit migrated from https://github.com/dotnet/corefx/commit/ca330455c9b884ffcca5b8b98d28a129e2248fe6
2017-01-10 16:20:59 -08:00
Stephen Toub 795becd1e5 Add System.ObjectModel serialization
Commit migrated from https://github.com/dotnet/corefx/commit/bf824598e784551d693672d7758cc404288dfb86
2016-11-02 22:55:25 -04:00
Justin Van Patten ebf0f387b2 ObservableCollection: Avoid SimpleMonitor allocation
Instead of always allocating an instance of the private `SimpleMonitor`
class for every instance of `ObservableCollection<T>`, lazily allocate
it only if/when a subclass calls `BlockReentrancy`.

Add tests that pass on the full framework and before/after these
changes.

Made some other minor improvements while making changes here, e.g.
removed the unnecessary base ctor call, raise events in the standard
thread-safe way, and remove/sort namespace imports.


Commit migrated from https://github.com/dotnet/corefx/commit/9e7cc5c99ef0e3ce26053e405872bfca7755a223
2016-10-21 07:38:54 -07:00
Justin Van Patten 69d17d5b30 ObservableCollection: Ensure passed-in collection is copied
Ensure the passed-in collection/list is copied to a new List<T>.


Commit migrated from https://github.com/dotnet/corefx/commit/94463e79f79960e41a38202664f16f604004c72d
2016-10-14 09:00:51 -07:00
Jose Perez Rodriguez db4fdbe4d1 Add missing members on System.Collections namespace
Commit migrated from https://github.com/dotnet/corefx/commit/fb0ed20aa2903b8ef43465ff854b93f2639d43f5
2016-10-12 09:12:22 -07:00
Jon Hanna 9e5785eb93 Fix Multiple Typos
Commit migrated from https://github.com/dotnet/corefx/commit/b0dd6b14fc845058b768fc7052b46aab0c1da22c
2016-03-20 16:37:09 +00:00
dotnet-bot b32ddb5d98 Deploy nameof throughout corefx in MemberData
Commit migrated from https://github.com/dotnet/corefx/commit/9c3156b9ada06b8e58ac53d48fc303500bf3e476
2016-02-18 23:58:15 -05:00
dotnet-bot 39d1eab950 Update licensing headers
Commit migrated from https://github.com/dotnet/corefx/commit/7cad8486cbabbce0236bdf530e30db7036335524
2016-01-27 08:02:28 -08:00
Justin Van Patten 9de9241b07 Optimize ObservableCollection<T>'s constructor
Instead of enumerating through the IEnumerable<T> directly, make use
of the List<T> constructor that takes an IEnumerable<T>, which has
optimizations for collections that implement ICollection<T>.

Also, cleaned up the ObservableCollection constructor/property tests.


Commit migrated from https://github.com/dotnet/corefx/commit/6992ca092454231f8152d4f771d2d6d7416de44d
2015-11-27 20:36:26 -08:00
Stephen A. Imhoff 106a87b81d Conform test namespaces in System.ObjectModel to standard in dotnet/corefx#2898
- Some namespaces changed.
- `using`s cleaned up in updated files.


Commit migrated from https://github.com/dotnet/corefx/commit/38938090b961898d119c61a2ac6fb1e051e0a294
2015-09-25 21:44:52 +09:00
Stephen A. Imhoff 7c088fcd28 Remove most instances ofcustom error checking from tests.
Patterns mostly were of the form:

```
if (someBooleanCondition)
{
    Assert.True(false, ....);
    // Or sometimes Assert.False(true, ....);
}
```
or
```
try
{
    SomeErrorThrowingOperation
    Assert.True(false, ....);
    // Or sometimes Assert.False(true, ....);
}
catch (ExpectedExceptionType e)
{
}
```
This replaces most instances with calls to the proper Xunit.Assert#### .
Some additional minor work was performed as noted with the affected package.

Add common ShouldNotBeInvokedException
System.Collections
 - Partially unwind edges of internal test framework.
System.Collections.Concurrent
 - Switch some tests to use InlineData instead of delegated method calls.
System.Collections.Immutable
 - Use ShouldNotBeInvokedException to state some lambdas should not be called.
System.Collections.NonGeneric
System.Composition
 - Partially unwind internal test famework.
 - Switch to using xunit asserts where possible.
System.Diagnostics.Contracts
 - Use ShouldNotBeInvokedException to state some lambdas should not be called.
 - Update project file to use upper case letter in hash.
System.Diagnostics.FileVersionInfo
 - Switch to direct equals comparison.
System.Diagnostics.Process
 - Use ShouldNotBeInvokedException to state a task should exit.
System.Diagnostics.Tracing.Telemetry
 - Use ShouldNotBeInvokedException to state an overridden method should not be called.
System.Globalization
 - Switch to direct equals comparisons in some cases.
System.Globalization.Extensions
 - Switch to direct equals comparison in some cases.
System.IO.Compression.ZipFile
System.IO.FileSystem
 - Partially unwind internal test framework.
System.IO.Packaging
 - Correct test T006 to check that adding absolute Uri part in internal mode is invalid.
System.ObjectModel
 - Use ShouldNotBeInvokedException to state some observables should execute.
System.Reflection
 - Update readonly-set test to verify that the field is set (previous test implied it was not).
System.Reflection.Extensions
System.Reflection.Metadata
 - Partially remove internal test framework.
 - Switch to xunit asserts where possible.
System.Reflection.TypeExtensions
System.Runtime
System.Runtime.Extensions
 - Switch to xunit bounded equals for doubles.
 - Switch to verifying non-varags Path.Combine override.
System.Runtime.Numerics
 - Switch to xunit Assert.Throws from internal version.
System.ServiceProcess.ServiceController
System.Text.Encoding
System.Text.Encodings.Web
System.Threading
System.Threading.Tasks.Dataflow
System.Threading.Tasks.Parallel
System.Xml.ReaderWriter
 - Switch to form verifying exception is thrown.
System.Xml.XmlDocument
 - Use ShouldNotBeInvokedException to state some handlers should not be called.


Commit migrated from https://github.com/dotnet/corefx/commit/ab1743b45213e88295a38e2bf9d80ded09058b18
2015-09-24 20:17:38 +09:00
Stephen Toub e4fe1e6b55 Add tests for System.Collections.* debugger attributes
Our collection types are some of the biggest users of DebuggerDisplayAttribute and DebuggerTypeProxyAttribute.  In the past as we've done refactorings, we've broken these on multiple occasions, and such breaks are often only discovered later on by someone using the types in the IDE.

This change adds some basic tests to exercise these debugger attributes, verifying their existence, that fields/properties they refer to exist, that properties on type proxies don't throw exceptions, etc.  We already had some debugger attribute tests in the System.Threading.Tasks.Dataflow library's tests; I've extracted those into some common helpers which I then use in the various test projects.

These helpers could be used in more test projects in the future.  They could also be expanded to cover more scenarios, as desired.


Commit migrated from https://github.com/dotnet/corefx/commit/f98612e1278908ad3998c90f982e8d1b4c44c320
2015-03-16 16:40:07 -04:00
dotnet-bot 52128f570e Add System.ObjectModel source and tests
Commit migrated from https://github.com/dotnet/corefx/commit/734dfcf6d3c31acb5c8103c904fb0554d4942f2f
2015-02-18 16:19:06 -08:00