Effectively revert previous change to Generator.cs

pull/288/head
Jon Skeet 14 years ago
parent 7ac20214e0
commit 12f0460a71
  1. 22
      src/ProtoGen/Generator.cs

@ -93,25 +93,9 @@ namespace Google.ProtocolBuffers.ProtoGen {
/// </summary>
private void Generate(FileDescriptor descriptor) {
UmbrellaClassGenerator ucg = new UmbrellaClassGenerator(descriptor);
string tempFile = Path.GetTempFileName();
try {
using (Stream fstream = File.Open(GetOutputFile(descriptor), FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read)) {
using (TextWriter textWriter = File.CreateText(tempFile)) {
TextGenerator writer = new TextGenerator(textWriter);
ucg.Generate(writer);
}
fstream.SetLength(0);
using (TextReader input = new StreamReader(tempFile))
using (TextWriter output = new StreamWriter(fstream)) {
string line;
while (null != (line = input.ReadLine()))
output.WriteLine(line);
}
}
}
finally {
if (File.Exists(tempFile))
File.Delete(tempFile);
using (TextWriter textWriter = File.CreateText(GetOutputFile(descriptor))) {
TextGenerator writer = new TextGenerator(textWriter);
ucg.Generate(writer);
}
}

Loading…
Cancel
Save