Resharper Isn’t Always Smart

I was writing some code today, essentially like this:



public class MyClass


{


    private int value;


    public MyClass(int value)


    {


        this.value = value;


    }


    public static bool operator==(MyClass left, MyClass right)


    {


        return left.value == right.value;


    }


 


    public static bool operator !=(MyClass left, MyClass right)


    {


        return !(left == right);


    }


}



    //…


    MyClass myClass1 = new MyClass(1);


    MyClass myClass2 = new MyClass(1);


    if((Object)myClass1 != (Object)myClass2) // “Type cast is reundant”


    {


        Console.WriteLine(“not equal”);


    }


    else


    {


        Console.WriteLine(“equal”);


    }


…where Resharper warned that both the casts to Object were redundant and offered a “Quick-fix” (red light bulb) to “Remove cast”.  Well, doing that to one of the casts results in a compile error so you have to manually change the other; but what it’s suggesting is this:



    if(myClass1 != myClass2)


This completely changes the output of my application from “not equal” to “equal”.  What Resharper doesn’t know (or doesn’t care to check) is that removing those casts switches from a reference comparison to a value comparison and may have different results.  What I wrote with the original code was to test if the two references referenced the same object.  The default behaviour of a class is to do a reference check; but I’ve overloaded operator== (and operator !=) to perform a value comparison (I’ve left out the lovely bits that truly gives MyClass value semantics for clarity).


So, when Resharper offers to change your code, be sure you know side-effects of that change before you let it do it.  You could introduce a nasty bug.


kick it on DotNetKicks.com

Licences for Microsoft products

Occasionally I get development questions that are governed by one or more product licenses (End-User License Agreement, “EULA”).  One question that I see is “I’ve used Reflector to decompile the .NET Framework and want to use that C# code in my application”.


You’ve installed some Microsoft software and agreed to the EULA but didn’t save it and it’s nowhere on your hard-disk.  If you’re not sure what your license terms are, there’s a Microsoft web page that allows you to look up EULAs for many products: http://www.microsoft.com/about/legal/useterms/


 By the way, the answer to the question is “You’re not licensed to do that”.  Anyone know what clause in which EULA denies that?


kick it on DotNetKicks.com

Windows XP Professional EULA


07/27/2001 54834.1


Microsoft Windows XP Professional


END-USER LICENSE AGREEMENT

IMPORTANT—READ CAREFULLY: This End-User License Agreement (“EULA”) is a legal agreement

between you (either an individual or a single entity) and Microsoft Corporation for the Microsoft software


product identified above, which includes computer software and may include associated media, printed


materials, “online” or electronic documentation, and Internet-based services (“Product”). An amendment or

addendum to this EULA may accompany the Product.
YOU AGREE TO BE BOUND BY THE TERMS OF THIS

EULA BY INSTALLING, COPYING, OR OTHERWISE USING THE PRODUCT. IF YOU DO NOT AGREE, DO


NOT INSTALL OR USE THE PRODUCT; YOU MAY RETURN IT TO YOUR PLACE OF PURCHASE FOR A


FULL REFUND.

1. GRANT OF LICENSE. Microsoft grants you the following rights provided that you comply with all terms and

conditions of this EULA:

Installation and use. You may install, use, access, display and run one copy of the Product on a single computer,

such as a workstation, terminal or other device (“Workstation Computer”). The Product may not be used by


more than two (2) processors at any one time on any single Workstation Computer. You may permit a maximum


of ten (10) computers or other electronic devices (each a “Device”) to connect to the Workstation Computer to


utilize the services of the Product solely for File and Print services, Internet Information Services, and remote


access (including connection sharing and telephony services). The ten connection maximum includes any indirect


connections made through “multiplexing” or other software or hardware which pools or aggregates connections.


Except as otherwise permitted by the NetMeeting, Remote Assistance, and Remote Desktop features described


below, you may not use the Product to permit any Device to use, access, display or run other executable software


residing on the Workstation Computer, nor may you permit any Device to use, access, display, or run the Product


or Product’s user interface, unless the Device has a separate license for the Product.

Mandatory Activation. The license rights granted under this EULA are limited to the first thirty (30) days after

you first install the Product unless you supply information required to activate your licensed copy in the

manner described during the setup sequence of the Product.
You can activate the Product through the use of

the Internet or telephone; toll charges may apply. You may also need to reactivate the Product if you modify your


computer hardware or alter the Product. There are technological measures in this Product that are designed to


prevent unlicensed or illegal use of the Product. You agree that we may use those measures.

Storage/Network Use. You may also store or install a copy of the Product on a storage device, such as a network

server, used only to install or run the Product on your other Workstation Computers over an internal network;


however, you must acquire and dedicate an additional license for each separate Workstation Computer on or

from which the Product is installed, used, accessed, displayed or run.
A license for the Product may not be shared or

used concurrently on different Workstation Computers.


Reservation of Rights. Microsoft reserves all rights not expressly granted to you in this EULA.

2. UPGRADES. To use a Product identified as an upgrade, you must first be licensed for the product identified by

Microsoft as eligible for the upgrade. After upgrading, you may no longer use the product that formed the basis


for your upgrade eligibility.

3. ADDITIONAL SOFTWARE/SERVICES. This EULA applies to updates, supplements, add-on components, or

Internet-based services components, of the Product that Microsoft may provide to you or make available to you


after the date you obtain your initial copy of the Product, unless we provide other terms along with the update,


supplement, add-on component, or Internet-based services component. Microsoft reserves the right to


discontinue any Internet-based services provided to you or made available to you through the use of the Product.


This EULA does not grant you any rights to use the Windows Media Format Software Development Kit


(“WMFSDK”) components contained in the Product to develop a software application that uses Windows Media


technology. If you wish to use the WMFSDK to develop such an application, visit

http://msdn.microsoft.com/workshop/imedia/windowsmedia/sdk/wmsdk.asp, accept a separate license for the

WMFSDK, download the appropriate WMFSDK, and install it on your system.

4. TRANSFER—Internal. You may move the Product to a different Workstation Computer. After the transfer, youmust completely remove the Product from the former Workstation Computer. Transfer to Third Party. The initial

user of the Product may make a one-time transfer of the Product to another end user. The transfer has to include


all component parts, media, printed materials, this EULA, and if applicable, the Certificate of Authenticity. The


transfer may not be an indirect transfer, such as a consignment. Prior to the transfer, the end user receiving the

transferred Product must agree to all the EULA terms
. No Rental. You may not rent, lease, lend or provide

commercial hosting services to third parties with the Product.


07/27/2001 54834.1

5. LIMITATION ON REVERSE ENGINEERING, DECOMPILATION, AND DISASSEMBLY. You may not

reverse engineer, decompile, or disassemble the Product, except and only to the extent that it is expressly


permitted by applicable law notwithstanding this limitation.

6. TERMINATION. Without prejudice to any other rights, Microsoft may cancel this EULA if you do not abide by

the terms and conditions of this EULA, in which case you must destroy all copies of the Product and all of its


component parts.


7. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.

NetMeeting/Remote Assistance/Remote Desktop Features. The Product contains NetMeeting, Remote

Assistance, and Remote Desktop technologies that enable the Product or other applications installed on the


Workstation Computer to be used remotely between two or more computers, even if the Product or application is


installed on only one Workstation Computer. You may use NetMeeting, Remote Assistance, and Remote Desktop


with all Microsoft products; provided however, use of these technologies with certain Microsoft products may


require an additional license. For Microsoft and non-Microsoft products, you should consult the license


agreement accompanying the applicable product or contact the applicable licensor to determine whether use of


NetMeeting, Remote Assistance, or Remote Desktop is permitted without an additional license.

Consent to Use of Data. You agree that Microsoft and its affiliates may collect and use technical information

gathered in any manner as part of the product support services provided to you, if any, related to the Product.


Microsoft may use this information solely to improve our products or to provide customized services or


technologies to you. Microsoft may disclose this information to others, but not in a form that personally identifies


you.

Internet Gaming/Update Features. If you choose to utilize the Internet gaming or update features within the

Product, it is necessary to use certain computer system, hardware, and software information to implement the


features. By using these features, you explicitly authorize Microsoft or its designated agent to access and utilize


the necessary information for Internet gaming and/or updating purposes. Microsoft may use this information


solely to improve our products or to provide customized services or technologies to you. Microsoft may disclose


this information to others, but not in a form that personally identifies you.

Internet-Based Services Components. The Product contains components that enable and facilitate the use of

certain Internet-based services. You acknowledge and agree that Microsoft may automatically check the version


of the Product and/or its components that you are utilizing and may provide upgrades or fixes to the Product


that will be automatically downloaded to your Workstation Computer.

Security Updates. Content providers are using the digital rights management technology (“Microsoft DRM”)

contained in this Product to protect the integrity of their content (“Secure Content”) so that their intellectual


property, including copyright, in such content is not misappropriated. Owners of such Secure Content (“Secure


Content Owners”) may, from time to time, request Microsoft to provide security related updates to the Microsoft


DRM components of the Product (“Security Updates”) that may affect your ability to copy, display and/or play

Secure Content through Microsoft software or third party applications that utilize Microsoft DRM.
You therefore

agree that, if you elect to download a license from the Internet which enables your use of Secure Content,


Microsoft may, in conjunction with such license, also download onto your computer such Security Updates

that a Secure Content Owner has requested that Microsoft distribute.
Microsoft will not retrieve any personally

identifiable information, or any other information, from your computer by downloading such Security Updates.

8. NOT FOR RESALE SOFTWARE. Product identified as “Not for Resale” or “NFR,” may not be resold,

transferred or used for any purpose other than demonstration, test or evaluation.

9. ACADEMIC EDITION SOFTWARE. To use Product identified as “Academic Edition” or “AE,” you must be a

“Qualified Educational User.” For qualification-related questions, please contact the Microsoft Sales Information


Center/One Microsoft Way/Redmond, WA 98052-6399 or the Microsoft subsidiary serving your country.

10. EXPORT RESTRICTIONS.

You acknowledge that the Product is of U.S. origin and subject to U.S. export jurisdiction. You agree to comply


with all applicable international and national laws that apply to the Product, including the U.S. Export


Administration Regulations, as well as end-user, end-use, and destination restrictions issued by U.S. and other


governments. For additional information see <http://www.microsoft.com/exporting/>.


07/27/2001 54834.1


11. LIMITED WARRANTY FOR PRODUCT ACQUIRED IN THE US AND CANADA.


Microsoft warrants that the Product will perform substantially in accordance with the accompanying


materials for a period of ninety days from the date of receipt.


If an implied warranty or condition is created by your state/jurisdiction and federal or state/provincial

law prohibits disclaimer of it,
you also have an implied warranty or condition, BUT ONLY AS TO

DEFECTS DISCOVERED DURING THE PERIOD OF THIS LIMITED WARRANTY (NINETY


DAYS). AS TO ANY DEFECTS DISCOVERED AFTER THE NINETY (90) DAY PERIOD, THERE IS

NO WARRANTY OR CONDITION OF ANY KIND.
Some states/jurisdictions do not allow limitations

on how long an implied warranty or condition lasts, so the above limitation may not apply to you.


Any supplements or updates to the Product, including without limitation, any (if any) service packs or hot


fixes provided to you after the expiration of the ninety day Limited Warranty period are not covered by


any warranty or condition, express, implied or statutory.

LIMITATION ON REMEDIES; NO CONSEQUENTIAL OR OTHER DAMAGES. Your exclusiveremedy for any breach of this Limited Warranty is as set forth below. Except for any refund elected by

Microsoft, YOU ARE NOT ENTITLED TO ANY DAMAGES, INCLUDING BUT NOT LIMITED TO


CONSEQUENTIAL DAMAGES, if the Product does not meet Microsoft’s Limited Warranty, and, to the

maximum extent allowed by applicable law, even if any remedy fails of its essential purpose.
The terms

of Section 13 below (“Exclusion of Incidental, Consequential and Certain Other Damages”) are also


incorporated into this Limited Warranty. Some states/jurisdictions do not allow the exclusion or limitation


of incidental or consequential damages, so the above limitation or exclusion may not apply to you. This


Limited Warranty gives you specific legal rights. You may have others which vary from state/jurisdiction

to state/jurisdiction.
YOUR EXCLUSIVE REMEDY. Microsoft’s and its suppliers’ entire liability and your

exclusive remedy shall be, at Microsoft’s option from time to time exercised subject to applicable law,


(a) return of the price paid (if any) for the Product, or (b) repair or replacement of the Product, that does not


meet this Limited Warranty and that is returned to Microsoft with a copy of your receipt. You will receive


the remedy elected by Microsoft without charge, except that you are responsible for any expenses you may


incur (e.g. cost of shipping the Product to Microsoft). This Limited Warranty is void if failure of the Product


has resulted from accident, abuse, misapplication, abnormal use or a virus. Any replacement Product will


be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer.


Outside the United States or Canada, neither these remedies nor any product support services offered by


Microsoft are available without proof of purchase from an authorized international source. To exercise


your remedy, contact: Microsoft, Attn. Microsoft Sales Information Center/One Microsoft Way/Redmond,


WA 98052-6399, or the Microsoft subsidiary serving your country.


LIMITED WARRANTY FOR PRODUCT ACQUIRED OUTSIDE THE US OR CANADA.


FOR THE LIMITED WARRANTIES AND SPECIAL PROVISIONS PERTAINING TO YOUR


PARTICULAR JURISDICTION, PLEASE REFER TO YOUR WARRANTY BOOKLET INCLUDED


WITH THIS PACKAGE OR PROVIDED WITH THE SOFTWARE PRODUCT PRINTED


MATERIALS.

12. DISCLAIMER OF WARRANTIES. The Limited Warranty that appears above is the only express warranty made

to you and is provided in lieu of any other express warranties (if any) created by any documentation, packaging,

or other communications.
Except for the Limited Warranty and to the maximum extent permitted by applicable

law, Microsoft and its suppliers provide the Product and support services (if any) AS IS AND WITH ALL

FAULTS, and hereby disclaim all other warranties and conditions, either express, implied or statutory,

including, but not limited to, any (if any) implied warranties, duties or conditions of merchantability, of


fitness for a particular purpose, of reliability or availability, of accuracy or completeness of responses, of


results, of workmanlike effort, of lack of viruses, and of lack of negligence, all with regard to the Product, and


the provision of or failure to provide support or other services, information, software, and related content


through the Product or otherwise arising out of the use of the Product. ALSO, THERE IS NO WARRANTY


OR CONDITION OF TITLE, QUIET ENJOYMENT, QUIET POSSESSION, CORRESPONDENCE TO


DESCRIPTION OR NON-INFRINGEMENT WITH REGARD TO THE PRODUCT.

13. EXCLUSION OF INCIDENTAL, CONSEQUENTIAL AND CERTAIN OTHER DAMAGES. TO THE

MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL MICROSOFT OR ITS


07/27/2001 54834.1


SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, PUNITIVE, INDIRECT, OR CONSEQUENTIAL


DAMAGES WHATSOEVER (INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS


OR CONFIDENTIAL OR OTHER INFORMATION, FOR BUSINESS INTERRUPTION, FOR PERSONAL


INJURY, FOR LOSS OF PRIVACY, FOR FAILURE TO MEET ANY DUTY INCLUDING OF GOOD FAITH


OR OF REASONABLE CARE, FOR NEGLIGENCE, AND FOR ANY OTHER PECUNIARY OR OTHER LOSS


WHATSOEVER) ARISING OUT OF OR IN ANY WAY RELATED TO THE USE OF OR INABILITY TO USE


THE PRODUCT, THE PROVISION OF OR FAILURE TO PROVIDE SUPPORT OR OTHER SERVICES,


INFORMATON, SOFTWARE, AND RELATED CONTENT THROUGH THE PRODUCT OR OTHERWISE


ARISING OUT OF THE USE OF THE PRODUCT, OR OTHERWISE UNDER OR IN CONNECTION WITH


ANY PROVISION OF THIS EULA, EVEN IN THE EVENT OF THE FAULT, TORT (INCLUDING


NEGLIGENCE), STRICT LIABILITY, BREACH OF CONTRACT OR BREACH OF WARRANTY OF


MICROSOFT OR ANY SUPPLIER, AND EVEN IF MICROSOFT OR ANY SUPPLIER HAS BEEN ADVISED


OF THE POSSIBILITY OF SUCH DAMAGES.

14. LINKS TO THIRD PARTY SITES. You may link to third party sites through the use of the Product. The third

party sites are not under the control of Microsoft, and Microsoft is not responsible for the contents of any third


party sites, any links contained in third party sites, or any changes or updates to third party sites. Microsoft is not


responsible for webcasting or any other form of transmission received from any third party sites. Microsoft is


providing these links to third party sites to you only as a convenience, and the inclusion of any link does not


imply an endorsement by Microsoft of the third party site.

15.
LIMITATION OF LIABILITY AND REMEDIES. Notwithstanding any damages that you might incur for any

reason whatsoever (including, without limitation, all damages referenced above and all direct or general


damages), the entire liability of Microsoft and any of its suppliers under any provision of this EULA and your


exclusive remedy for all of the foregoing (except for any remedy of repair or replacement elected by Microsoft


with respect to any breach of the Limited Warranty) shall be limited to the greater of the amount actually paid


by you for the Product or U.S.$5.00. The foregoing limitations, exclusions and disclaimers (including Sections


11, 12 and 13 above) shall apply to the maximum extent permitted by applicable law, even if any remedy fails


its essential purpose.

16. U.S. GOVERNMENT LICENSE RIGHTS. All Product provided to the U.S. Government pursuant to solicitations

issued on or after December 1, 1995 is provided with the commercial license rights and restrictions described


elsewhere herein. All Product provided to the U.S. Government pursuant to solicitations issued prior to


December 1, 1995 is provided with “Restricted Rights” as provided for in FAR, 48 CFR 52.227-14 (JUNE 1987) or


DFAR, 48 CFR 252.227-7013 (OCT 1988), as applicable.

17.
APPLICABLE LAW. If you acquired this Product in the United States, this EULA is governed by the laws of the

State of Washington. If you acquired this Product in Canada, unless expressly prohibited by local law, this EULA


is governed by the laws in force in the Province of Ontario, Canada; and, in respect of any dispute which may


arise hereunder, you consent to the jurisdiction of the federal and provincial courts sitting in Toronto, Ontario. If


this Product was acquired outside the United States, then local law may apply.

18.
ENTIRE AGREEMENT. This EULA (including any addendum or amendment to this EULA which is included

with the Product) are the entire agreement between you and Microsoft relating to the Product and the support


services (if any) and they supersede all prior or contemporaneous oral or written communications, proposals


and representations with respect to the Product or any other subject matter covered by this EULA. To the


extent the terms of any Microsoft policies or programs for support services conflict with the terms of this


EULA, the terms of this EULA shall control.


19. The Product is protected by copyright and other intellectual property laws and treaties. Microsoft or its suppliers


own the title, copyright, and other intellectual property rights in the Product. The Product is licensed, not sold.


Si vous avez acquis votre produit Microsoft au CANADA, la garantie limitée suivante vous concerne :


GARANTIE LIMITÉE


Microsoft garantit que le Produit fonctionnera conformément aux documents qui l’accompagnent pendant une période de 90 jours


suivant la date de réception.


Si une garantie ou condition implicite est créée par votre État ou votre territoire et qu’une loi fédérale, provinciale ou étatique en interdit le déni,

v
ous jouissez également d’une garantie ou condition implicite, MAIS UNIQUEMENT POUR LES DÉFAUTS DÉCOUVERTS

DURANT LA PÉRIODE DE LA PRÉSENTE GARANTIE LIMITÉE (QUATRE-VINGT-DIX JOURS). IL N’Y A AUCUNE GARANTIE OU


CONDITION DE QUELQUE NATURE QUE CE SOIT QUANT AUX DÉFAUTS DÉCOUVERTS APRÈS CETTE PÉRIODE DE QUATREVINGT-

DIX JOURS.
Certains États ou territoires ne permettent pas de limiter la durée d’une garantie ou condition implicite de sorte

que la limitation cidessus peut ne pas s’appliquer à vous.


Tous les suppléments ou toutes les mises à jour relatifs au Produit, y compris notamment (le cas échéant), tous les ensembles de


services ou les réparations à chaud qui vous sont fournis après l’expiration de la période de quatre-vingt-dix jours de la garantie


limitée ne sont pas couverts par quelque garantie ou condition que ce soit, expresse,implicite ou en vertu de la loi.


07/27/2001 54834.1

LIMITATION DES RECOURS; ABSENCE DE DOMMAGES INDIRECTS OU AUTRES. Votre recours exclusif pour toute violation de laprésente garantie limitée est décrit ci-après. Sauf pour tout remboursement au choix de Microsoft, si le Produit ne respecte pas la garantie

limitée de Microsoft et, dans toute la mesure permise par le droit applicable, même si tout recours n’atteint pas son but essentiel, VOUS N’AVEZ

DROIT À AUCUNS DOMMAGES, NOTAMMENT DES DOMMAGES INDIRECTS.
Les modalités de la clause «Exclusion des

dommages accessoires, indirects et de certains autres dommages » sont également incorporées à la présente garantie limitée.


Certains États ou territoires ne permettent pas l’exclusion ou la limitation des dommages indirects ou accessoires de sorte que la


limitation ou l’exclusion ci-dessus peut ne pas s’appliquer à vous. La présente garantie limitée vous donne des droits légaux

spécifiques. Vous pouvez avoir d’autres droits qui peuvent varier d’un territoire ou d’un État à un autre.
VOTRE RECOURSEXCLUSIF. La responsabilité intégrale de Microsoft et de ses fournisseurs et votre recours exclusif seront, selon le choix de

Microsoft de temps à autre sous réserve de toute loi applicable, a) le remboursement du prix payé, le cas échéant, pour le Produit


ou b) la réparation ou le remplacement du Produit qui ne respecte pas la présente garantie limitée et qui est retourné à Microsoft


avec une copie de votre reçu. Vous recevrez la compensation choisie par Microsoft, sans frais, sauf que vous êtes responsable des


dépenses que vous pourriez engager (p. ex., les frais d’envoi du Produit à Microsoft). La présente garantie limitée est nulle si la


défectuosité du Produit est causée par un accident, un usage abusif, une mauvaise application, un usage anormal ou un virus. Tout


Produit de remplacement sera garanti pour le reste de la période de garantie initiale ou pendant trente (30) jours, selon la plus


longue entre ces deux périodes. À l’extérieur des États-Unis ou du Canada, ces recours ou l’un quelconque des services de


soutien technique offerts par Microsoft ne sont pas disponibles sans preuve d’achat d’une source internationale autorisée. Pour


exercer votre recours, vous devez communiquer avec Microsoft et vous adresser au Microsoft Sales Information Center/One


Microsoft Way/Redmond, WA 98052-6399, ou à la filiale de Microsoft de votre pays.

DÉNI DE GARANTIES. La garantie limitée qui apparaît ci-dessus constitue la seule garantie expresse qui vous est donnée et

remplace toutes autres garanties expresses (s’il en est) mentionnées dans tout document, emballage ou autre communication.


Sauf en ce qui a trait à la garantie limitée et dans toute la mesure permise par le droit applicable, le Produit et les services de soutien technique

(le cas échéant) sont fournis
TELS QUELS ET AVEC TOUS LEURS DÉFAUTS par Microsoft et ses fournisseurs, lesquels par les présentes

dénient toutes autres garanties et conditions expresses, implicites ou en vertu de la loi, y compris notamment (le cas échéant) les garanties,


devoirs ou conditions implicites de qualité marchande, d’adaptation à une fin particulière, de fiabilité ou disponibilité, d’exactitude ou d’exhaustivité


des réponses, des résultats, des efforts déployés selon les règles de l’art, d’absence de virus et de négligence, le tout à l’égard du Produit et de


la prestation des services de soutien technique ou autres services ou du défaut de fournir une telle prestation, de l’information, du logiciel, et de


tout contenu s’y rapportant à travers le Produit ou autrement découlant de l’utilisation du Produit. PAR AILLEURS, IL N’Y A AUCUNE


GARANTIE OU CONDITION QUANT AU TITRE DE PROPRIÉTÉ, À LA JOUISSANCE OU LA POSSESSION PAISIBLE, À LA


CONCORDANCE À UNE DESCRIPTION NI QUANT À UNE ABSENCE DE CONTREFAÇON CONCERNANT LE PRODUIT.


EXCLUSION DES DOMMAGES ACCESSOIRES, INDIRECTS ET DE CERTAINS AUTRES DOMMAGES. DANS TOUTE LA MESURE


PERMISE PAR LE DROIT APPLICABLE, EN AUCUN CAS MICROSOFT OU SES FOURNISSEURS NE SERONT RESPONSABLES


DES DOMMAGES SPÉCIAUX, ACCESSOIRES, EXEMPLAIRES OU INDIRECTS DE QUELQUE NATURE QUE CE SOIT (Y


COMPRIS NOTAMMENT, LES DOMMAGES À L’ÉGARD DE LA PERTE DE PROFITS OU DE LA DIVULGATION DE


RENSEIGNEMENTS CONFIDENTIELS OU AUTRES, DE L’INTERRUPTION DES AFFAIRES, DE BLESSURES CORPORELLES, DE


LA VIOLATION DE LA VIE PRIVÉE, DE L’OMISSION DE REMPLIR TOUT DEVOIR, Y COMPRIS D’AGIR DE BONNE FOI OU


D’EXERCER UN SOIN RAISONNABLE, DE LA NÉGLIGENCE ET DE TOUTE AUTRE PERTE PÉCUNIAIRE OU AUTRE PERTE DE


QUELQUE NATURE QUE CE SOIT) DÉCOULANT OU SE RAPPORTANT DE QUELQUE MANIÈRE QUE CE SOIT À L’UTILISATION


DU PRODUIT OU À L’INCAPACITÉ DE S’EN SERVIR, À LA PRESTATION DE SERVICES DE SOUTIEN TECHNIQUE OU AUTRES


SERVICES OU À L’OMISSION D’UNE TELLE PRESTATION , À L’INFORMATION, AU LOGICIEL ET À TOUT CONTENU S’Y


RAPPORTANT À TRAVERS LE PRODUIT OU AUTREMENT DÉCOULANT DE L’UTILISATION DU PRODUIT OU AUTREMENT AUX


TERMES DE TOUTE DISPOSITION DU PRÉSENT CONTRAT OU RELATIVEMENT À UNE TELLE DISPOSITION, MÊME EN CAS DE


FAUTE, DE DÉLIT CIVIL (Y COMPRIS LA NÉGLIGENCE), DE RESPONSABILITÉ STRICTE, DE VIOLATION DE CONTRAT OU DE


VIOLATION DE GARANTIE DE MICROSOFT OU DE TOUT FOURNISSEUR ET MÊME SI MICROSOFT OU TOUT FOURNISSEUR A


ÉTÉ AVISÉ DE LA POSSIBILITÉ DE TELS DOMMAGES.


LIMITATION DE RESPONSABILITÉ ET RECOURS. Malgré les dommages que vous puissiez subir pour quelque motif que ce soit


(y compris notamment, tous les dommages susmentionnés et tous les dommages directs ou généraux), la responsabilité intégrale


de Microsoft et de l’un ou l’autre de ses fournisseurs aux termes de toute disposition du présent contrat et votre recours exclusif à


l’égard de tout ce qui précède (sauf en ce qui concerne tout recours de réparation ou de remplacement choisi par Microsoft à


l’égard de tout manquement à la garantie limitée) se limite au plus élevé entre les montants suivants : le montant que vous avez


07/27/2001 54834.1


réellement payé pour le Produit ou 5,00 $US. Les limites, exclusions et dénis qui précèdent (y compris les clauses ci-dessus),


s’appliquent dans la toute la mesure permise par le droit applicable, même si tout recours n’atteint pas son but essentiel.


La présente Convention est régie par les lois de la province d’Ontario, Canada. Vous reconnaissez irrévocablement par la présente


la compétence des tribunaux de la province d’Ontario et consentez à instituer tout litige qui pourrait découler de la présente auprès


des tribunaux fédéraux ou provinciaux ayant juridiction pour la ville de Toronto, province d’Ontario.


EULAID:WX.4_PRO_RTL_EN

.NET 2.0 Framework License


End-User License Agreement


MICROSOFT SOFTWARE SUPPLEMENTAL LICENSE TERMS


MICROSOFT .NET FRAMEWORK 2.0


Microsoft Corporation (or based on where you live, one of its affiliates) licenses this supplement to you. If you are licensed to use Microsoft Windows operating system software (the “software”), you may use this supplement. You may not use it if you do not have a license for the software. You may use a copy of this supplement with each validly licensed copy of the software.


The following license terms describe additional use terms for this supplement. These terms and the license terms for the software apply to your use of this supplement. If there is a conflict, these supplemental license terms apply.


———————————-


By using this supplement, you accept these terms. If you do not accept them, do not use this supplement. If you comply with these license terms, you have the rights below.


1. SUPPORT SERVICES FOR SUPPLEMENT. Microsoft provides support services for this supplement as described at www.support.microsoft.com/common/international.aspx.


2. MICROSOFT .NET FRAMEWORK BENCHMARK TESTING. This supplement includes the .NET Framework component of the Windows operating systems (“.NET Component”). You may conduct internal benchmark testing of the .NET Component. You may disclose the results of any benchmark test of the .NET Component, provided that you comply with the following terms: (1) you must disclose all the information necessary for replication of the tests, including complete and accurate details of your benchmark testing methodology, the test scripts/cases, tuning parameters applied, hardware and software platforms tested, the name and version number of any third party testing tool used to conduct the testing, and complete source code for the benchmark suite/harness that is developed by or for you and used to test both the .NET Component and the competing implementation(s); (2) you must disclose the date (s) that you conducted the benchmark tests, along with specific version information for all Microsoft software products tested, including the .NET Component; (3) your benchmark testing was performed using all performance tuning and best practice guidance set forth in the product documentation and/or on Microsoft’s support web sites, and uses the latest updates, patches and fixes available for the .NET Component and the relevant Microsoft operating system; (4) it shall be sufficient if you make the disclosures provided for above at a publicly available location such as a website, so long as every public disclosure of the results of your benchmark test expressly identifies the public site containing all required disclosures; and (5) nothing in this provision shall be deemed to waive any other right that you may have to conduct benchmark testing. The foregoing obligations shall not apply to your disclosure of the results of any customized benchmark test of the .NET Component, whereby such disclosure is made under confidentiality in conjunction with a bid request by a prospective customer, such customer’s application(s) are specifically tested and the results are only disclosed to such specific customer. Notwithstanding any other agreement you may have with Microsoft, if you disclose such benchmark test results, Microsoft shall have the right to disclose the results of benchmark tests it conducts of your products that compete with the .NET Component, provided it complies with the same conditions above.


 


 


 

Upcoming C# 3 Guidance From Microsoft

Mircea Trofin has some design guidelines with regard to some C# 3 language additions (that I assume will make it into a revised Framework Design Guidelines of some sort).  They more less agree with the guidelines I published in Code Magazine a while ago.  There are some slight differences:


Consider using extension methods in any of the following scenarios: to provide helper functionally relevant to every implementation of an interface… and,


Do define extension methods in the same namespace as the extended type, if the type is an interface, and if the extension methods are meant to be used in most or all cases.  This applies to framework designers that are publishing interfaces but also want to publish callable methods that apply to all implementation of those interfaces.  My article approaches the guidelines more from a non-framework designer.  I do agree that extension methods to extend interfaces is very useful and is probably one of the most adept use of extension methods.  Although, I think the wording of this guideline could use improvement.


Avoid defining extension methods on System.Object, unless absolutely necessary.  Good advice.


Do not define extension methods pertaining to a feature in namespaces normally associated with other features.  Instead define them in the namespace associated with the feature they belong to, or a namespace of it.  This is really unclear (and seems to suggest contradicting the first guideline: Avoid frivolous use of the extension methods feature when defining methods on a new type.  Use the canonical, language-specific means for defining type members).  I’m assuming the jist of this is, as a framework designer, don’t arbitrarily put extension methods in the namespace of the type the method applies to, consider putting the extension method in a more applicable namespace, if possible.  For example, if you want to declare an extension method “Forward” for Telecom.INode implementations, putting the method in a “Routing” namespace would be better than arbitrarily putting it in the “Telecom” namespace.  I’ve changed the Mircea’s guidance slightly to use a interface in the example–which I think makes it more clear.


Mircea also includes Consider using extension methods in any of the following scenarios:… when object model considerations would dictate taking a dependency on some assuming but taking such a dependency would break dependency management rules.  This means, should you need to add a method to a class but adding that method would create cyclic dependency or would cause a lower level assembly/class to be dependant on a higher level class, break the method out into another assembly as an extension method.  Use this advice with caution; I would argue that if you think you need a method like this at all (even if implemented as an extension method), you likely have some design problems and should only be considered when revising a published framework, and not when creating a new framework.


Another tidbit of guidance that came about after I wrote the article and Mircea doesn’t mention is that extension methods can make writing fluent interfaces much cleaner by separating the state management concern of supporting a fluent interface from the class that it applies to.


Thoughts?  Any additional guidance you feel has been overlooked (with regard to extension methods and LINQ)?

kick it on DotNetKicks.com

Single-Entry, Single-Exit, Should It Still Be Applicable In Object-oriented Languages?

Before the modern high-level languages Edsger Dijkstra came up with “Structured Programming”.  This programming methodology relied on the programmer to form and enforce most of the structure of the program–manually keeping sub-structures and logic separate from one another to promote maintainability and easy of understanding, among other things.  Think assembly language with a linear collection of instructions and jumps and then the only concept of a method or function is how the rest of the logic jumps to that block of code.


This concept of delineating functions hinged on a single entry, i.e. from point A to point B only one point is actually jumped to from “external” code.  This single entry concept usually included a single exit, to ease the delineation of a “function”.  This is known as the single-entry, single-exit methodology (SESE).


It’s hard to think of multiple entry points with modern high-level languages what with object-orientation and abstraction and encapsulation; but it’s easy to see multiple exits from a method.  For example:



        public static int CountCommas(string text)


        {


            if (String.IsNullOrEmpty(text))


            {


                return 0;


            }


            if (text.Length == 0)


            {


                return 0;


            }


 


            int index = 0;


            int result = 0;


            while (index > 0)


            {


                index = text.IndexOf(‘,’, index);


                if (index > 0)


                {


                    result++;


                }


            }


            return result;


        }


Structured programming (at least SESE) suggests writing the method like this instead:



        public static int CountCommas(string text)


        {


            int result = 0;


            if (!String.IsNullOrEmpty(text))


            {


                if (text.Length > 0)


                {


                    int index = 0;


                    while (index > 0)


                    {


                        index = text.IndexOf(‘,’, index);


                        if (index > 0)


                        {


                            result++;


                        }


                    }


                }


            }


 


            return result;


        }



This concept may have made for more readable code when Dijkstra first cemented the concept in the late 60’s early 70’s; but in Object-Oriented languages I believe it’s less readable.  For one thing, it’s difficult to shoe-horn SESE with other language concepts like exceptions:



        public static int CountCommas(string text)


        {


            Exception exception = null;


            int result = 0;


            if (!String.IsNullOrEmpty(text))


            {


                if (text.Length > 0)


                {


                    int index = 0;


                    while (index > 0)


                    {


                        index = text.IndexOf(‘,’, index);


                        if (index > 0)


                        {


                            result++;


                        }


                    }


                }


                else


                {


                    exception = new ArgumentException(“argument of zero length”, “text”);


                }


            }


            else


            {


                exception = new ArgumentNullException(“text”);


            }


 


            if (exception != null)


            {


                throw exception;


            }


 


            return result;


        }



And this technically still violates SESE since we exit via return or via throw, although they have close proximity.


I believe the above example is hard to read and hard to maintain.  I would abandon the SESE trappings of structured programming in favour of:



 


        public static int CountCommas(string text)


        {


            if (String.IsNullOrEmpty(text))


            {


                throw new ArgumentNullException(“text”);


            }


            if (text.Length == 0)


            {


                throw new ArgumentException(“argument of zero length”, “text”);


            }


 


            int index = 0;


            int result = 0;


            while (index > 0)


            {


                index = text.IndexOf(‘,’, index);


                if (index > 0)


                {


                    result++;


                }


            }


            return result;


        }


In high-level languages that do have concepts like functions, subroutines, or methods, the “Single Entry” aspect of SESE is moot, evolving to the concept of “Single Exit” or the “Single Point of Exit From Methods Principle”.  This seems like a Cargo Cult to me–separating the part of a concept that is no longer obviously archaic in the hopes of getting the same result in a different context.


Interestingly, as I was writing this, Patrick Smacchia posted to his blog about NDepend and Nesting Depth–which basically details metrics that show the SESE implementations I show above would actually have higher nesting depths than the non-SESE implementations and thus be more complex, less readable, and less testable.


 What are your thoughts?  Do you generally follow Single Point of Exit From Methods Principle?  If you do, do you ignore it for exceptions?

kick it on DotNetKicks.com