Current filter:
                                You should refresh the page.
                                  • Contract.Requires for array shouldn't checks its length, just for null.


                                    Contract.Requires(items != null && items.Length != 0, nameof(items) + " is null or empty.");


                                    Contract.Requires(items != null , nameof(items) + " is null.");

                                    Mostly it is not an error passing an empty array. IMHO.

                                • Alex Eg (DevExpress) 07.01.2016

                                  Hi Miha,
                                  I totally agree with you that in case of the Contract.Requires code contract, it's not necessary to check the array length. However, we will keep such a check for the Exit Method and other contracts.

                                • Miha Markic - DevExpress MVP 07.01.2016

                                  Hi Alex,

                                  Hm, don't know about Exit either. Empty array can be perfectly valid result as well.

                                • Alex Eg (DevExpress) 07.01.2016

                                  Since CodeRush Classic, we use not only null checks but also check if array/collections/strings are not empty. It's a matter of personal style, so the best decision would be to add options so everyone would have the preferred result.

                                1 Solution

                                Creation Date Importance Sort by


                                Additional information:

                                We have added an option to disable length checking in Code Contracts. It will be available in the next CRR release on the Editor{Your Programming Language}\Code Actions\Code Actions Settings page.