Index

Symbols

{ } (braces), C# style conventions, 466469

, (comma), C# style conventions, 475476

- (hyphens), naming conventions, 53

(/* . */), multiline syntax, comments, 482

(// .), single line syntax, comments, 482

[TypeForwardedTo], moving types, 532533

_ (underscore), naming conventions, 53, 481482

A

abbreviations, naming conventions, 5556

abstract classes, type design guidelines, 98102

abstract members

adding, 539

changing

to virtual members, 553

virtual members to, 553

override members, removing an override of an abstract member, 543544

abstractions

designing frameworks, 3436

extensibility, 239241

self-documenting object models, principle of, 3436

AccessViolationException, 276

acronyms

capitalization, 4548

naming conventions, 5556

adding

abstract members, 539

base interfaces to interfaces, 536

members

to interfaces, 541

to unsealed types, 539540

method parameters, 546

readonly modifier to structs, 535, 550

reference type fields to structs, 540

second declaration to generic interfaces, 536537

static modifiers, 549

aggregate components

component-oriented design, 331334

design patterns, 329338

designing, 335338

factored types, 334335

alphanumeric characters, naming conventions, 53

API (Application Programming Interface)

availability, 1314

consistency, 34

designing frameworks

low barrier to entry, principle of, 2329

scenario-driven framework design, 1623

self-documenting object models, principle of, 2936

exceptions and API consistency, 250

heavy API design processes, 2

intuitive API, 3334

layered architecture, principle of, 3639

naming new versions of existing API, 5861

sample specification, 523528

Stopwatch specification, 524528

strong typing, 3334

unification, 1314

well-designed frameworks, qualities of, 3

backward compatibility, 2

borrowing from existing proven designs, 67

consistency, 78

evolution, 7

expense, 45

integration, 7

OO design, 2

prototyping, 2

simplicity, 34

trade-offs, 6

ApplicationException, 274

applications

models, namespaces, 6566

RAD, progressive frameworks, 13

architectures (layered), principle of, 3639

ArgumentException, 275276

ArgumentNullException, 275276

ArgumentOutOfRangeException, 275276

arguments, validation, 207210, 480

arrays

collections versus, 302303

design patterns, 430433

usage guidelines, 287291

ASCII characters

code restrictions, 479

naming conventions, 54

Unicode escape sequences (uXXXX), 479

assemblies

naming conventions, 6162

renaming, 530531

types and assembly metadata, 127129

assignment-expression-throw, C# style conventions, 480

Async Patterns, 502

Async method return types, 348351

Async variants of existing synchronous methods, 353354

await foreach, 363365

cancellation, 512513

choosing, 339341, 503504

Classic Async Patterns, 361, 503509

consistency, 355361

context, 357358

deadlock, 358

design patterns, 339365

Event-Based Async Patterns, 361362, 510512

exceptions to Async methods, 359361

IAsyncDisposable interface, 362

IAsyncEnumerable<T> interface, 362365

implementation guidelines, 355361

incremental results, 516

Out parameters, 512

progress reporting, 513516

Ref parameters, 512

Task-Based Aync Pattern, 341347

Task.Status consistency, 355357

ValueTask structs, 358359

ValueTask<TResult> structs, 358359

attached DP design, 369370

attributes, usage guidelines, 291294

auto-implemented properties, C# style conventions, 479

await foreach, Async Patterns, 363365

await using, Dispose Patterns, 393394

B

backward compatibility, well-designed frameworks, qualities of, 2

base classes

extensibility, 242244

moving members to, 541

base interfaces

adding to interfaces, 536

moving members to, 541

base members, masking, 539

BCL type names, C# style conventions, 476

behaviors, changing, 553555

Binary serialization, 493

boolean parameters, choosing, 205207

borrowing from existing proven designs, well-designed frameworks, 67

braces ({ }), C# style conventions, 466469

breaking changes, 529

assemblies, renaming, 530531

behaviors, changing, 553555

classes

changing structs to, 537538

changing to structs, 537

moving members to base classes, 541

compilation breaks, 530

finalizers, removing from

sealed types, 542

unsealed types, 542

interfaces

adding a second declaration to interfaces, 536537

adding base interfaces to interfaces, 536

adding members to, 541

moving members to base interfaces, 541

members

adding abstract members, 539

adding to interfaces, 541

adding to unsealed types, 539540

changing member signatures, 545553

masking base members, 539

moving to base classes, 541

moving to base interfaces, 541

moving to derived types, 542

overloading, 544545

override members, 540

removing an override of a virtual member, 543

removing an override of an abstract member, 543544

removing non-override members, 543

namespaces, adding namespaces that conflict with existing types, 531532

private fields

removing from serializable types, 544

renaming on serializable types, 544

recompile breaks, 530

reflection breaks, 530

runtime breaks, 529

structs

adding first reference type field to, 540

adding readonly modifier to structs, 535536

changing classes to, 537

changing to classes, 537538

ref structs, 538

types

changing namespaces, 535

moving, 532533

moving members to derived types, 542

names, case sensitivity, 534

removing, 533

removing finalizers from sealed types, 542

removing finalizers from unsealed types, 542

removing private fields on serializable types, 544

renaming private fields on serializable types, 544

sealing unsealed types, 534

unsealing sealed types, 534

brevity, naming conventions, 52

buffer operators

arrays, 430433

data transformation operations, 445451

design patterns, 430445

fixed sizes, 451452

OperationStatus value, 458463

partial writes to buffers, 458463

predetermined sizes, 451452

Spans, 431445

Try-Write Pattern, 452458

C

C#

coding style conventions, 465466

ASCII characters, code restrictions, 479

assignment-expression-throw, 480

auto-implemented properties, 479

BCL type names, 476

braces ({ }), 466469

collection initializers, 478

commas ( , ), 475476

comments, 482483

expression-bodied members, 478479

file organization, 483485

if.throw, 480

indents, 465466

language keywords, 476

member modifiers, 473475

nameof (.) syntax, 479

naming conventions, 480482

object initializers, 477478

readonly modifiers, 479

spaces, 469470

this.476

Unicode escape sequences (uXXXX), 479

var keyword, 476477

vertical whitespace, 472473

language-specific names, naming conventions, 57

C++, language-specific names, naming conventions, 57

callbacks, extensibility, 231237

camelCasing, 43

C# style conventions, 481482

naming conventions, 481482

parameter names, 79

cancellation, Async Patterns, 512513

capitalization, 42

acronyms, 4548

case sensitivity, 5152

compound words, 4851

identifiers, 4244

camelCasing, 43

PascalCasing, 4244

case sensitivity

capitalization, 5152

type names, 534

change notification events, DP, 371

changing

abstract members to virtual members, 553

behaviors, 553555

classes to structs, 537

constant field values, 552

default values, in optional parameters, 552

member

signatures, 545553

visibility, 548549

method

parameters types, 546

return types, 547548

non-virtual members to virtual members, 553

notification events in properties, 163165

optional parameters to required, 551552

property types, 548

reference parameters, 549550

required parameters to optional, 551

runtime error exceptions to usage error exceptions, 553554

structs to classes, 537538

type names

case sensitivity, 534

changing namespaces, 535

usage error exceptions to functioning behavior, 554

values returned type, from a method, 554555

virtual members to abstract members, 553

choosing

boolean parameters, 205207

enum parameters, 205207

exceptions for throwing, 260264

member

methods, 152158

properties, 152158

classes

abstract classes, type design guidelines, 98102

base classes

extensibility, 242244

moving members to, 541

changing

classes to structs, 537

structs to classes, 537538

defined, 84

members, moving to base classes, 541

naming conventions, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

static classes

defined, 84

type design guidelines, 102104

type design guidelines, 89100, 102104

unsealed classes, extensibility, 228229

Classic Async Patterns, 361, 503509

Close() method, Dispose Patterns, 382383

CLR (Common Language Runtime), language-specific names and naming conventions, 57

collections

arrays versus, 302303

custom collections, 302303

initializers, C# style conventions, 478

live collections, 301302

parameters, 296297

properties, 298302

return values, 298302

snapshot collections, 301302

usage guidelines, 294296

arrays versus collections, 302303

collection properties, 298302

custom collections, 302303

live collections, 301302

parameters, 296297

return values, 298302

snapshot collections, 301302

ComException, 278

commas ( , ), C# style conventions, 475476

comments

C# style conventions, 482483

“I” usage, 483

multiline syntax (/* . */), 482

passive voice, 483

personification, 483

single-line syntax (// .), 482

“we” usage, 483

common names, naming conventions, 5758

compatibility (backward), well-designed frameworks, 2

compilation breaks, 530

component-oriented design, 331334

compound words, capitalization, 4851

ConfigureAwait modifier, await using, 393394

consistency

Async Patterns, 355361

self-documenting object models, principle of, 34

Task.Status, 355357

well-designed frameworks, qualities of, 78

constant field values, changing, 552

constructors

designing, 165172

type constructors, 172175

contravariance, design patterns, 412417

conversion operators, 198-C05.1827

core namespaces, 66

costs, well-designed frameworks, 45

covariance, design patterns, 412415, 417423

customizing

collections, 303305

event handlers, obsolete guidance, 491492

exceptions

designing, 279280

obsolete guidance, 492493

D

Data Contract serialization, 493, 495499

data transformation operations, 445451

DateTime struct, usage guidelines, 306308

DateTimeOffset struct, usage guidelines, 306308

deadlock, Async Patterns, 358

declarations, adding to interfaces, 536537

default values, changing in optional parameters, 552

derived types, moving members to, 542

design patterns

aggregate components, 329338

arrays, 430433

Async Patterns, 339365, 502

cancellation, 512513

choosing between Async Patterns, 503504

Classic Async Patterns, 503509

Event-Based Async Patterns, 503504, 510512

incremental results, 516

Out parameters, 512

progress reporting, 513516

Ref parameters, 512

buffer operators, 430445

arrays, 430433

fixed sizes, 451452

OperationStatus value, 458463

partial writes to buffers, 458463

predetermined sizes, 451452

Spans, 431445

Try-Write Pattern, 452458

contravariance, 412417

covariance, 412415, 417423

Dispose Patterns, 372394, 511517

DP, 366372

factories, 394399

LINQ, 400408

optional features, 408411

Spans, 431445

Template Method Pattern, 423425

timeouts, 426427

Try-Write Pattern, 452458

XAML readable types, 427430

.Design subnamespaces, 489

designing

aggregate components, 335338

component-oriented design, 331334

constructors, 165175

custom exceptions, 279280

error messages, 264265

events, 175180

extensibility, 227228

abstractions, 239241

base classes, 242244

callbacks, 231237

events, 231237

limiting, 244246

protected members, 230

sealing, 244246

unsealed classes, 228229

virtual members, 237239

fields, 180183

frameworks, 3, 911, 1516

abstractions, 3436

backward compatibility, 2

consistency, 78

evolution, 7

existing proven designs, borrowing from, 67

expense, 45

integration, 7

low barrier to entry, principle of, 2329

multiframework platforms, 1213

OO design, 2

programming languages, 1112

progressive frameworks, 1215

prototyping, 2

scenario-driven framework design, 1623

self-documenting object models, principle of, 2939

simplicity, 34

trade-offs, 6

members

boolean parameters, 205207

choosing methods, 152158

choosing properties, 152158

conversion operators, 198-C05.1827

enum parameters, 205207

explicit implementation of interface members, 148152

extension methods, 184192

fields, 180183

inequality operators, 200202

members with variable number of parameters, 214218

operator overloads, 192198

overloading members, 136148

parameter argument validation, 207210

parameter passing, 210214

parameters, 202204

pointer parameters, 218219

tuples in member signatures, 220226

parameters, 202204

argument validation, 207210

boolean parameters, 205207

enum parameters, 205207

members with variable number of parameters, 214218

passing, 210214

properties, 158160

change notification events, 163165

indexed properties, 161163

types, 8485

assembly metadata and types, 127129

classes, 89104

constructors, 172175

enums, 111124

interfaces, 92100, 104106

namespaces, 8588

nested types, 124127

strings, 129133

structs, 8992, 106111

diacritical marks, naming conventions, 55

Dispose (bool) method, Dispose Patterns, 376380

Dispose (true) method, Dispose Patterns, 377378

Dispose Patterns

await using, 393394

basic Dispose Patterns, 375383

Close() method, 382383

ConfigureAwait modifier, 393394

design patterns, 372394

Dispose (bool) method, 376380

Dispose (true) method, 377378

finalizable types, 383387, 511517

IAsyncDisposable interface, 391392

IDisposable method, 382383

rehydration, 381382

scoped operations, 387391

SuppressFinalize method, 378

DLL (Dyanmic-Link Libraries), naming conventions, 6162

DP (Dependency Properties), 365366

attached DP design, 369370

change notification events, 371

design patterns, 366372

validation, 370

value coercion, 371372

E

enums

adding values to, 123124

defined, 84

flag enums, type design guidelines, 119123

naming conventions, 7274

parameters, choosing, 205207

type design guidelines, 111118

equality operators

reference types, 328

usage guidelines, 324328

value types, 327

error exceptions

runtime error exceptions, changing to usage error exceptions, 553554

throwing new types of, 555

usage error exceptions, changing

to functioning behavior, 554

runtime error exceptions to, 553554

error handling, exceptions and, 250252

error messages, designing, 264265

event handlers (custom), obsolete guidance, 491492

Event-Based Async Patterns, 361362, 503504, 510512

events

change notification events, DP, 371

custom event handlers, obsolete guidance, 491492

designing, 175180

extensibility, 231237

naming conventions, 7778

notification events, changing in properties, 163165

evolution of well-designed frameworks, qualities of, 7

exceptions

AccessViolationException, 276

API consistency, 250

ApplicationException, 274

ArgumentException, 275276

ArgumentNullException, 275276

ArgumentOutOfRangeException, 275276

Async methods, 359361

ComException, 278

custom exceptions

designing, 279280

obsolete guidance, 492493

error exceptions, throwing new types of, 555

error handling, 250252

error messages, 264265

ExecutionEngineException, 278

FormatException, 278279

handling, 249254, 265271

IndexOutOfRangeException, 276

instrumentation and, 254

InvalidOperationException, 274275

NullReferenceException, 276

object-oriented languages, 249250

OperationCanceledException, 278

OutOfMemoryException, 277278

performance and, 281

Tester-Doer Pattern, 281282

Try Pattern, 282286

PlatformNotSupportedException, 279

runtime error exceptions, changing to usage error exceptions, 553554

SEHException, 278

self-documenting object models, 33

StackOverflowException, 276277

SystemException, 274

TaskCanceledException, 278

throwing, 254260

choosing exceptions, 260264

error messages, 264265

from existing thrown types, 555

new types of error exceptions, 555

types, 273279

unhandled exception handlers, 253

usage error exceptions

changing runtime error exceptions to, 553554

changing to functioning behavior, 554

wrapping, 271273

ExecutionEngineException, 278

existing proven designs (well-designed frameworks), qualities of, 67

expense, well-designed frameworks, 45

explicit implementation of interface members, 148152

exposing layers

in the same namespace, 3839

in separate namespaces, 38

expression-bodied members, C# style conventions, 478479

expression-throw, C# style conventions, 480

extensibility, 227228

abstractions, 239241

base classes, 242244

callbacks, 231237

events, 231237

limiting, 244246

protected members, 230

sealing, 244246

unsealed classes, 228229

virtual members, 237239

extension methods, 184192

F

factored types, aggregate components, 334335

factories, design patterns, 394399

features (optional), design patterns, 408411

fields

designing, 180183

naming conventions, 7879

private fields

removing from serializable types, 544

renaming private fields on serializable types, 544

file organization, C# style conventions, 483485

finalizable types, Dispose Patterns, 383387, 511517

Finalize method, Dispose Patterns, 378

finalizers, removing

sealed types, 542

from unsealed types, 542

first reference type field, adding to structs, 540

fixed buffer sizes, 451452

flag enums, type design guidelines, 119123

FormatException, 278279

Framework Design Guidelines, naming conventions, 480

frameworks

designing, 3, 911, 1516

abstractions, 3436

backward compatibility, 2

borrowing from existing proven designs, 67

consistency, 78

evolution, 7

expense, 45

integration, 7

low barrier to entry, principle of, 2329

multiframework platforms, 1213

naming conventions, 480

OO design, 2

programming languages, 1112

progressive frameworks, 1215

prototyping, 2

scenario-driven framework design, 1623

self-documenting object models, principle of, 2936

simplicity, 34

trade-offs, 6

development of, 13

multiframework platforms, 1213

progressive frameworks, 1215

usability studies, scenario-driven framework design, 2123

well-designed frameworks, qualities of, 3

backward compatibility, 2

borrowing from existing proven designs, 67

consistency, 78

evolution, 7

expense, 45

integration, 7

OO design, 2

prototyping, 2

simplicity, 34

trade-offs, 6

G

generic interfaces, adding a second declaration to, 536537

generic type parameters, naming conventions, 7071

guidance (obsolete), 487488

Async Patterns, 502

cancellation, 512513

choosing between Async Patterns, 503504

Classic Async Patterns, 503509

Event-Based Async Patterns, 503504, 510512

incremental results, 516

Out parameters, 512

progress reporting, 513516

Ref parameters, 512

custom event handlers, 491492

custom exceptions, 492493

Dispose Patterns, finalizable types, 511517

namespaces, 489490

.Interop subnamespaces, 490

.Permissions subnamespaces, 489490

naming conventions, 488

serialization, 493

.NET serialization technologies, 493

usage guidelines, 493502

H

heavy API design processes, 2

Hungarian notation

C# style conventions, 482

naming conventions, 53, 482

hyphens (-), naming conventions, 53

I

“I” in comments, 483

IAsyncDisposable interface

Async Patterns, 362

Dispose Patterns, 391392

IAsyncEnumerable<T> interface, Async Patterns, 362365

ICloneable struct, usage guidelines, 308309

IComparable<T> struct, usage guidelines, 309311

identifiers

capitalization, 42, 44

camelCasing, 43

PascalCasing, 4244

naming conventions, 54

type parameters (generic), naming conventions, 7071

IDisposable method, Dispose Patterns, 377, 382383

IEnumerable<T> method, LINQ support, 402403

if.throw, C# style conventions, 480

implementation

Async Patterns, 355361

auto-implemented properties, 479

expression-bodied members, 478479

interface members, explicit implementation of, 148152

System.Uri, 322323

incremental results, Async Patterns, 516

indents, C# style conventions, 471472

indexed properties, designing, 161163

IndexOutOfRangeException, 276

inequality operators, 200202

infrastructure namespaces, 66

initializers, C# style conventions

collection initializers, 478

object initializers, 477478

instrumentation, exceptions and, 254

integration (well-designed frameworks), qualities of, 7

interfaces

abstractions, extensibility, 239241

adding, members, 541

base interfaces

adding to interfaces, 536

moving members to, 541

defined, 84

generic interfaces, adding a second declaration to, 536537

members

adding, 541

adding to interfaces, 541

implementing explicitly, 148152

moving to base interfaces, 541

naming conventions, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

type design guidelines, 92100, 104106

.Interop subnamespaces, 490

intuitive API, 3334

InvalidOperationException, 274275

IQueryable<T> method, LINQ support, 403404

J - K

keywords (language)

C# style conventions, 476

var, C# style conventions, 476477

L

language keywords, C# style conventions, 476

languages (programming), framework design, 1112

language-specific names, naming conventions, 5658

layered architecture, principle of, 3639

limiting, extensibility, 244246

LINQ (Language-Integrated Queries)

design patterns, 400408

overview of, 400401

support

IEnumerable<T> method, 402403

implementation, 402

IQueryable<T> method, 403404

query patterns, 404408

live collections, 301302

low barrier to entry, principle of, 2329

M

masking base members, 539

members

abstract members

adding, 539

changing to virtual members, 553

changing virtual members to, 553

removing an override of an abstract member, 543544

base members, masking, 539

changing, member signatures, 545553

constructors

designing, 165172

type constructors, 172175

designing

boolean parameters, 205207

conversion operators, 198-C05.1827

enum parameters, 205207

events, 175180

extension methods, 184192

fields, 180183

inequality operators, 200202

members with variable number of parameters, 214218

operator overloads, 192198

parameter argument validation, 207210

parameter passing, 210214

parameters, 202204

pointer parameters, 218219

tuples in member signatures, 220226

events, designing, 175180

expression-bodied members, 478479

interface members, implementing explicitly, 148152

masking base members, 539

methods, choosing, 152158

modifiers, C# style conventions, 473475

moving to

base classes, 541

base interfaces, 541

derived types, 542

non-override members, removing, 543

non-virtual members, changing to virtual members, 553

overloading, 136148, 544545

override members, 540

removing an override of a virtual member, 543

removing an override of an abstract member, 543544

parameters, designing, 202204

properties

change notification events, 163165

choosing, 152158

designing, 158160

indexed properties, 161163

protected members, extensibility, 230

signatures

changing, 545553

tuples in, 220226

unsealed types, adding members to, 539540

virtual members

changing abstract members to, 553

changing to abstract members, 553

extensibility, 237239

removing an override of a virtual member, 543

visibility, changing, 548549

metadata, assembly metadata and types, 127129

methods

Async methods

exceptions to, 359361

return types, 348351

Close() method, 382383

Dispose (bool) method, 376380

Dispose (true) method, 377378

extension methods, 184192

IDisposable method, Dispose Patterns, 377, 382383

IEnumerable<T> method, LINQ support, 402403

IQueryable<T> method, IQueryable<T> method, 403404

member methods, choosing, 152158

naming conventions, 7475, 196197

operators and method names, 196197

parameters

adding, 546

changing types, 546

removing, 546

renaming, 545

reordering parameters by the same type, 547

reordering parameters of differing types, 547

return types, changing, 547548

static TryParse methods, 286

struct methods

adding readonly modifiers, 550

removing readonly modifiers, 551

SuppressFinalize method, 378

synchronous methods, Async variants of, 353354

Try methods, value-producing Try methods, 284285

values returned type, changing from a method, 554555

modifiers

member modifiers, C# style conventions, 473475

readonly modifiers

adding to struct methods, 550

C# style conventions, 479

removing from struct methods, 551

static modifiers, adding/removing, 549

moving

members to

base classes, 541

base interfaces, 541

derived types, 542

types

via [TypeForwardedTo], 532533

without [TypeForwardedTo], 533

multiframework platforms, 1213

multiline syntax (/* . */), comments, 482

N

nameof (.) syntax, C# style conventions, 479

namespaces

adding namespaces that conflict with existing types, 531532

application models, 6566

core namespaces, 66

infrastructure namespaces, 66

naming conventions, 6367

obsolete guidance, 489490

subnamespaces

.Design subnamespaces, 489

.Interop subnamespaces, 490

.Permissions subnamespaces, 489490

naming conventions, 489490

technology namespace groups, 6667

type design guidelines, 8588

type names, changing, 535

type names, conflicts, 65

application models, 6566

core namespaces, 66

infrastructure namespaces, 66

technology namespace groups, 6667

naming conventions, 4142

abbreviations, 5556

acronyms, 5556

alphanumeric characters, 53

API, naming new versions of existing API, 5861

ASCII characters, 54

assemblies, 6162

brevity, 52

C# style conventions, 480482

camelCasing, 481, 482

capitalization, 42

acronyms, 4548

case sensitivity, 5152

compound words, 4851

identifiers, 4244

classes, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

common names, 5758

custom collections, 305

diacritical marks, 55

DLL, 6162

enumerations, 7274

events, 7778

fields, 7879

Framework Design Guidelines, 480

Hungarian notation, 53

hyphens (-), 53

identifiers, 54

capitalization, 4244

type parameters (generic), 7071

interfaces, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

language-specific names, 5658

methods, 7475, 196197

namespaces, 6367

obsolete guidance, 488

operators, 196197

overload operator parameters, 80

packages, 6162

parameters, 7980

PascalCasing, 480481

properties, 7576

readability, 52

resources, 81

self-documenting object models, 3032

structs, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

subnamespaces, 489490

type members, 74

events, 7778

fields, 7879

methods, 7475

properties, 7576

types (common), 71

underscores (_), 53, 481482

word choice, 5255

nested types, design guidelines, 124127

.NET serialization technologies, 493

non-override members, removing, 543

non-virtual members, changing to virtual members, 553

notification events, changing in properties, 163165

Nullable<T> struct, usage guidelines, 311312

NullReferenceException, 276

O

object initializers, C# style conventions, 477478

object models (self-documenting), principle of, 2930

abstractions, 3436

consistency, 34

exceptions, 33

naming, 3032

strong typing, 3334

Object.Equals, usage guidelines, 312314

reference types, 314

value types, 314

Object.GetHashCode, usage guidelines, 315316

object-oriented design, 2

object-oriented languages, exceptions and, 249250

Object-Oriented Programming, 2

objects, usage guidelines, 312

Object.Equals, 312314

Object.GetHashCode, 315316

Object.ToString, 316318

obsolete guidance, 487488

Async Patterns, 502

cancellation, 512513

choosing between Async Patterns, 503504

Classic Async Patterns, 503509

Event-Based Async Patterns, 503504, 510512

incremental results, 516

Out parameters, 512

progress reporting, 513516

Ref parameters, 512

custom event handlers, 491492

custom exceptions, 492493

Dispose Patterns, finalizable types, 511517

namespaces, 489490

.Design subnamespaces, 489

.Interop subnamespaces, 490

.Permissions subnamespaces, 489490

naming conventions, 488

serialization, 493

usage guidelines, serialization, 493502

OO (Object-Oriented) design, 2

OOP (Object-Oriented Programming), 2

OperationCanceledException, 278

operations (scoped), Dispose Patterns, 387391

OperationStatus value, buffer operators, 458463

operators

conversion operators, 198-C05.1827

equality operators

reference types, 328

usage guidelines, 324328

value types, 327

inequality operators, 200202

method names and, 196197

overloading, 192198

optional features, design patterns, 408411

optional parameters, changing

default values, 552

to required, 551552

required parameters to optional, 551

organization (files), C# style conventions, 483485

Out parameters, 512

OutOfMemoryException, 277278

overload operator parameters, naming conventions, 80

overloading

members, 136148, 544545

operators, 192198

override members

adding to unsealed types, 540

removing

removing an override of a virtual member, 543

removing an override of an abstract member, 543544

P

packages, naming conventions, 6162

parameters

argument validation, 207210

boolean parameters, choosing, 205207

collection parameters, 296297

designing, 202204

enum parameters, choosing, 205207

members with variable number of parameters, 214218

method parameters

adding, 546

changing types, 546

removing, 546

renaming, 545

reordering parameters by the same type, 547

reordering parameters of differing types, 547

naming conventions, 7980

optional parameters, changing

default values, 552

required parameters to optional, 551

to required, 551552

Out parameters, 512

overload operator parameters, naming conventions, 80

passing, 210214, 549550

pointer parameters, 218219

Ref parameters, 512

reference parameters

Async variants of existing synchronous methods, 352353

changing, 549550

required parameters, changing

optional parameters to, 551552

to optional, 551

Pareto principle, 10

partial writes to buffers, 458463

PascalCasing, 4244

C# style conventions, 480481

naming conventions, 480481

passing parameters, 210214

passive voice, comments, 483

performance, exceptions, 281

Tester-Doer Pattern, 281282

Try Pattern, 282286

.Permissions subnamespaces, 489490

personification, comments, 483

PlatformNotSupportedException, 279

pointer parameters, 218219

predetermined buffer sizes, 451452

private fields

removing, on serializable types, 544

renaming, in serializable types, 544

programming

languages, framework design, 1112

OOP, 78

progress reporting, Async Patterns, 513516

progressive frameworks, 1215

properties

auto-implemented properties, 479

change notification events, 163165

designing, 158160

change notification events, 163165

indexed properties, 161163

indexed properties, designing, 161163

member properties, choosing, 152158

naming conventions, 7576

events, 7778

fields, 7879

methods, 7475

properties, 7576

types, changing, 548

protected members, extensibility, 230

prototyping, well-designed frameworks, 2

Q - R

query patterns, LINQ support, 404408

RAD (Rapid Application Development), progressive frameworks, 13

readability, naming conventions, 52

readonly modifiers

C# style conventions, 479

structs

adding to, 535, 550

removing from, 535536, 551

recompile breaks, 530

Ref parameters, 512

ref structs, 538

reference parameters

Async variants of existing synchronous methods, 352353

changing, 549550

reference types

equality operators, 328

fields, adding to structs, 540

Object.Equals, 314

reflection breaks, 530

rehydration, Dispose Patterns, 381382

removing

finalizers

from sealed types, 542

from unsealed types, 542

method parameters, 546

non-override members, 543

override members

removing an override of a virtual member, 543

removing an override of an abstract member, 543544

private fields, on serializable types, 544

readonly modifiers from structs, 535536, 551

static modifiers, 549

types, 533

renaming

assemblies, 530531

method parameters, 545

private fields in serializable types, 544

reordering method parameters

of differing types, 547

by the same type, 547

reporting (progress), Async Patterns, 513516

required parameters, changing

to optional, 551

optional parameters to, 551552

return types

Async methods, 348351

method return types, changing, 547548

return values in collections, 298302

runtime breaks, 529

runtime error exceptions, changing to usage error exceptions, 553554

runtime serialization, 493, 500502

S

scenario-driven framework design, 1623

scoped operations, Dispose Patterns, 387391

sealed types

removing finalizers from, 542

unsealing, 534

sealing,

extensibility, 244246

unsealed types, 534

SEHException, 278

self-documenting object models, principle of, 2930

abstractions, 3436

consistency, 34

exceptions, 33

layered architecture, principle of, 3637

naming, 3032

strong typing, 3334

serializable types, private fields, 544

serialization

Binary serialization, 493

Data Contract serialization, 493, 495499

.NET serialization technologies, 493

obsolete guidance, 493502

runtime serialization, 493, 500502

SOAP serialization, 493

usage guidelines, 319321

XML serialization, 493, 499500

signatures (member)

changing, 545553

tuples in, 220226

simplicity, well-designed frameworks, 34

single-line syntax (// .), comments, 482

snapshot collections, 301302

SOAP serialization, 493

source-breaking changes

compilation breaks, 530

recompile breaks, 530

spaces, C# style conventions, 469470

Spans, 1112, 431445

specifications

sample specification, 523528

Stopwatch specification, 524528

StackOverflowException, 276277

static classes

defined, 84

type design guidelines, 102104

static modifiers, adding/removing, 549

static TryParse methods, 286

Stopwatch specification, 524528

strings (strongly typed), 129133

strong typing, self-documenting object models (principle of), 3334

structs

adding first reference type field to, 540

changing

changing classes to, 537

to classes, 537538

DateTime struct, 306308

DateTimeOffset struct, 306308

defined, 84

ICloneable struct, 308309

IComparable<T> struct, 309311

naming conventions, 6770

common types, 71

enumerations, 7274

generic type parameters, 7071

Nullable<T> struct, 311312

readonly modifiers

adding to structs, 535, 550

removing from structs, 535536, 551

ref structs, 538

type design guidelines, 8992, 106111

usage guidelines

DateTime struct, 306308

DateTimeOffset struct, 306308

ICloneable struct, 308309

IComparable<T> struct, 309311

Nullable<T> struct, 311312

ValueTask structs, Async Patterns, 358359

ValueTask<TResult> structs, Async Patterns, 358359

style conventions, C#465–466

ASCII characters, code restrictions, 479

assignment-expression-throw, 480

auto-implemented properties, 479

BCL type names, 476

braces ({ }), 466469

collection initializers, 478

commas ( , ), 475476

comments, 482483

expression-bodied members, 478479

file organization, 483485

if.throw, 480

indents, 465466

language keywords, 476

member modifiers, 473475

nameof (.) syntax, 479

naming conventions, 480482

object initializers, 477478

readonly modifiers, 479

spaces, 469470

this.476

Unicode escape sequences (uXXXX), 479

var keyword, 476477

vertical whitespace, 472473

subclassing, 13

subnamespaces

.Design subnamespaces, 489

.Interop subnamespaces, 490

naming conventions, 489490

.Permissions subnamespaces, 489490

SuppressFinalize method, Dispose Patterns, 378

synchronous methods, Async variants of, 353354

SystemException, 274

System.Object, usage guidelines, 312

Object.Equals, 312314

Object.GetHashCode, 315316

Object.ToString, 316318

System.Uri

implementation guidelines, 322323

usage guidelines, 321323

System.Xml, usage guidelines, 323324

T

Task-Based Aync Pattern, 341347

TaskCanceledException, 278

Task.Status, consistency, 355357

technology namespace groups, 6667

Template Method Pattern, 423425

Tester-Doer Pattern, exceptions and performance, 281282

this., C# style conventions, 476

throwing exceptions, 254260

choosing exceptions, 260264

error messages, 264265

from existing thrown types, 555

new types of error exceptions, 555

timeouts, 426427

trade-offs, well-designed frameworks, 6

Try Pattern, exceptions and performance, 282284

static TryParse methods, 286

value-producing Try methods, 284285

Try-Write Pattern, 452458

tuples in member signatures, 220226

types

abstractions, extensibility, 239241

assemblies

metadata and types, 127129

renaming, 530531

classes

abstract classes, 98102

defined, 84

static classes, 102104

type design guidelines, 89104

common types, naming conventions, 71

constructors, 172175

derived types, moving members to, 542

design guidelines, 8485

assembly metadata and types, 127129

classes, 89104

enums, 111124

interfaces, 92100, 104106

namespaces, 8588

nested types, 124127

strongly typed strings, 129133

structs, 8992, 106111

enums

adding values to, 123124

defined, 84

flag enums, 119123

type design guidelines, 111124

exception types, 273279

factored types, aggregate components, 334335

finalizable types, Dispose Patterns, 383387, 511517

interfaces

defined, 84

type design guidelines, 92100, 104106

logical groupings, 83

members

moving to derived types, 542

naming conventions, 79

method parameter types

changing, 546

reordering parameters of differing types, 547

moving

via [TypeForwardedTo], 532533

without [TypeForwardedTo], 533

names

case sensitivity, 534

changing namespaces, 535

namespaces

adding namespaces that conflict with existing types, 531532

name conflicts, 6567

obsolete guidance, 489490

type design guidelines, 8588

nested types, design guidelines, 124127

parameters (generic), naming conventions, 7071

property types, changing, 548

reference types

equality operators, 328

Object.Equals, 314

removing, 533

return types

Async methods, 348351

changing method return types, 547548

sealed types

removing finalizers from, 542

unsealing, 534

sealing unsealed types, 534

serializable types, private fields

removing, 544

renaming, 544

static classes, defined, 84

strings (strongly typed), 129133

structs

defined, 84

type design guidelines, 8992, 106111

unsealed types

adding members to, 539540

removing finalizers from, 542

value types, 99

equality operators, 327

Object.Equals, 314

values returned type, changing from a method, 554555

typing (strong), self-documenting object models, 3334

U

underscores (_), naming conventions, 53, 481482

unhandled exception handlers, 253

Unicode escape sequences (uXXXX), C# style conventions, 479

unsealed classes, extensibility, 228229

unsealed types

adding members to, 539540

removing finalizers from, 542

sealing, 534

Uri

implementation guidelines, 322323

usage guidelines, 321323

usability studies, designing frameworks, scenario-driven framework design, 2123

usage error exceptions, changing

to functioning behavior, 554

runtime error exceptions to, 553554

usage guidelines

arrays, 287291

attributes, 291294

collections, 294296

arrays versus collections, 302303

custom collections, 302303

live collections, 301302

parameters, 296297

properties, 298302

return values, 298302

snapshot collections, 301302

DateTime struct, 306308

DateTimeOffset struct, 306308

equality operators, 324328

ICloneable struct, 308309

IComparable<T> struct, 309311

Nullable<T> struct, 311312

Object.Equals, 312314

reference types, 314

value types, 314

Object.GetHashCode, 315316

objects, 312

Object.Equals, 312314

Object.GetHashCode, 315316

Object.ToString, 316318

Object.ToString, 316318

serialization, 319321, 493502

structs

DateTime struct, 306308

DateTimeOffset struct, 306308

ICloneable struct, 308309

IComparable<T> struct, 309311

Nullable<T> struct, 311312

System.Object, 312

Object.Equals, 312314

Object.GetHashCode, 315316

Object.ToString, 316318

System.Uri, 321323

System.Xml, 323324

Uri, 321323

uXXXX (Unicode escape sequences), C# style conventions, 479

V

validation

arguments, 207210, 480

assignment-expression-throw, 480

DP, 370

value coercion, DP, 371372

value types, 99

equality operators, 327

Object.Equals, 314

value-producing Try methods, 284285

values

constant field values, changing, 552

default values, changing in optional parameters, 552

values returned type, changing from a method, 554555

ValueTask structs, Async Patterns, 358359

ValueTask<TResult> structs, 358359

var keyword, C# style conventions, 476477

vertical whitespace, C# style conventions, 472473

virtual members

abstract members, changing to virtual members, 553

changing

to abstract members, 553

non-virtual members to, 553

extensibility, 237239

override members, removing an override of a virtual member, 543

visibility of members, changing, 548549

Visual Basic, language-specific names, 57

W

“we” in comments, 483

well-designed frameworks, qualities of, 3

backward compatibility, 2

consistency, 78

evolution, 7

existing proven designs, borrowing from, 67

expense, 45

integration, 7

OO design, 2

prototyping, 2

simplicity, 34

trade-offs, 6

whitespace (vertical), C# style conventions, 472473

word choice, naming conventions, 5255

wrapping exceptions, 271273

X - Y - Z

XAML readable types, 427430

XML serialization, 493, 499500

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.169.94