Bug 1896 - MonoDevelop.Ide.TextFileProvider has serious problems
Summary: MonoDevelop.Ide.TextFileProvider has serious problems
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Mac OS
: Normal major
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-11-05 15:16 UTC by Mikayla Hutchinson [MSFT]
Modified: 2016-11-05 05:35 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2011-11-05 15:16:37 UTC
MonoDevelop.Ide.TextFileProvider has big problems.

* It doesn't handle encoding.
* It doesn't perform atomic writes.

Using MonoDevelop.Projects.Text.TextFile instead of System.IO.File would fix this.

The API also has serious perf problems - on each insertion/deletion, it writes the whole file to the disk. Oddly, if the whole file is changed by setting the Text property, it's not written.
Comment 1 Jeffrey Stedfast 2011-12-19 17:35:42 UTC
Fixed the first 2 items in git master, but not the perf problem.
Comment 2 Mike Krüger 2012-04-15 04:04:10 UTC
The text file provider API should never be used. I suggest using always a TextDocument for doing text changes.
It provides a rich API for handling common document operations (lines/columns model, diffing, searching etc.)

And for reading/writing text files the TextFileUtility class from the text editor. It has atm the best encoding detection we have in monodevelop.
Comment 3 Mikayla Hutchinson [MSFT] 2012-04-17 10:26:55 UTC
Then we should change the ITextFileProvider API to provide a TextDocument. It has an important purpose - transparently editing a file whether it's on disk or open in the text editor.
Comment 4 Marius Ungureanu 2016-11-05 05:35:10 UTC
This seems to be fixed.