US8370801B2

Architecture that extends types using extension methods

Summary by NHIP

Extension Method Invocation

The method extends data models by treating static extension methods as instance methods during processing. It rewrites invocations with identifiers resolved via namespace declarations and method groups containing all accessible extension methods sharing that name.

Claim Score by NHIP

Read claim 1, the broadest

Abstract

Architecture that extends existing types including constructed and sealed types using extension methods. Extension methods are static methods that can be invoked using instance method syntax. Extension methods are declared by specifying the keyword “this” as a modifier on the first parameter of the methods. Extension methods have all the capabilities of regular static methods. In addition, once imported, extension methods can be invoked using instance method syntax. Also disclosed are rules for importing extension methods, and extension method invocations. Extension methods are imported through using-namespace-directives. In addition to importing the types contained in a namespace, a using-namespace-directive imports all extension methods in all static classes in the namespace. In effect, imported extension methods appear as additional methods on the types that are given by their first parameter and have lower precedence than regular instance methods.

US8370801B2, drawing sheet 1
Sheet 1 of 12

Term

Term ended

Expired 17 July 2026, 0.2 years ago.

  1. Priority
  2. Filed
  3. Granted
  4. Expired
  5. Today

20 claims: 3 independent, 17 dependent

  1. 1
    Broadest claimClaim Score 52, average(NHIP)A computer-implemented method of extending data model and operations without needing to modify existing codes, the method comprising:statically processing invocation of an extension method of a static type by treating the extension method as a normal instance method rather than as a method having declaration syntax;determining that static processing invocation of the extension method includes an instance method and, as a result, rewriting the instance method with at least one identifier followed by an expression;and processing the rewritten instance method as a static method invocation, except for resolving of the at least one identifier, which has special identifier processing, the special identifier processing including namespace processing that begins with a closest namespace declaration and uses a method group that includes all accessible extension methods having a name given by the at least one identifier.
  2. 14
    A computer-readable storage medium having stored thereon computer executable instructions that, when executed by one or more processors, cause a computing system to perform a method for extending data model and operations without needing to modify existing codes, the method comprising:statically processing invocation of an extension method of a static type by treating the extension method as a normal instance method rather than as a method having declaration syntax;determining that static processing invocation of the extension method includes an instance method and, as a result, rewriting the instance method with at least one identifier followed by an expression;and processing the rewritten instance method as a static method invocation, except for resolving of the at least one identifier, which has special identifier processing, the special identifier processing including namespace processing that begins with a closet closest namespace declaration and uses a method group that includes all accessible extension methods having a name given by the at least one identifier.
  3. 20
    A system for extending data model and operations without needing to modify existing codes, the system comprising:one or more processors;one or more computer-readable media having stored thereon computer-executable instructions that, when executed by the one or more processors, cause the system to: statically process invocation of an extension method of a static type by treating the extension method as a normal instance method rather than as a method having declaration syntax;determine that static processing invocation of the extension method includes an instance method and, as a result, rewriting the instance method with at least one identifier followed by an expression;and process the rewritten instance method as a static method invocation, except for resolving of the at least one identifier, which has special identifier processing, the special identifier processing including namespace processing that begins with a closest namespace declaration and uses a method group that includes all accessible extension methods having a name given by the at least one identifier.