Oxidizer does not recognize local functions


(Theo) #1

The example code of Microsoft:

using System;
using System.IO;

class Example
{
    static void Main()
    {
        string contents = GetText(@"C:\temp", "example.txt");
        Console.WriteLine("Contents of the file:\n" + contents);
    }
   
    private static string GetText(string path, string filename)
    {
         var sr = File.OpenText(AppendPathSeparator(path) + filename);
         var text = sr.ReadToEnd();
         return text;
         
         // Declare a local function.
         string AppendPathSeparator(string filepath)
         {
            if (! filepath.EndsWith(@"\"))
               filepath += @"\";

            return filepath;   
         }
    } 
}

Is generation the following:

namespace;

interface

uses
  System,
  System.IO;

type
  Example = class
    class method Main;
  private
    class method GetText(path: String; filename: String): String;
  end;

implementation

class method Example.Main;
begin
  var contents: String := GetText('C:\temp', 'example.txt');
  Console.WriteLine('Contents of the file:'#10 + contents);
end;

class method Example.GetText(path: String; filename: String): String;
begin
  var sr := File.OpenText(AppendPathSeparator(path) + filename);
  var text := sr.ReadToEnd();
  exit text;
  //  Declare a local function.
  #errorstring AppendPathSeparator(filepath:string)
end;

end.

(RemObjects) #2

Thanks, logged as bugs://82113