private int Execute(Arguments arguments)
        {
            var errors = new List <string>();

            Log.Info("Checking required executables and libraries can be found and loaded");

            // this is an important call used in analyze long recordings.
            // This call effectively check is we can load types and if files are present (I think)
            try
            {
                AnalysisCoordinator.GetAnalyzers <IAnalyser2>(typeof(MainEntry).Assembly);
            }
            catch (ReflectionTypeLoadException rtlex)
            {
                errors.Add(ExceptionLookup.FormatReflectionTypeLoadException(rtlex, true));
            }

            // master audio utility checks for available executables
            try
            {
                var utility = new MasterAudioUtility();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
            }

            if (MainEntry.CheckForDataAnnotations() is string message)
            {
                errors.Add(message);
            }


            Type type = Type.GetType("Mono.Runtime");

            if (type != null)
            {
                errors.Add($"We no longer use Mono with ${Meta.Name}. DO NOT prefix the {Meta.Name} prefix with `mono`.");
            }


            // don't have much more to check at the current time
            if (errors.Count == 0)
            {
                Log.Success("Valid environment");

                return(ExceptionLookup.Ok);
            }
            else
            {
                foreach (var error in errors)
                {
                    Log.Error(error);
                }

                // not using exception lookup on purpose - it's static constructor loads more types
                return(ExceptionLookup.UnhandledExceptionErrorCode);
            }
        }
Ejemplo n.º 2
0
        public void TestExceptionEnumerations_FromPrivateMethod()
        {
            var type   = GetTypeDef <ExceptionTestClass> ();
            var member = type.Methods.Single(m => m.Name == "ThrowFromPrivateMethod");

            var sources = new ExceptionLookup(ExceptionLocations.DependentAssemblies)[member];

            Assert.IsNotNull(sources);
            Assert.AreEqual(0, sources.Count());
        }
Ejemplo n.º 3
0
        public void TestExceptionEnumerations_FromPublicMethod()
        {
            var type   = GetTypeDef <ExceptionTestClass> ();
            var member = type.Methods.Single(m => m.Name == "ThrowFromPublicMethod");

            var sources = new ExceptionLookup(ExceptionLocations.Assembly)[member];

            Assert.IsNotNull(sources);
            Assert.AreEqual(1, sources.Count());
            var source = sources.First();

            Assert.AreEqual("ThrowItPublic", source.Sources.First().Name);
        }
Ejemplo n.º 4
0
        private int Execute(Arguments arguments)
        {
            var errors = new List <string>();

            Log.Info("Checking required executables and libraries can be found and loaded");

            // this is an important call used in analyze long recordings.
            // This call effectively check is we can load types and if files are present (I think)
            try
            {
                AnalysisCoordinator.GetAnalyzers <IAnalyser2>(typeof(MainEntry).Assembly);
            }
            catch (ReflectionTypeLoadException rtlex)
            {
                errors.Add(ExceptionLookup.FormatReflectionTypeLoadException(rtlex, true));
            }

            // master audio utility checks for available executables
            try
            {
                var utility = new MasterAudioUtility();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
            }

            if (MainEntry.CheckForDataAnnotations() is string message)
            {
                errors.Add(message);
            }

            if (AppConfigHelper.IsMono)
            {
                Type type = Type.GetType("Mono.Runtime");
                if (type != null)
                {
                    MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);

                    if (displayName?.Invoke(null, null) is string name)
                    {
                        var version = Regex.Match(name, @".*(\d+\.\d+\.\d+\.\d+).*").Groups[1].Value;
                        Console.WriteLine(version);
                        if (new Version(version) > new Version(5, 5))
                        {
                            Log.Success($"Your mono version {name} is greater than our required Mono version 5.5");
                        }
                        else
                        {
                            errors.Add($"Mono version is {name}, we require at least Mono 5.5");
                        }
                    }
                    else
                    {
                        errors.Add("Could not get Mono display name");
                    }
                }
            }

            // don't have much more to check at the current time
            if (errors.Count == 0)
            {
                Log.Success("Valid environment");

                return(ExceptionLookup.Ok);
            }
            else
            {
                foreach (var error in errors)
                {
                    Log.Error(error);
                }

                // not using exception lookup on purpose - it's static constructor loads more types
                return(ExceptionLookup.UnhandledExceptionErrorCode);
            }
        }