GitNexus/gitnexus/test/fixtures/lang-resolution/csharp-method-chain-binding/App.cs
Gergo Magyar e6b8edc1ac feat: Phase 9C unified fixpoint with field access and method-call-result binding
Replace the sequential Tier 2b/2a propagation with a unified fixpoint
loop that handles four binding kinds: callResult, copy, fieldAccess,
and methodCallResult. The loop iterates until no new bindings are
produced (max 10 iterations), enabling arbitrary-depth mixed chains:

  const user = getUser();       // callResult → User
  const addr = user.address;    // fieldAccess → Address
  const city = addr.getCity();  // methodCallResult → City
  city.save();                  // resolves to City#save

Infrastructure:
- PendingAssignment union extended with fieldAccess and methodCallResult
- resolveFieldType helper: typeName → class nodeId → lookupFieldByOwner
- resolveMethodReturnType helper: typeName → class nodeId → lookupFuzzyCallable filtered by ownerId
- Fixpoint also resolves reverse-order copy chains that single-pass missed

Languages: TS, JS, Java, Kotlin, C#, Go, Rust, Python, PHP, Ruby, C++.
Each gets field access and/or method-call-with-receiver detection in
extractPendingAssignment, plus method-chain-binding test fixtures.
2026-03-19 11:50:50 +00:00

29 lines
651 B
C#

class City {
public string Name { get; set; }
public City(string name) { Name = name; }
public bool Save() { return true; }
}
class Address {
public City City { get; set; }
public Address(City city) { City = city; }
public City GetCity() { return City; }
}
class User {
public Address Address { get; set; }
public User(Address address) { Address = address; }
}
class App {
static User GetUser() {
return new User(new Address(new City("NYC")));
}
void ProcessChain() {
var user = GetUser();
var addr = user.Address;
var city = addr.GetCity();
city.Save();
}
}