public AssemblyContext(string path, DotNetFramework framework) { LocationDirectory = Path.GetDirectoryName(path); RootAssembly = LoadFromAssemblyPath(path); Framework = framework; ReferencedAssemblies = RootAssembly.GetReferencedAssemblies(); }
public void Process(ImprovementInitiated @event, EventSourceId eventSourceId) { var recipe = new DotNetFramework(); var improvement = new Improvement { Id = eventSourceId.Value, Improvable = @event.ForImprovable, PullRequest = @event.PullRequest, Version = @event.Version }; var improvable = _improvableManager.GetById(@event.ForImprovable); var context = new ImprovementContext( _executionContextManager.Current.Tenant, improvement, improvable); var pod = _improvementPodFactory.BuildFrom(context, recipe); using (var client = _kubernetesClientFactory()) { client.CreateNamespacedPod(pod, pod.Metadata.NamespaceProperty); } }
public void NotDeclaredTFMTest() { Assert.Throws <NotSupportedException>(() => { DotNetFramework.Parse("netcoreapp??").CompatibilityFrameworks.Select(x => x.ToString()).ToArray(); }); }
public static string ToFolderName(this DotNetFramework framework) { switch (framework) { case DotNetFramework.v2: return("net20"); case DotNetFramework.v3_5: return("net35"); case DotNetFramework.v4_0: return("net40"); case DotNetFramework.v4_5: return("net45"); case DotNetFramework.v4_5_1: return("net451"); case DotNetFramework.v4_5_2: return("net452"); case DotNetFramework.v4_6: return("net46"); case DotNetFramework.v4_6_1: return("net461"); case DotNetFramework.v4_6_2: return("net462"); default: throw new ArgumentOutOfRangeException("framework"); } }
public static string GetNETFXKitsDir(DotNetFramework dotNetFramework) { if (s_netFxKitsDir.ContainsKey(dotNetFramework)) { return(s_netFxKitsDir[dotNetFramework]); } throw new NotImplementedException("No NETFXKitsDir associated with " + dotNetFramework); }
private void GeneratePackagesConfig(Project.Configuration conf, DotNetFramework frameworks, List <string> generatedFiles, List <string> skipFiles) { var packagesConfigPath = PackagesConfigPath; // No NuGet references and no trace of a previous packages.config if (conf.ReferencesByNuGetPackage.Count == 0) { if (!File.Exists(packagesConfigPath)) { return; } } lock (s_packagesConfigLock) { if (conf.ReferencesByNuGetPackage.Count == 0) { var fi = new FileInfo(packagesConfigPath); if (!fi.IsReadOnly) // Do not delete packages.config submitted in P4 { Util.TryDeleteFile(packagesConfigPath); } return; } if (IsGenerateNeeded(packagesConfigPath)) { FileGenerator fileGenerator = new FileGenerator(); fileGenerator.Write(Template.Begin); // dependencies DotNetFramework dnfs = ((DotNetFramework[])Enum.GetValues(typeof(DotNetFramework))).First(f => frameworks.HasFlag(f)); for (int i = 0; i < conf.ReferencesByNuGetPackage.SortedValues.Count; ++i) { using (fileGenerator.Declare("dependency", conf.ReferencesByNuGetPackage.SortedValues[i])) using (fileGenerator.Declare("framework", dnfs.ToFolderName())) fileGenerator.Write(Template.DependenciesItem); } fileGenerator.Write(Template.End); bool written = _builder.Context.WriteGeneratedFile(GetType(), new FileInfo(packagesConfigPath), fileGenerator.ToMemoryStream()); if (written) { generatedFiles.Add(packagesConfigPath); } else { skipFiles.Add(packagesConfigPath); } } } IsGenerated = true; }
private static (DotNetFramework, string) ProcessFrameworkTag (string aFramework, string aLookFor, DotNetFramework aDesiredFramework) { (DotNetFramework, string)vResult = !String.IsNullOrWhiteSpace(aFramework) ? (aFramework.StartsWith(aLookFor, _COMPARISON) ? (aDesiredFramework, aFramework) : (DotNetFramework.Unknown, String.Empty)) : (DotNetFramework.Unknown, String.Empty); return(vResult); }
public void Test1() { var fws = DotNetFramework.Parse("net451").CompatibilityFrameworks.Select(x => x.ToString()).ToArray(); Assert.Equal(new[] { "net451", "netstandard1.2", "net45", "netstandard1.1", "netstandard1.0", "net403", "net40", "net35", "net20", "net11" }, fws); }
public static string ToVersionString(this DotNetFramework framework) { switch (framework) { case DotNetFramework.v2: return("2.0"); case DotNetFramework.v3: return("3.0"); case DotNetFramework.v3_5: return("3.5"); case DotNetFramework.v3_5clientprofile: return("3.5"); case DotNetFramework.v4_0: return("4.0"); case DotNetFramework.v4_5: return("4.5"); case DotNetFramework.v4_5_1: return("4.5.1"); case DotNetFramework.v4_5_2: return("4.5.2"); case DotNetFramework.v4_5clientprofile: return("4.5"); case DotNetFramework.v4_6: return("4.6"); case DotNetFramework.v4_6_1: return("4.6.1"); case DotNetFramework.v4_6_2: return("4.6.2"); case DotNetFramework.v4_7: return("4.7"); case DotNetFramework.v4_7_1: return("4.7.1"); case DotNetFramework.v4_7_2: return("4.7.2"); default: throw new ArgumentOutOfRangeException("framework"); } }
public CommonTarget( Platform platform, DevEnv devEnv, Optimization optimization, DotNetFramework dotNetFramework, DotNetOS dotNetOS ) { Platform = platform; DevEnv = devEnv; Optimization = optimization; DotNetFramework = dotNetFramework; DotNetOS = dotNetOS; }
public static string GetNETFXToolsDir(DotNetFramework dotNetFramework) { string netFxToolsDir; if (s_netFxKitsDir.TryGetValue(dotNetFramework, out netFxToolsDir)) { return(netFxToolsDir); } var microsoftSdksRegistryKeyString = string.Format(@"SOFTWARE{0}\Microsoft\Microsoft SDKs", Environment.Is64BitProcess ? @"\Wow6432Node" : string.Empty); if (dotNetFramework >= DotNetFramework.v4_6) { netFxToolsDir = Util.GetRegistryLocalMachineSubKeyValue( $@"{microsoftSdksRegistryKeyString}\NETFXSDK\{dotNetFramework.ToVersionString()}\WinSDK-NetFx40Tools-x86", "InstallationFolder", $@"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX {dotNetFramework.ToVersionString()} Tools\"); } else if (dotNetFramework >= DotNetFramework.v4_5_1) // Note: .Net 4.5.2 lacks a NETFX tools release, so we use the previous version { netFxToolsDir = Util.GetRegistryLocalMachineSubKeyValue( $@"{microsoftSdksRegistryKeyString}\Windows\v8.1A\WinSDK-NetFx40Tools-x86", "InstallationFolder", $@"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\"); } else if (dotNetFramework >= DotNetFramework.v4_0) { netFxToolsDir = Util.GetRegistryLocalMachineSubKeyValue( $@"{microsoftSdksRegistryKeyString}\Windows\v8.0A\WinSDK-NetFx40Tools-x86", "InstallationFolder", $@"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\"); } else if (dotNetFramework >= DotNetFramework.v3_5) { netFxToolsDir = Util.GetRegistryLocalMachineSubKeyValue( $@"{microsoftSdksRegistryKeyString}\Windows\v8.0A\WinSDK-NetFx35Tools-x86", "InstallationFolder", $@"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\"); } else { throw new NotImplementedException("No NETFXToolsDir associated with " + dotNetFramework); } s_netFxToolsDir.TryAdd(dotNetFramework, netFxToolsDir); return(netFxToolsDir); }
public Target( Platform platform, DevEnv devEnv, Optimization optimization, OutputType outputType = OutputType.Lib, Blob blob = Blob.NoBlob, BuildSystem buildSystem = BuildSystem.MSBuild, DotNetFramework framework = DotNetFramework.v3_5 ) { Platform = platform; DevEnv = devEnv; Optimization = optimization; OutputType = outputType; Framework = framework; BuildSystem = buildSystem; Blob = blob; }
static SystemInfo() { var extractionRegex = new Regex("(\\w+?) ?= ?\"(.+?)\";", RegexOptions.Compiled | RegexOptions.Multiline); var systemInfo = GetManagementInfo("SELECT * FROM Win32_OperatingSystem", extractionRegex); var processorInfo = GetManagementInfo("SELECT * FROM Win32_Processor", extractionRegex); Caption = systemInfo.GetValue("Caption"); CSName = systemInfo.GetValue("CSName"); InstallDate = systemInfo.GetValue("InstallDate"); OSArchitecture = systemInfo.GetValue("OSArchitecture"); SerialNumber = systemInfo.GetValue("SerialNumber"); Version = systemInfo.GetValue("Version"); TotalVisibleMemorySize = systemInfo.GetValue("TotalVisibleMemorySize").CastTo <long>(); CPUName = processorInfo.GetValue("Name"); DotNetFrameworkVersion = Get45PlusFromRegistry(); }
public static string GetNETFXKitsDir(DotNetFramework dotNetFramework) { string netFxKitsDir; if (s_netFxKitsDir.TryGetValue(dotNetFramework, out netFxKitsDir)) return netFxKitsDir; if (dotNetFramework >= DotNetFramework.v4_6) { var netFXSdkRegistryKeyString = string.Format(@"SOFTWARE{0}\Microsoft\Microsoft SDKs\NETFXSDK", Environment.Is64BitProcess ? @"\Wow6432Node" : string.Empty); netFxKitsDir = Util.GetRegistryLocalMachineSubKeyValue(netFXSdkRegistryKeyString + @"\" + dotNetFramework.ToVersionString(), "KitsInstallationFolder", $@"C:\Program Files (x86)\Windows Kits\NETFXSDK\{dotNetFramework.ToVersionString()}\"); s_netFxKitsDir.TryAdd(dotNetFramework, netFxKitsDir); return netFxKitsDir; } throw new NotImplementedException("No NETFXKitsDir associated with " + dotNetFramework); }
void init() { try { SplashScreen.CloseAll(); BringToFrontEx(); bool hasLanguage = LocalisationManager.IsInitialised; if (!hasLanguage) { Invoke(delegate { LocalisationManager.SetLanguage(null, false, delegate { hasLanguage = true; }, osu.Properties.Resources.en); }); int timeout = 20000; while (!hasLanguage && (timeout -= 100) > 0) { setText(@"Downloading localisation...", true); Thread.Sleep(100); } } while (true) { try { instance = new SingleInstance(OsuMain.ClientGuid, 500); } catch (TooManyInstancesException) { if (OsuMain.IsWine) { break; } setText(LocalisationManager.GetString(OsuString.Maintenance_OsuIsAlreadyRunning), true); Thread.Sleep(100); continue; } break; } if (!DotNetFramework.CheckInstalled(FrameworkVersion.dotnet4)) { Process installProcess = null; string dotNetInstallFilename = Environment.OSVersion.Version.Major < 6 ? @"dotNetFx40_Full_setup.exe" : @"NDP452-KB2901954-Web.exe"; setText(LocalisationManager.GetString(OsuString.Maintenance_DotNetInstall), true); pFileWebRequest fnr = new pFileWebRequest(dotNetInstallFilename, @"http://m1.ppy.sh/r/" + dotNetInstallFilename); fnr.DownloadProgress += delegate(pWebRequest sender, long current, long total) { setProgress((float)current / total * 100, OsuString.Maintenance_DotNetInstall); }; try { fnr.BlockingPerform(); installProcess = Process.Start(dotNetInstallFilename, @"/passive /promptrestart"); while (installProcess != null && !installProcess.HasExited) { setText(LocalisationManager.GetString(OsuString.Maintenance_WaitingForDotNetComplete), true); setProgress(); Thread.Sleep(500); } } catch { } GeneralHelper.FileDelete(dotNetInstallFilename); label.Click += manualDotNetInstall; while (!DotNetFramework.CheckInstalled(FrameworkVersion.dotnet4, false)) { setText(LocalisationManager.GetString(OsuString.Maintenance_DotNetFailed), true); setProgress(); Thread.Sleep(500); } label.Click -= manualDotNetInstall; } setText(); setProgress(); } catch { } }
private void GenerateProjectJson(Project.Configuration conf, DotNetFramework frameworks, List <string> generatedFiles, List <string> skipFiles) { var projectJsonPath = ProjectJsonPath; var projectJsonLockPath = ProjectJsonLockPath; // No NuGet references and no trace of a previous project.json if (conf.ReferencesByNuGetPackage.Count == 0) { if (!File.Exists(projectJsonPath)) { return; } } lock (s_projectJsonLock) { if (conf.ReferencesByNuGetPackage.Count == 0) { var fi = new FileInfo(projectJsonPath); if (!fi.IsReadOnly) // Do not delete project.json submitted in P4 { Util.TryDeleteFile(projectJsonPath); Util.TryDeleteFile(projectJsonLockPath); } return; } if (IsGenerateNeeded(projectJsonPath)) { FileGenerator fileGenerator = new FileGenerator(); fileGenerator.Write(Template.Begin); // frameworks fileGenerator.Write(Template.FrameworksBegin); DotNetFramework[] dnfs = ((DotNetFramework[])Enum.GetValues(typeof(DotNetFramework))).Where(f => frameworks.HasFlag(f)).ToArray(); for (int i = 0; i < dnfs.Length; ++i) { if (i != 0) { fileGenerator.Write(","); } using (fileGenerator.Declare("framework", dnfs[i].ToFolderName())) fileGenerator.Write(Template.FrameworksItem); } fileGenerator.Write(Template.FrameworksEnd); fileGenerator.Write(","); // runtimes fileGenerator.Write(Template.RuntimesBegin); var runtimes = new[] { "win-x64", "win-x86", "win-anycpu", "win" }; for (int i = 0; i < runtimes.Length; ++i) { if (i != 0) { fileGenerator.Write(","); } using (fileGenerator.Declare("runtime", runtimes[i])) fileGenerator.Write(Template.RuntimesItem); } fileGenerator.Write(Template.RuntimesEnd); fileGenerator.Write(","); // dependencies fileGenerator.Write(Template.DependenciesBegin); for (int i = 0; i < conf.ReferencesByNuGetPackage.SortedValues.Count; ++i) { if (i != 0) { fileGenerator.Write(","); } var packageReference = conf.ReferencesByNuGetPackage.SortedValues[i]; bool hasOptions = false; // Check for private assets string privateAssets = null; if (packageReference.PrivateAssets != PackageReferences.DefaultPrivateAssets) { privateAssets = string.Join(",", PackageReferences.PackageReference.GetFormatedAssetsDependency(packageReference.PrivateAssets)); hasOptions = true; } // Check for a custom type string referenceType = null; if (!string.IsNullOrEmpty(packageReference.ReferenceType)) { referenceType = packageReference.ReferenceType; hasOptions = true; } if (!hasOptions) { using (fileGenerator.Declare("dependency", packageReference)) fileGenerator.Write(Template.DependenciesItem); } else { using (fileGenerator.Declare("dependency", packageReference)) { fileGenerator.Write($"{Template.BeginDependencyItem}"); if (!string.IsNullOrEmpty(privateAssets)) { using (fileGenerator.Declare("privateAssets", privateAssets)) fileGenerator.Write($"{Template.DependencyPrivateAssets}"); } if (!string.IsNullOrEmpty(referenceType)) { using (fileGenerator.Declare("referenceType", referenceType)) fileGenerator.Write($"{Template.DependencyReferenceType}"); } fileGenerator.Write($"{Template.EndDependencyItem}"); } } } fileGenerator.Write(Template.DependenciesEnd); fileGenerator.Write(Template.End); fileGenerator.RemoveTaggedLines(); bool written = _builder.Context.WriteGeneratedFile(GetType(), new FileInfo(projectJsonPath), fileGenerator.ToMemoryStream()); if (written) { generatedFiles.Add(projectJsonPath); } else { skipFiles.Add(projectJsonPath); } } } IsGenerated = true; }
public static string ToVersionString(this DotNetFramework framework) { switch (framework) { case DotNetFramework.v3_5: return("3.5"); case DotNetFramework.v3_5clientprofile: return("3.5"); case DotNetFramework.v4_0: return("4.0"); case DotNetFramework.v4_5: return("4.5"); case DotNetFramework.v4_5_1: return("4.5.1"); case DotNetFramework.v4_5_2: return("4.5.2"); case DotNetFramework.v4_5clientprofile: return("4.5"); case DotNetFramework.v4_6: return("4.6"); case DotNetFramework.v4_6_1: return("4.6.1"); case DotNetFramework.v4_6_2: return("4.6.2"); case DotNetFramework.v4_7: return("4.7"); case DotNetFramework.v4_7_1: return("4.7.1"); case DotNetFramework.v4_7_2: return("4.7.2"); case DotNetFramework.v4_8: return("4.8"); case DotNetFramework.netcore1_0: return("netcoreapp1.0"); case DotNetFramework.netcore1_1: return("netcoreapp1.1"); case DotNetFramework.netcore2_0: return("netcoreapp2.0"); case DotNetFramework.netcore2_1: return("netcoreapp2.1"); case DotNetFramework.netcore2_2: return("netcoreapp2.2"); case DotNetFramework.netcore3_0: return("netcoreapp3.0"); case DotNetFramework.netcore3_1: return("netcoreapp3.1"); case DotNetFramework.netstandard1_0: return("netstandard1.0"); case DotNetFramework.netstandard1_1: return("netstandard1.1"); case DotNetFramework.netstandard1_2: return("netstandard1.2"); case DotNetFramework.netstandard1_3: return("netstandard1.3"); case DotNetFramework.netstandard1_4: return("netstandard1.4"); case DotNetFramework.netstandard1_5: return("netstandard1.5"); case DotNetFramework.netstandard1_6: return("netstandard1.6"); case DotNetFramework.netstandard2_0: return("netstandard2.0"); case DotNetFramework.netstandard2_1: return("netstandard2.1"); case DotNetFramework.net5_0: return("net5.0"); case DotNetFramework.all_netframework: case DotNetFramework.all_netcore: case DotNetFramework.all_netstandard: default: throw new ArgumentOutOfRangeException(nameof(framework)); } }
public static bool IsDotNetStandard(this DotNetFramework framework) { return(0 != (framework & DotNetFramework.all_netstandard)); }
public static bool IsDotNetCore(this DotNetFramework framework) { return(0 != (framework & DotNetFramework.all_netcore)); }
public static string ToFolderName(this DotNetFramework framework) { //https://docs.microsoft.com/en-us/dotnet/standard/frameworks switch (framework) { case DotNetFramework.v3_5: return("net35"); case DotNetFramework.v4_0: return("net40"); case DotNetFramework.v4_5: return("net45"); case DotNetFramework.v4_5_1: return("net451"); case DotNetFramework.v4_5_2: return("net452"); case DotNetFramework.v4_6: return("net46"); case DotNetFramework.v4_6_1: return("net461"); case DotNetFramework.v4_6_2: return("net462"); case DotNetFramework.v4_7: return("net47"); case DotNetFramework.v4_7_1: return("net471"); case DotNetFramework.v4_7_2: return("net472"); case DotNetFramework.v4_8: return("net48"); case DotNetFramework.netcore1_0: return("netcoreapp1.0"); case DotNetFramework.netcore1_1: return("netcoreapp1.1"); case DotNetFramework.netcore2_0: return("netcoreapp2.0"); case DotNetFramework.netcore2_1: return("netcoreapp2.1"); case DotNetFramework.netcore2_2: return("netcoreapp2.2"); case DotNetFramework.netcore3_0: return("netcoreapp3.0"); case DotNetFramework.netcore3_1: return("netcoreapp3.1"); case DotNetFramework.net5_0: return("net5.0"); case DotNetFramework.netstandard1_0: return("netstandard1.0"); case DotNetFramework.netstandard1_1: return("netstandard1.1"); case DotNetFramework.netstandard1_2: return("netstandard1.2"); case DotNetFramework.netstandard1_3: return("netstandard1.3"); case DotNetFramework.netstandard1_4: return("netstandard1.4"); case DotNetFramework.netstandard1_5: return("netstandard1.5"); case DotNetFramework.netstandard1_6: return("netstandard1.6"); case DotNetFramework.netstandard2_0: return("netstandard2.0"); case DotNetFramework.netstandard2_1: return("netstandard2.1"); default: throw new ArgumentOutOfRangeException(nameof(framework), framework, nameof(DotNetFramework) + " cannot be converted to a folder name."); } }
public override void Run() { if (!Directory.Exists(OutFolder)) { Directory.CreateDirectory(OutFolder); } var targetAssemblyName = Program.ProjectInfo.AssemblyName; var assemblyContext = new AssemblyContext($"{TargetBinFolder}/{targetAssemblyName}.dll", DotNetFramework.Parse(Program.ProjectInfo.TargetFramework)); var dbContextType = assemblyContext.GetType($"Microsoft.EntityFrameworkCore.DbContext,Microsoft.EntityFrameworkCore"); var types = assemblyContext.RootAssembly.GetTypesWhichExtends(dbContextType, true); foreach (var type in types) { var outFile = $"{Path.GetFullPath($"{OutFolder}/{type.Name}.html")}"; var builder = new DbStructureBuilder(); builder.Cache(type); var csvContent = builder.GetHtml(); var bytes = SetBOM ? new byte[] { 0xef, 0xbb, 0xbf }.Concat(csvContent.Bytes(Encoding.UTF8)).ToArray() : csvContent.Bytes(Encoding.UTF8).ToArray(); File.WriteAllBytes(outFile, bytes); Console.WriteLine($"File Saved: {outFile}"); } }
private void GenerateProjectJson(Project.Configuration conf, DotNetFramework frameworks, List <string> generatedFiles, List <string> skipFiles) { var projectJsonPath = ProjectJsonPath; var projectJsonLockPath = ProjectJsonLockPath; // No NuGet references and no trace of a previous project.json if (conf.ReferencesByNuGetPackage.Count == 0) { if (!File.Exists(projectJsonPath)) { return; } } lock (s_projectJsonLock) { if (conf.ReferencesByNuGetPackage.Count == 0) { var fi = new FileInfo(projectJsonPath); if (!fi.IsReadOnly) // Do not delete project.json submitted in P4 { Util.TryDeleteFile(projectJsonPath); Util.TryDeleteFile(projectJsonLockPath); } return; } if (IsGenerateNeeded(projectJsonPath)) { FileGenerator fileGenerator = new FileGenerator(); fileGenerator.Write(Template.Begin); // frameworks fileGenerator.Write(Template.FrameworksBegin); DotNetFramework[] dnfs = ((DotNetFramework[])Enum.GetValues(typeof(DotNetFramework))).Where(f => frameworks.HasFlag(f)).ToArray(); for (int i = 0; i < dnfs.Length; ++i) { if (i != 0) { fileGenerator.Write(","); } using (fileGenerator.Declare("framework", dnfs[i].ToFolderName())) fileGenerator.Write(Template.FrameworksItem); } fileGenerator.Write(Template.FrameworksEnd); fileGenerator.Write(","); // runtimes fileGenerator.Write(Template.RuntimesBegin); var runtimes = new[] { "win-x64", "win-x86", "win-anycpu", "win" }; for (int i = 0; i < runtimes.Length; ++i) { if (i != 0) { fileGenerator.Write(","); } using (fileGenerator.Declare("runtime", runtimes[i])) fileGenerator.Write(Template.RuntimesItem); } fileGenerator.Write(Template.RuntimesEnd); fileGenerator.Write(","); // dependencies fileGenerator.Write(Template.DependenciesBegin); for (int i = 0; i < conf.ReferencesByNuGetPackage.SortedValues.Count; ++i) { if (i != 0) { fileGenerator.Write(","); } using (fileGenerator.Declare("dependency", conf.ReferencesByNuGetPackage.SortedValues[i])) fileGenerator.Write(Template.DependenciesItem); } fileGenerator.Write(Template.DependenciesEnd); fileGenerator.Write(Template.End); bool written = _builder.Context.WriteGeneratedFile(GetType(), new FileInfo(projectJsonPath), fileGenerator.ToMemoryStream()); if (written) { generatedFiles.Add(projectJsonPath); } else { skipFiles.Add(projectJsonPath); } } } IsGenerated = true; }
private static void GenerateTypeScript(string outFolder, bool setBOM) { if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } var targetAssemblyName = Program.ProjectInfo.AssemblyName; var assemblyContext = new AssemblyContext($"{TargetBinFolder}/{targetAssemblyName}.dll", DotNetFramework.Parse(Program.ProjectInfo.TargetFramework)); var types = assemblyContext.RootAssembly.GetTypesWhichExtends <DbContext>(true); foreach (var type in types) { var outFile = $"{Path.GetFullPath($"{outFolder}/{type.Name}.html")}"; var builder = new DbStructureBuilder(); builder.Cache(type); var csvContent = builder.GetHtml(); var bytes = setBOM ? new byte[] { 0xef, 0xbb, 0xbf }.Concat(csvContent.Bytes(Encoding.UTF8)).ToArray() : csvContent.Bytes(Encoding.UTF8).ToArray(); File.WriteAllBytes(outFile, bytes); Console.WriteLine($"File Saved: {outFile}"); } }
public override void Run() { var targetAssemblyName = Project.AssemblyName; var assemblyContext = new AssemblyContext($"{TargetBinFolder}/{targetAssemblyName}.dll", DotNetFramework.Parse(Project.TargetFramework)); string outFile; // if Directory if (Directory.Exists(Out) || Path.GetExtension(Out) == "" || Out.Last().For(c => c == '/' || c == '\\')) { if (!Directory.Exists(Out)) { Directory.CreateDirectory(Out); } outFile = Path.GetFullPath(Path.Combine(Out, $"{targetAssemblyName}.api.ts")); } // if File else { var dir = Path.GetDirectoryName(Out); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } outFile = Path.GetFullPath(Out); } var builder = new TypeScriptApiBuilder(Uri); var markAttr = assemblyContext.GetType($"{nameof(TypeSharp)}.{nameof(TypeScriptApiAttribute)},{nameof(TypeSharp)}"); var modelTypes = assemblyContext.RootAssembly.GetTypesWhichMarkedAs(markAttr); builder.CacheTypes(modelTypes); foreach (var include in Includes) { var type = assemblyContext.GetType(include); if (type == null) { throw new ArgumentException($"Can not find type({type.FullName})."); } builder.CacheType(type); } foreach (var relative in Relatives) { if (relative.Count(";") == 1) { var pair = relative.Split(";"); builder.AddDeclaredType(assemblyContext.GetType(pair[0]), pair[1]); } else { throw new ArgumentException("Each parameter('Relative') must contain a semicolon(;)."); } } builder.WriteTo(outFile); Console.WriteLine($"File saved: {outFile}"); }
private static UpdateStates doUpdate() { //ensure we have the correct version of .net available. if (ReleaseStream.ToString().Contains(@"40") && !DotNetFramework.CheckInstalled(FrameworkVersion.dotnet4)) { Log(@"Not updating due to missing .NET 4 installation"); LastError = new MissingFrameworkVersionException(FrameworkVersion.dotnet4); return(UpdateStates.Error); } try { ConfigManagerCompact.LoadConfig(); //ensure we are starting clean. //note that we don't clear a pending update just yet because there are scenarios we can use this (see variable stagedAndWaitingToUpdate below). Cleanup(10000, false); List <DownloadableFileInfo> streamFiles = null; string rawString = string.Empty; try { Log(@"Requesting update information..."); var sn = new pWebRequest <List <DownloadableFileInfo> >(string.Format(CENTRAL_UPDATE_URL + @"?action=check&stream={0}&time={1}", ReleaseStream.ToString().ToLower(), DateTime.Now.Ticks)); sn.BlockingPerform(); rawString = sn.ResponseString; if (rawString == @"fallback") { Log(@"Server has requested an emergency fallback!"); return(UpdateStates.EmergencyFallback); } streamFiles = sn.ResponseObject; } catch (Exception e) { LastError = e; LastErrorExtraInformation = rawString; Log(LastError.ToString()); Log(rawString); return(UpdateStates.Error); } if (streamFiles == null || streamFiles.Count == 0) { LastError = new Exception($@"update file returned no results ({rawString})"); Log(LastError.ToString()); return(UpdateStates.Error); } tryAgain: bool stagedAndWaitingToUpdate = Directory.Exists(STAGING_COMPLETE_FOLDER); List <DownloadableFileInfo> updateFiles = new List <DownloadableFileInfo>(); foreach (DownloadableFileInfo file in streamFiles) { if (stagedAndWaitingToUpdate) { Log(@"A pending update is already waiting. Checking what we're working with..."); //special case where we already have a pending update. //if we find *any* file which doesn't match, we should remove the folder and restart the process. string pendingFilename = STAGING_COMPLETE_FOLDER + @"/" + file.filename; if (File.Exists(pendingFilename)) { Log(file.filename + @": PENDING"); //pending file exists and matches this update precisely. if (getMd5(pendingFilename) == file.file_hash) { continue; } } else if (File.Exists(file.filename) && getMd5(file.filename, true) == file.file_hash) { Log(file.filename + @": LATEST"); //current version is already newest. continue; } Log(file.filename + @": MISMATCH"); //something isn't up-to-date. let's run the update process again without our pending version. Reset(false); goto tryAgain; } if (!File.Exists(file.filename)) { updateFiles.Add(file); Log(file.filename + @": NEW"); } else if (getMd5(file.filename, true) != file.file_hash) { Log(file.filename + @": CHANGED (cached)"); updateFiles.Add(file); //cached md5 check failed. } else if (file.filename == @"osu!.exe" && getMd5(file.filename, true) != getMd5(file.filename)) //special intensive check for main osu!.exe { Log(file.filename + @": CHANGED"); ConfigManagerCompact.ResetHashes(); goto tryAgain; } } if (stagedAndWaitingToUpdate) { Log(@"Pending updating is waiting and requires no further changes."); //return early, as we've already done the rest of the process below in a previous run. return(MoveInPlace() ? UpdateStates.Completed : UpdateStates.NeedsRestart); } if (updateFiles.Count == 0) { Log(@"No changes to apply!"); if (!DotNetFramework.CheckInstalled(FrameworkVersion.dotnet4)) { Log(@"Becuase we had no changes, let's let the user know they need a newer framework in the future"); //if there are no pending updates but the user doesn't have dotnet4 available, we should tell them to get it. LastError = new MissingFrameworkVersionException(FrameworkVersion.dotnet4); return(UpdateStates.Error); } return(UpdateStates.NoUpdate); } totalUpdatableFiles = updateFiles.Count; if (!Directory.Exists(STAGING_FOLDER)) { Log(@"Creating staging folder"); DirectoryInfo di = Directory.CreateDirectory(STAGING_FOLDER); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } setCallbackStatus(UpdateStates.Updating); lock (ActiveFiles) ActiveFiles.AddRange(updateFiles); foreach (DownloadableFileInfo f in updateFiles) { DownloadableFileInfo file = f; Log(@"Processing {0}...", file.ToString()); if (File.Exists(file.filename)) { Log(@"Exists locally; checking for patchability..."); string localHash = getMd5(file.filename); //check for patchability... try { var sn = new pWebRequest <List <DownloadableFileInfo> >(@"{0}?action=path&stream={1}&target={2}&existing={3}&time={4}", CENTRAL_UPDATE_URL, ReleaseStream.ToString().ToLower(), file.file_version, localHash, DateTime.Now.Ticks); sn.BlockingPerform(); List <DownloadableFileInfo> patchFiles = sn.ResponseObject; if (patchFiles.Count > 1) { Log(@"Server returned {0} patch files", patchFiles.Count.ToString()); //copy the local version to the staging path. File.Copy(file.filename, STAGING_FOLDER + @"/" + file.filename); bool success = false; lock (ActiveFiles) ActiveFiles.AddRange(patchFiles.GetRange(0, patchFiles.Count - 1)); totalUpdatableFiles += patchFiles.Count - 1; try { //we now know we have a patchable path, so let's try patching! foreach (DownloadableFileInfo patch in patchFiles) { try { if (patch.file_version == file.file_version) { Log(@"Reached end of patch chain ({0} / {1}), checking file checksum...", patch.file_version.ToString(), patch.file_hash); //reached the end of patching. if (getMd5(STAGING_FOLDER + @"/" + file.filename) != file.file_hash) { Log(@"Patching FAILED!"); throw new Exception(@"patching failed to end with correct checksum."); } Log(@"Patching success!"); success = true; break; //patching successful! } string localPatchFilename = STAGING_FOLDER + @"/" + patch.filename + @"_patch"; Log(@"Applying patch {0} (to {1})...", patch.file_version.ToString(), patch.file_hash); patch.Perform(true); } finally { lock (ActiveFiles) ActiveFiles.Remove(patch); } } if (success) { lock (ActiveFiles) ActiveFiles.Remove(file); continue; } } finally { lock (ActiveFiles) patchFiles.ForEach(pf => ActiveFiles.Remove(pf)); } } Log(@"No patches available; falling back to full download"); } catch (Exception e) { Log(@"Error occured during patching: " + e); //an error occurred when trying to patch; fallback to a full update. } } Log(@"Beginning download of {0} ({1})...", file.filename, file.url_full); file.PerformThreaded(delegate { lock (ActiveFiles) ActiveFiles.Remove(file); Log(@"Completed download of {0} ({1} files remain)!", file.filename, ActiveFiles.Count); }, delegate { Log(@"Failed download of {0}! Error: {1}", file.filename, file.Error); //error occurred }); } while (ActiveFiles.Count > 0) { foreach (DownloadableFileInfo dfi in ActiveFiles) { if (dfi.Error != null) { LastError = dfi.Error; return(UpdateStates.Error); } } Thread.Sleep(100); } if (State == UpdateStates.Updating) { if (Directory.Exists(STAGING_COMPLETE_FOLDER)) { Directory.Delete(STAGING_COMPLETE_FOLDER, true); } GeneralHelper.RecursiveMove(STAGING_FOLDER, STAGING_COMPLETE_FOLDER); ConfigManagerCompact.Configuration[@"_ReleaseStream"] = ReleaseStream.ToString(); return(MoveInPlace() ? UpdateStates.Completed : UpdateStates.NeedsRestart); } return(UpdateStates.NoUpdate); } catch (ThreadAbortException) { Log(@"Thread was aborted!"); foreach (DownloadableFileInfo dfi in ActiveFiles) { dfi.Abort(); } return(UpdateStates.NoUpdate); } catch (Exception e) { Log(@"Error: " + e.ToString()); LastError = e; return(UpdateStates.Error); } finally { Log(@"Saving out global config"); ConfigManagerCompact.SaveConfig(); updateThread = null; } }
public static string ToFolderName(this DotNetFramework framework) { switch (framework) { case DotNetFramework.v2: return("net20"); case DotNetFramework.v3_5: return("net35"); case DotNetFramework.v4_0: return("net40"); case DotNetFramework.v4_5: return("net45"); case DotNetFramework.v4_5_1: return("net451"); case DotNetFramework.v4_5_2: return("net452"); case DotNetFramework.v4_6: return("net46"); case DotNetFramework.v4_6_1: return("net461"); case DotNetFramework.v4_6_2: return("net462"); case DotNetFramework.v4_7: return("net47"); case DotNetFramework.v4_7_1: return("net471"); case DotNetFramework.v4_7_2: return("net472"); case DotNetFramework.netcore1_0: return("netcoreapp1.0"); case DotNetFramework.netcore1_1: return("netcoreapp1.1"); case DotNetFramework.netcore2_0: return("netcoreapp2.0"); case DotNetFramework.netcore2_1: return("netcoreapp2.1"); case DotNetFramework.netcore2_2: return("netcoreapp2.2"); case DotNetFramework.netcore3_0: return("netcoreapp3.0"); case DotNetFramework.netcore3_1: return("netcoreapp3.1"); default: throw new ArgumentOutOfRangeException(nameof(framework)); } }