c# - StackTrace, line info of fluent call -
given following fluent api calls: foo() .bar1(() => { ... }) .bar2(() => { ... }) .bar3(); i want determine code file , line number of bar1, bar2 , bar3 lines later down (eh... up) call stack... case 1: ...inside bar1/bar2/bar3 extension methods. my current solution: create stack trace inside methods , find information. open problems: line information belongs foo() line, not bar#(...) -line :( case 2: ...later on, somewhere else in code, in case given delegate throws exception when executed. my current solution: examine stack trace of exception , find correct line : ) special case 3: bar3 defines delegate inside method, still want .bar3() line when such delegate throws exception. my current solution: don't know yet, delegate created somewhere else , can't use same method in case 2. chance information case1, however, information not correct (wrong line number). q: know how determine correct code file , line number in 3 cases? ...