Partial Methods for Machine-Generated Code Customization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Machine-generated source code often requires customization, but direct modifications can be lost if the code generator is re-run, and existing methods lack efficient ways to handle partial method implementations, leading to overhead costs for unused functionality.

Innovation Solution

The method involves defining partial methods with explicit hook points in the source code, allowing separate implementation by other parties, which can be injected into the code, and treating unimplemented partial methods as no-operation instructions to avoid overhead costs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If machine-generated source code is directly modified for customization, then code flexibility is improved, but modifications are lost when the code generator is re-run

Engineering Contradiction:
Improvecode customization flexibilityVSAvoidmodification persistence
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The code is segmented into machine-generated portions and user-customizable portions. Partial methods provide explicit boundaries where user code can be injected into the generated code structure, allowing modifications to persist separately from the generated code.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The code generator pre-defines partial method hooks and signatures in the generated code before user customization. This preliminary structure prepares explicit insertion points that guide user modifications and ensure they are preserved during code regeneration.

Inventive Principle:
Principle #10Preliminary action

2Adaptability or versatility

If partial method implementations are always provided, then code functionality is improved, but execution overhead increases for unused functionality

Engineering Contradiction:
Improvecode functionalityVSAvoidexecution overhead
Core Design Contradiction:
Adaptability or versatilityVSUse of energy by moving object

Solution Approach 1:

Instead of requiring complete partial method implementations, the system allows optional partial implementations. Users provide only the specific functionality they need, and the compiler eliminates unnecessary code, avoiding overhead for unused functionality.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system changes the parameter of partial method implementation from mandatory to optional. This parameter change allows the code to adapt its execution path based on whether a partial implementation exists, eliminating overhead for cases where no customization is needed.

Inventive Principle:
Principle #35Parameter changes

3Ease of repair

If multiple parties collaborate on code in separate files, then code maintainability is improved, but integration complexity increases

Engineering Contradiction:
Improvecode maintainabilityVSAvoidintegration complexity
Core Design Contradiction:
Ease of repairVSDevice complexity

Solution Approach 1:

Partial methods serve as intermediary contracts between machine-generated code and user customization. The compiler acts as a mediator that automatically integrates separate files containing partial method implementations into the generated code structure, reducing manual integration complexity.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The partial method mechanism provides a universal interface that works for all types of code generation scenarios. Whether code is generated from visual designers, database schemas, or other sources, the same partial method approach enables collaboration and integration across different file types and generation tools.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS7890939B2Partial methods
Publication Date: 2011.02.15 MICROSOFT TECHNOLOGY LICENSING LLC
  • US7890939B2 patent drawing
  • US7890939B2 patent drawing
  • US7890939B2 patent drawing

AI summary

Partial methods enable separation of method declaration and/or calls from method implementation. A partial method specifies a signature of a join or hook point in a class. Calls to a partial method specify a join or hook point in code that can optionally be linked with an actual method implementation of the same signature. Separate method implementations or other code related to a partial method are injected into a single program prior to execution. Unimplemented partial methods are treated as no operation instructions or otherwise ignored.