| |
| |
Preface | |
| |
| |
| |
CLR/Framework Gotchas | |
| |
| |
Type alias size doesn't match what you're familiar with | |
| |
| |
struct and class differ in behavior | |
| |
| |
Returning value types from a method/property is risky | |
| |
| |
You can't force calls to your value-type constructors | |
| |
| |
String concatenation is expensive | |
| |
| |
Exceptions may go unhandled | |
| |
| |
Uninitialized event handlers aren't treated gracefully | |
| |
| |
Division operation isn't consistent between types | |
| |
| |
Typeless ArrayList isn't type-safe | |
| |
| |
Type.GetType() may not locate all types | |
| |
| |
Public key reported by sn.exe is inconsistent | |
| |
| |
| |
Visual Studio and Compiler Gotchas | |
| |
| |
Compiler warnings may not be benign | |
| |
| |
Ordering of catch processing isn't consist across languages | |
| |
| |
Type.GetType() might fail at run-time | |
| |
| |
rethrow isn't consistent | |
| |
| |
Default of Option Strict (off) isn't good | |
| |
| |
Versioning may lead to Serialization headaches | |
| |
| |
Creating Web apps can be painful | |
| |
| |
Naming XML documentation for IntelliSense support isn't intuitive | |
| |
| |
| |
Language and API Gotchas | |
| |
| |
Singleton isn't guaranteed process-wide | |
| |
| |
Default performance of Data. ReadXML is poor | |
| |
| |
enum lacks type-safety | |
| |
| |
Copy Constructor hampers exensibility | |
| |
| |
Clone() has limitations | |
| |
| |
Access to static/Shared members isn't enforced consistently | |
| |
| |
Details of exception may be hidden | |
| |
| |
Object initialization sequence isn't consistent | |
| |
| |
Polymorphism kicks in prematurely | |
| |
| |
Unit testing private methods is tricky | |
| |
| |
| |
Language Interoperability Gotchas | |
| |
| |
Common Language Specification Compliance isn't the default | |
| |
| |
Optional parameters break interoperability | |
| |
| |
Mixing case between class members breaks interoperability | |
| |
| |
Name collision with keywords breaks interoperability | |
| |
| |
Defining an array isn't consistent | |
| |
| |
| |
Garbage Collection Gotchas | |
| |
| |
Writing Finalize() is rarely a good idea | |
| |
| |
Releasing managed resources in Finalize() can wreak havoc | |
| |
| |
Rules to invoke base.Finalize() aren't consistent | |
| |
| |
Depending on Finalize() can tie up critical resources | |
| |
| |
Using Finalize() on disposed objects is costly | |
| |
| |
Implementing IDisposable isn't enough | |
| |
| |
Using the Dispose Design Pattern doesn't guarantee cleanup | |
| |
| |
| |
Inheritance and Polymorphism Gotchas | |
| |
| |
Runtime Type Identification can hurt extensibility | |
| |
| |
Using new/shadows causes "hideous hiding" | |
| |
| |
Compilers are lenient toward forgotten override/overrides | |
| |
| |
Compilers lean toward hiding virtual methods | |
| |
| |
Exception handling can break polymorphism | |
| |
| |
Signature mismatches can lead to method hiding | |
| |
| |
| |
Multithreading Gotchas | |
| |
| |
The Thread class supports some dangerous methods/properties | |
| |
| |
Foreground threads may prevent a program from terminating | |
| |
| |
Background threads don't terminate gracefully | |
| |
| |
Interrupt () kicks in only when a thread is blocked | |
| |
| |
ThreadAbortException-a hot potato | |
| |
| |
Environment.Exit() brings down the CLR | |
| |
| |
ResetAbort() may lead to surprises | |
| |
| |
Abort() takes time to clean up | |
| |
| |
Calling Type.GetType() may not return what you expect | |
| |
| |
Locking on globally visible objects is too sweeping | |
| |
| |
Threads from the thread pool are scarce | |
| |
| |
Threads invoked using delegates behave like background threads | |
| |
| |
Passing parameters to threads is tricky | |
| |
| |
Exceptions thrown from threads in the pool are lost | |
| |
| |
Accessing WinForm controls from arbitrary threads is dangerous | |
| |
| |
Web-service proxy may fail when used for multiple asynchronous calls | |
| |
| |
Raising events lacks thread-safety | |
| |
| |
| |
COM-Interop and Enterprise Services Gotchas | |
| |
| |
Release of COM object is confusing | |
| |
| |
Using interface pointers after calling ReleaseComObject() will fail | |
| |
| |
Cross-apartment calls are expensive | |
| |
| |
Default apartment of main thread is inconsistent across languages | |
| |
| |
STAThread attribute may have no effect on your methods | |
| |
| |
Spattering access to COM components makes code hard to maintain | |
| |
| |
Auto-generating GUID for your classes leads to versioning woes | |
| |
| |
All but one of the ClassInterface options are ineffective | |
| |
| |
Simply turning the switch for COM interop is dangerous | |
| |
| |
ServicedComponents implemented inconsistently on XP and 2003 | |
| |
| |
AutoComplete comes with undesirable side effects | |
| |
| |
Appendix | |
| |
| |
Index | |