Ejemplo n.º 1
0
        internal Cleaner(BlazorFile _blazorFile, int _phase)
        {
            blazorFile = _blazorFile;

            phase = _phase;

            ProcessFile();
        }
        public IActionResult Post([FromBody] BlazorFile file)
        {
            _logger.LogDebug("Saving file...");
            _azureFile.SaveFileAsync(file);

            _logger.LogDebug("File saved!");

            return(Ok());
        }
Ejemplo n.º 3
0
        public async Task SaveFileAsync(BlazorFile file)
        {
            // Create a BlobServiceClient object which will be used to create a container client
            BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

            // Create the container and return a container client object
            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);

            await containerClient.UploadBlobAsync(file.FileName, new MemoryStream(file.FileInfo));
        }
Ejemplo n.º 4
0
        public async Task <BlazorFile> GetInfoFile(string fileName)
        {
            // Create a BlobServiceClient object which will be used to create a container client
            BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

            // Create the container and return a container client object
            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);

            var blobFile         = containerClient.GetBlobClient(fileName);
            var fileInfoInMemory = await blobFile.DownloadAsync();

            MemoryStream ms = new MemoryStream();

            await fileInfoInMemory.Value.Content.CopyToAsync(ms);

            var newBlazorFile = new BlazorFile()
            {
                FileName = blobFile.Name, FileInfo = ms.ToArray()
            };

            return(newBlazorFile);
        }
Ejemplo n.º 5
0
        public async Task <IEnumerable <BlazorFile> > GetFiles()
        {
            // Create a BlobServiceClient object which will be used to create a container client
            BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

            // Create the container and return a container client object
            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);

            var blobs = containerClient.GetBlobs(Azure.Storage.Blobs.Models.BlobTraits.All, Azure.Storage.Blobs.Models.BlobStates.Version);
            List <BlazorFile> list = new List <BlazorFile>();

            foreach (var item in blobs)
            {
                var newBlazorFile = new BlazorFile()
                {
                    FileName = item.Name
                };
                list.Add(newBlazorFile);
            }

            return(list);
        }
Ejemplo n.º 6
0
 internal Mangler(BlazorFile _blazorFile)
 {
     blazorFile = _blazorFile;
     ProcessFile();
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            TimeAnalyzer.StartTimeCounter();

            LocalData.appMode = AppMode.CleanDeadCodeAndMangle;

            LocalData.inputDir  = new DirectoryInfo("E:/monocecil/_bin");
            LocalData.outputDir = new DirectoryInfo("E:/monocecil/_bin2");

            LocalData.resolver.AddSearchDirectory(LocalData.outputDir.FullName);

            LocalData.CleanerRepeatCount = 3;

            LocalData.verbose      = true;
            LocalData.verboseDeep  = false;
            LocalData.manglePublic = false;

            LocalFunctions.EnsureOutputDirectory();

            FileInfo[] files = LocalData.inputDir.GetFiles("*.dll", SearchOption.AllDirectories);


            if (files.Count() > 0)
            {
                LocalData.BlazorFilesList = new List <BlazorFile>();
                foreach (var item in files)
                {
                    BlazorFile bf = new BlazorFile()
                    {
                        FI     = item,
                        Name   = item.Name.Replace(".dll", null),
                        module = ModuleDefinition.ReadModule(item.FullName, new ReaderParameters {
                            AssemblyResolver = LocalData.resolver
                        }),
                        OutputFile = new FileInfo(Path.Combine(LocalData.outputDir.FullName, item.Name)),
                        IsPrimary  = false,
                        References = new List <BlazorFile>(),
                    };
                    LocalData.BlazorFilesList.Add(bf);
                }



                if (LocalData.BlazorFilesList.Count > 1)
                {
                    LocalFunctions.AnalyzeReferences();
                }
                else
                {
                    LocalData.BlazorFilesList.First().IsPrimary = true;
                }

                // LocalData.BlazorFilesList.Single(x => x.IsPrimary).Process = false;


                switch (LocalData.appMode)
                {
                case AppMode.CleanDeadCodeAndMangle:
                    LocalFunctions.RunDCCleaner();
                    LocalFunctions.RunMangler();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.Mangle:
                    LocalFunctions.RunMangler();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.CleanDeadCode:
                    LocalFunctions.RunDCCleaner();
                    LocalFunctions.SaveResult();
                    break;

                case AppMode.ReportDeadCode:
                    LocalFunctions.RunDCReporter();
                    break;

                default:
                    break;
                }

                //    LocalFunctions.AnalyzeHardCodedPropertyNames();

                // LocalFunctions.AnalyzeOutsideCalls();
            }
            else
            {
                Console.WriteLine("Files not found in " + LocalData.inputDir.FullName);
            }



            TimeAnalyzer.FinishTimeCounter();
        }