TG.Common
2.0.1-preview.0.24
dotnet add package TG.Common --version 2.0.1-preview.0.24
NuGet\Install-Package TG.Common -Version 2.0.1-preview.0.24
<PackageReference Include="TG.Common" Version="2.0.1-preview.0.24" />
paket add TG.Common --version 2.0.1-preview.0.24
#r "nuget: TG.Common, 2.0.1-preview.0.24"
// Install TG.Common as a Cake Addin #addin nuget:?package=TG.Common&version=2.0.1-preview.0.24&prerelease // Install TG.Common as a Cake Tool #tool nuget:?package=TG.Common&version=2.0.1-preview.0.24&prerelease
TG.Common
This library provides methods for logging to file, object cloning delaying when to invoke a method and various other useful tools. I try to add helpers that I end up using regularly over the years, such as the InputBox, AppData and AssemblyInfo.
AssemblyInfo
This class helps to get various Assembly information, such as the Version, InformationVersion, Title or Company. The default assembly referenced is Assembly.GetEntryAssembly().
Basic AssemblyInfo Usage
Console.WriteLine(AssemblyInfo.Title);
Console.WriteLine(AssemblyInfo.InformationalVersion);
Changing the referenced assembly
AssemblyInfo.ReferenceAssembly = Assembly.GetCallingAssembly();
Any subsequent calls on the AssemblyInfo properties will pull from the new ReferenceAssembly.
AppData
The AppData class is a helper for generating a folder in the user's AppData folder. If the folder doesn't exist, it will automatically be created. There are several schemes to choose from for the subfolder structure. For Windows, that would be at C:\Users\<user>\Roaming. In Linux, that would be at ~/.config.
Schemes
- CompanyTitle
- Generates %AppData%\AssemblyInfo.Company\AssemblyInfo.Title
- CompanyProduct
- Generates %AppData%\AssemblyInfo.Company\AssemblyInfo.Product
- Company
- Generates %AppData%\AssemblyInfo.Company
- Title
- Generates %AppData%\AssemblyInfo.Title
- Product
- Generates %AppData%\AssemblyInfo.Product
You can also call AppData.GetAppDataPath(AppDataSchemes) for better control or setting the property AppData.DefaultScheme.
LogManager
The LogManager class is a simple file logger were you only need something small to log to a file. It is suitable if you only need a small library to write error to a log. It doesn't currently have any mechanism for writing for only certain log levels but that could be added if there is interest.
Log Example
// Sets up logging folder using AppData.AppDataPath/Logging.
// Setting AppData.DefaultScheme can control the folder structure.
LogManager.InitializeDefaultLog();
try
{
throw new Exception("Something bad happened!");
}
catch (Exception ex)
{
LogManager.WriteExceptionToLog(ex);
}
Crypto
This class is pretty outdated but can still be useful if you need some simple encryption. It has options for encrypting/decrypting strings, byte arrays and Base64 strings.
DelayedMethodInvoker
This class provides a way to invoke a method after a set amount of time. Once initialized, call Invoke and the internal timer is started. You can also call the RestartTimer method and the timer will start/restart. That can be useful for "debouncing" a button click.
WinForms
There are three included forms that can be used if targeting WinForms. InputBox is the most common form I use since that does't seem to be built into C#.
Forms
- InputBox
- Prompt for user input.
- ExMessageBox
- Honestly, I don't remember why I created this form.
- WaitForm
- A popup form showing a marquee progress bar and message.
Miscellaneous
This class has one-off helpers. The only notable one would be CloneObject; which can do a deep clone of an object.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows7.0 is compatible. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net20 is compatible. net35 was computed. net40 was computed. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 2.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net6.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.1-preview.0.24 | 117 | 11/6/2022 |
2.0.1-preview.0.23 | 107 | 11/6/2022 |
2.0.0 | 428 | 11/6/2022 |
1.2.2 | 349 | 11/3/2022 |
1.2.1 | 321 | 5/5/2021 |
1.2.0 | 367 | 1/5/2021 |
1.1.22 | 581 | 3/17/2019 |