/// <summary> /// Get the MSBuild object (if any) at the specified position in the project file. /// </summary> /// <param name="position"> /// The target position. /// </param> /// <returns> /// The MSBuild object, or <c>null</c> no object was found at the specified position. /// </returns> public MSBuildObject GetMSBuildObjectAtPosition(Position position) { if (!HasMSBuildProject) { throw new InvalidOperationException($"MSBuild project '{ProjectFile.FullName}' is not loaded."); } if (IsMSBuildProjectCached) { throw new InvalidOperationException($"MSBuild project '{ProjectFile.FullName}' is a cached (out-of-date) copy because the project XML is currently invalid; positional lookups can't work in this scenario."); } return(MSBuildLocator.Find(position)); }