示例#1
0
        private static Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
        {
            var assembly = (Assembly)null;

            Directory.EnumerateFiles(AssembliesHelper.GetFolderPath(), "*.dll")
            .Aggregate(0, (seed, file) =>
            {
                try
                {
                    var asm = Assembly.LoadFile(file);
                    if (asm.FullName == args.Name)
                    {
                        assembly = asm;
                    }
                }
                catch (Exception ex)
                {
                    Log.Debug(ex, string.Empty);
                }

                return(++seed);
            });

            return(assembly);
        }
示例#2
0
        static void Main()
        {
            Configuration = new ConfigurationBuilder()
                            .Build();

            DependencyInjection();

            // Make sure all our assemblies are loaded...
            AssembliesHelper.LoadAllAssembliesForExecutingContext();

            if (Configuration.GetSection("EnableTFAService").Value == null)
            {
                Console.WriteLine("*** Warning! **** Check for missing configuration values. e.g EnableTFAService");
            }

            Console.WriteLine("**** Configuration Settings ****");
            foreach (var env in Configuration.GetChildren())
            {
                Console.WriteLine($"{env.Key}:{env.Value}");
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
示例#3
0
    public ActionResult Index()
    {
        var prefixes = new[] { "COR_", "CORECLR_", "DOTNET_", "OTEL_" };

        var envVars = from envVar in Environment.GetEnvironmentVariables().Cast <DictionaryEntry>()
                      from prefix in prefixes
                      let key                         = (envVar.Key as string)?.ToUpperInvariant()
                                            let value = envVar.Value as string
                                                        where key.StartsWith(prefix)
                                                        orderby key
                                                        select new KeyValuePair <string, string>(key, value);

        var instrumentationType =
            Type.GetType("OpenTelemetry.AutoInstrumentation.Instrumentation, OpenTelemetry.AutoInstrumentation");

        ViewBag.EnvVars          = envVars;
        ViewBag.HasEnvVars       = envVars.Any();
        ViewBag.ProfilerAttached =
            instrumentationType?.GetProperty("ProfilerAttached", BindingFlags.Public | BindingFlags.Static)
            ?.GetValue(null) ?? false;
        ViewBag.TracerAssemblyLocation = instrumentationType?.Assembly.Location;
        ViewBag.TracerAssemblies       = AssembliesHelper.GetLoadedTracesAssemblies();
        ViewBag.AllAssemblies          = AssembliesHelper.GetLoadedAssemblies();

        return(View());
    }
示例#4
0
        /// <summary>
        /// Initialises the ApexBroker, allowing it to be used.
        /// </summary>
        public static void Initialise()
        {
            //  Always lock for this method.
            lock (syncLock)
            {
                //  We may have already been initialised.
                if (isInitialised)
                {
                    return;
                }

                //  Enumerate all types to search.
                var typesToSearch = AssembliesHelper.GetTypesInDomain().ToList();

                //  Find every type that has the Model attribute.
                var modelTypes = from t in typesToSearch
                                 where t.GetCustomAttributes(typeof(ModelAttribute), false).Any()
                                 select new
                {
                    ModelType      = t,
                    ModelAttribute = (ModelAttribute)t.GetCustomAttributes(typeof(ModelAttribute), false).Single()
                };

                //  Go through each model type, construct it and register it as a model.
                foreach (var modelType in modelTypes)
                {
                    //  Create the model instance.
                    var modelInstance = Activator.CreateInstance(modelType.ModelType);

                    //  If the model implements the IModel interface, notify it that it can be initialised.
                    if (modelInstance is IModel)
                    {
                        ((IModel)modelInstance).OnInitialised();
                    }

                    //  Store the model.
                    modelInstances.Add(modelInstance);
                }

                //  Find every type that has the View attribute.
                var viewTypes = from t in typesToSearch
                                where t.GetCustomAttributes(typeof(ViewAttribute), false).Any()
                                select new
                {
                    ViewType      = t,
                    ViewAttribute = (ViewAttribute)t.GetCustomAttributes(typeof(ViewAttribute), false).Single()
                };

                //  Register each view to viewmodel.
                foreach (var viewType in viewTypes)
                {
                    //  Register the mapping.
                    RegisterViewForViewModel(viewType.ViewAttribute.ViewModelType, viewType.ViewType);
                }

                //  We're now initialised.
                isInitialised = true;
            }
        }
示例#5
0
    protected override void Awake()
    {
        body = this.GetComponentUpwards <ChipmunkBody>();

        if (!String.Empty.Equals(MonoBehaviourName))
        {
            Type type = AssembliesHelper.GetType(MonoBehaviourName);
            ownMono = this.GetComponent(type) as MonoBehaviour;
        }
    }
示例#6
0
        static void Main()
        {
            DependencyInjection();

            // Make sure all our assemblies are loaded...
            AssembliesHelper.LoadAllAssembliesForExecutingContext();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
示例#7
0
        public MainForm()
        {
            InitializeComponent();
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
            styleCopAnalyzerAssembly = AssembliesHelper.GetAnalyzersAssembly();
            styleCopFixersAssembly   = AssembliesHelper.GetCodeFixAssembly();
            SeedCheckList();
            var autoCompleteSource = new AutoCompleteStringCollection();

            autoCompleteSource.AddRange(analyzers.SelectMany(x => x.SupportedDiagnostics).Select(x => $"{x.Id}: {x.Title}")
                                        .ToArray());
            autoCompleteTextBox.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            autoCompleteTextBox.AutoCompleteCustomSource = autoCompleteSource;
            autoCompleteTextBox.TextChanged += AutoCompleteTextBox_TextChanged;
            Text          += $" {ApplicationVersionUtility.GetVersion()}";
            DoubleBuffered = true;
        }
示例#8
0
        private void ObjectSaving(object sender, ObjectManipulatingEventArgs e)
        {
            var compilationHelper = new ScriptCompilationHelper(AssembliesHelper.GetReferencedAssembliesPaths(Application));
            var script            = (e.Object as IDashboardDataExtract).Script;
            var tempFile          = Path.GetTempFileName();
            var compileResult     = compilationHelper.Compile(script, tempFile);

            File.Delete(tempFile);

            if (!compileResult.Success)
            {
                var errors = compileResult.Diagnostics
                             .Where(o => o.Severity == DiagnosticSeverity.Error)
                             .Select(o => o.ToString());

                throw new UserFriendlyException(string.Join("\n", errors));
            }
        }
示例#9
0
        /// <summary>
        /// Determines the execution context.
        /// </summary>
        /// <returns>The current execution context.</returns>
        private static ExecutionContext DetermineExecutionContext()
        {
#if SILVERLIGHT
            //  We can check the designer properties in Silverlight to
            //  determine whether we're in the desinger.
            if (DesignerProperties.IsInDesignTool)
            {
                return(ExecutionContext.Design);
            }
#else
            //  We can check the IsInDesignModeProperty property in WPF to
            //  determine whether we're in the desinger.
            var prop = DesignerProperties.IsInDesignModeProperty;
            if ((bool)DependencyPropertyDescriptor
                .FromProperty(prop, typeof(FrameworkElement))
                .Metadata.DefaultValue == true)
            {
                return(ExecutionContext.Design);
            }
#endif

            //  Test assemblies we know about.
            var  unitTestFrameworkMS    = @"microsoft.visualstudio.qualitytools.unittestframework";
            var  unitTestFrameworkNunit = @"nunit.framework";
            bool isUnitTest             = AssembliesHelper.GetDomainAssemblies().Any(a =>
                                                                                     (a.FullName.ToLower().StartsWith(unitTestFrameworkMS) ||
                                                                                      a.FullName.ToLower().StartsWith(unitTestFrameworkNunit)));

            //  If we're not in a unit test, we're in the designer.
            if (isUnitTest)
            {
                return(ExecutionContext.Test);
            }

            //  We're just running code.
            return(ExecutionContext.Standard);
        }
示例#10
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.LiterateConsole()
                         .CreateLogger();

            if (args.Length == 0)
            {
                Console.WriteLine(Args.Usage);
                return;
            }

            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;

                var options = new Args(args);
                if (options.ShowVersion)
                {
                    Log.Information($"Saritasa Prettify - {GetVersionOfExecutionAssembly()}");
                }

                var styleCopAnalyzerAssembly = AssembliesHelper.GetAnalyzersAssembly();
                var styleCopFixersAssembly   = AssembliesHelper.GetCodeFixAssembly();

                var analyzers = DiagnosticHelper.GetAnalyzersFromAssemblies(new[] { styleCopAnalyzerAssembly, styleCopFixersAssembly });
                var codeFixes =
                    CodeFixProviderHelper.GetFixProviders(new[] { styleCopAnalyzerAssembly, styleCopFixersAssembly })
                    .Where(x => options.Rules == null || options.Rules.Contains(x.Key))
                    .ToList();

                var workspace = MSBuildWorkspace.Create();
                var solution  = workspace.OpenSolutionAsync(options.SolutionPath).Result;

                foreach (var solutionProject in solution.Projects)
                {
                    var diagnostics = ProjectHelper.GetProjectAnalyzerDiagnosticsAsync(analyzers, solutionProject, true).Result
                                      .Where(x => options.Rules == null || options.Rules.Contains(x.Id))
                                      .ToList();

                    Log.Information("<======= Project: {project} =======>", solutionProject.Name);
                    if (!diagnostics.Any())
                    {
                        Log.Information("Can't find any diagnostic issues for {@rules}", options.Rules);
                        continue;
                    }

                    foreach (var projectAnalyzer in diagnostics)
                    {
                        Log.Information("DiagnosticId {@id} - {message} in file {path}({row},{column})", projectAnalyzer.Id, projectAnalyzer.GetMessage(), GetFormattedFileName(projectAnalyzer.Location.GetLineSpan().Path),
                                        projectAnalyzer.Location.GetLineSpan().StartLinePosition.Line, projectAnalyzer.Location.GetLineSpan().StartLinePosition.Character);
                    }

                    if (options.Rules == null && options.Mode == Args.RunningMode.Fix)
                    {
                        Log.Warning("Please specify rules for fix");
                        break;
                    }

                    if (options.Mode == Args.RunningMode.Fix)
                    {
                        var diagnistics = DiagnosticHelper.GetAnalyzerDiagnosticsAsync(solution, analyzers, true).Result;

                        foreach (var keyValuePair in codeFixes)
                        {
                            var equivalenceGroups = new List <CodeFixEquivalenceGroup>();

                            keyValuePair.Value.ForEach(x =>
                            {
                                equivalenceGroups.AddRange(CodeFixEquivalenceGroup.CreateAsync(x, diagnistics, solution).Result);
                            });

                            if (!equivalenceGroups.Any())
                            {
                                continue;
                            }

                            var fix = equivalenceGroups[0];

                            if (equivalenceGroups.Count() > 1)
                            {
                                Log.Warning("Allowed only one equivalence group for fix");
                                continue;
                            }

                            var operations = fix.GetOperationsAsync().Result;
                            if (operations.Length == 0)
                            {
                                Log.Information("No changes was found for this fixer");
                            }
                            else
                            {
                                operations[0].Apply(workspace, default(CancellationToken));
                                Log.Information("Fixer with DiagnosticId {@id} was applied ", keyValuePair.Key);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, string.Empty);
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            Log4NetAspExtensions.ConfigureLog4Net("TRex");

            DependencyInjection();

            // Make sure all our assemblies are loaded...
            AssembliesHelper.LoadAllAssembliesForExecutingContext();

            Log = VSS.TRex.Logging.Logger.CreateLogger <Program>();

            Log.LogInformation("Initialising TAG file processor");

            try
            {
                // Pull relevant arguments off the command line
                if (args.Length < 2)
                {
                    Console.WriteLine("Usage: ProcessTAGFiles <ProjectUID> <FolderPath>");
                    Console.ReadKey();
                    return;
                }

                Guid   projectID = Guid.Empty;
                string folderPath;
                try
                {
                    projectID  = Guid.Parse(args[0]);
                    folderPath = args[1];
                }
                catch
                {
                    Console.WriteLine($"Invalid project ID {args[0]} or folder path {args[1]}");
                    Console.ReadKey();
                    return;
                }

                if (projectID == Guid.Empty)
                {
                    return;
                }

                try
                {
                    if (args.Length > 2)
                    {
                        AssetOverride = Guid.Parse(args[2]);
                    }
                }
                catch
                {
                    Console.WriteLine($"Invalid Asset ID {args[2]}");
                    return;
                }

                ProcessTAGFilesInFolder(projectID, folderPath);

                // ProcessMachine10101TAGFiles(projectID);
                // ProcessMachine333TAGFiles(projectID);

                //ProcessSingleTAGFile(projectID, TAGTestConsts.TestDataFilePath() + "TAGFiles\\Machine10101\\2085J063SV--C01 XG 01 YANG--160804061209.tag");
                //ProcessSingleTAGFile(projectID);

                // Process all TAG files for project 4733:
                //ProcessTAGFilesInFolder(projectID, TAGTestConsts.TestDataFilePath() + "TAGFiles\\Model 4733\\Machine 1");
                //ProcessTAGFilesInFolder(projectID, TAGTestConsts.TestDataFilePath() + "TAGFiles\\Model 4733\\Machine 2");
                //ProcessTAGFilesInFolder(projectID, TAGTestConsts.TestDataFilePath() + "TAGFiles\\Model 4733\\Machine 3");
                //ProcessTAGFilesInFolder(projectID, TAGTestConsts.TestDataFilePath() + "TAGFiles\\Model 4733\\Machine 4");
            }
            finally
            {
            }
        }