fluffynuts / peanutbutter Goto Github PK
View Code? Open in Web Editor NEWTasty, versatile, nutritious; goes with many things in .net.
License: BSD 3-Clause "New" or "Revised" License
Tasty, versatile, nutritious; goes with many things in .net.
License: BSD 3-Clause "New" or "Revised" License
Load() a non-existing file should not create folders nor file.
It should just work in memory until the .Persist() calling.
Load() creates full path directories path and a 0 byte file, in case of missing.
The creation is performed into GetLinesFrom() and there's no way to avoid it.
Thank you.
Seeing warnings that <iconUrl>
is deprecated in the nuspecs raises the question of new icons, which would be checked into the PB repo.
1st prize: icons with a constant theme which communicate the purpose of each library, even if they just have a common frame/background with a little text on them.
2nd prize: a unified icon for all packages.
Preferred design:
I'm still using 1.0.155 so this might have been resolved already.
I'm using the generic builders in the RandomGenerators and when calling .BuildRandom() or .WithRandomProps() I don't get a random object, I get default values. It requires the TestUtils.Generic package to be installed to get real random values, It seems like there is a dependency requirement missing because BuildRandom doesn't actually work without it so I was pretty confused until I debugged my tests to find the lack of randomness.
I'd like to be able to hack on PB on any machine - so I'd like to embrace dotnet for build & targeting.
This raises the issue of minimum framework support (currently net452) - though the included MonoForFramework.targets
file may suffice with a reasonable system Mono install, conversely the solution at https://stackoverflow.com/a/45380046 would allow build & test on !windows, but release would still have to happen on a windows machine.
This also raises the issue of platform-specific packages:
These are quite stable and should probably be moved into their own repos, much like https://github.com/fluffynuts/PeanutButter.TrayIcon
If tooling can be switched to dotnet
, then packaging metadata would come from the .csproj files, meaning zarro
would just build packages (remove custom package building), zarro
could increment package versions (remove NugetPackageIncrementer) and the Package.nuspec files could be removed too.
GetRandom{Int|Long|Decimal|Float|Double)
should be friendlier when providing only a lower-bound for the range of acceptable values, and, instead of using the default parameter value and then potentially swapping them, should rather use the default range, added onto the minimum
ie if the user asks for GetRandomInt(100)
, then she probably expects a number of value at least 100, but the current implementation defaults the max to 10
and tries to protect the caller against accidental flipping of min & max, so the call above results in a number between 10 and 100 (inclusive). Probably not the original intention of the call, and not clear.
Adding some README and documentations to explain INI
I'm trying to use PeanutButter.INI but it truncates text at every ; because it considers that sign a comment.
I suppose I should create a new ILineParser to tell the library to do not stop reading at ; but I cannot figure out how.
Do you have any documentation?
Use case:
[PATHS]
'The line below contains the SQL connection string to customer DB
DBPATH=DRIVER={SQL Server};SERVER=192.168.85.130\SQLEXPRESS02;DATABASE=OneSQL;UID=sa;PWD=pazzword;TRUSTED_CONNECTION=NO;CONNECTION TIMEOUT=60;
In my case, comments are full lines only, started with ' char, while ; it's a valid char.
Suggested solutions:
Thank you,
Matteo Farina
If .CommentDelimiter has been set, for example to CommentDelimiter = "'";
after calling .Persist()
the result file contains both ; and ' are the comment header.
[DBJUMPING]
'NOJUMPRANGE=1
[DBJUMPING]
;'NOJUMPRANGE=1
Currently, after persisting, there are no gaps between sections.
This makes it difficult to review the ini when opened in notepad.
Please consider adding a default separator such as blank row, blank comment (; ), or line comment (; -----).
TempDbMySql can be instantiated with a number of the settings which would be written to the temporary instance's my.ini. There is a POCO which exposes the settings I found via a quick trawl of Oracle's documentation, but apparently there are many advanced settings which aren't currently tweakable via this interface, particularly some which could improve performance (meaning tests run faster!), especially on higher-end machines which can handle it.
These options largely center around disk I/O.
I would like:
The following ini entry was saved properly. But this entry gets truncated starting with the first semi-colon when reading the value.
Email_Message=" <title>message</title> <style type="text/css"> body{font-family: Verdana, Geneva, sans-serif; font-size:10pt;} td{font-family: Verdana, Geneva, sans-serif;font-size:10pt;} p{margin-top: 10px; margin-bottom: 10px;} ol,ul{margin-top: -10px; margin-bottom: -10px;} </style> test {MovedFileFullPath} "
So when reading that entry, the text starting with the first semi-colon is lost, resulting in just this text:
" <title>message</title> <meta http-equiv="content-type" content="text/html
Looks like the value-embedded semi-colon is falsely handled as a start of a comment.
Looks like there's a need to improve comment detection.
I'd like to be able to compile cli apps AOT, and use PeanutButter.EasyArgs because it's easy!
I can't, because under the hood, EasyArgs uses the DuckTyper, which emits code - which isn't supported on AOT targets
I'm working with an old library that load an INI file and I'm editing its INI file with PeanutButter.INI. The problem I'm facing is that PeanutButter.INI removes empty lines in at the bottom of the file. Apparently, the library needs those empty lines.
Not removing empty lines at the bottom.
Removes all empty lines at the bottom.
It would be great to spend some time on documenting individual projects, even if only briefly in a README.md in each project's folder. The natural knock-on for this would be to make the readme available in the nuget package via the nuspec options outlined at https://devblogs.microsoft.com/nuget/add-a-readme-to-your-nuget-package/, specifically:
<package>
<metadata>
...
<readme>docs\README.md</readme>
...
</metadata>
<files>
...
<file src="..\README.md" target="docs\" />
...
</files>
</package>
this would:
Projects to consider (probably best candidates in bold):
I look up all of "HttpServer" api. It seems only support sync handle.
I'm currently managing our Installer App with WMI calls to install and repair our app,
I was looking to your package to replace WMI as System.Management isn't AOT compatible.
Unfortunately, You only expose the basic features for the service, I am looking for the
It's not urgent for my problem at the moment, If you could expose those, that would be awesome.
Otherwise when it gets more urgent, I might look if I can add the features.
The ini Remove method deletes the key value but leaves the key behind.
Before the call:
[mySection]
myKey="myValue"
After calling gINIFile.Item("mySection").Remove("myKey"):
[mySection]
myKey
Expected behavior is for myKey to be completely removed.
Currently, the only way to rename a section is to create a new one and delete the old one.
That removes all comments and changes the position of the section within the ini file.
Please consider adding a RenameSection() method.
A recent PR has provided an SVG source icon (resources/logo.svg
) which now needs to be applied to the arduous task of copying, applying textural labels & exporting as png for each of the published projects. There's limited space considering the final size of the icon, so here are suggestions:
PeanutButter.Utils - "Utils"
PeanutButter.RandomGenerators - "Random"
PeanutButter.INI - "INI"
PeanutButter.TrayIcon - "Tray"
PeanutButter.ServiceShell - "Service"
PeanutButter.WindowsServiceManagement - "SvcMgr"
PeanutButter.SimpleHttpServer - "HTTP"
PeanutButter.TempDb - "TempDb"
PeanutButter.XmlUtils - "Xml"
PeanutButter.DatabaseHelpers - "SQL"
PeanutButter.DatabaseHelpers.Testability - "SQL-T"
PeanutButter.FluentMigrator - "Migrate"
PeanutButter.Async - "Async"
PeanutButter.Utils.Entity - "EF"
PeanutButter.TestUtils.Generic - "TestUtils"
PeanutButter.TinyEventAggregator - "Events"
PeanutButter.DuckTyping - "Quack"
PeanutButter.TestUtils.Async - "TestAsync"
PeanutButter.SimpleHTTPServer.Testability - "HttpTest"
PeanutButter.SimpleTcpServer - "TCP"
PeanutButter.JObjectExtension - "{}"
PeanutButter.TempDb.Sqlite - "Sqlite"
PeanutButter.TempDb.LocalDb - "LocalDb"
PeanutButter.TestUtils.MVC - "MVC"
PeanutButter.TempDb.SqlCe - "SqlCe"
PeanutButter.TempDb.Runner - "DbRunner"
PeanutButter.TempDb.MySql.Connector - "MySql.Connector"
PeanutButter.TempDb.MySql.Data - "MySql.Data"
A pull request does not have to satisfy all icon requirements. Feel free to PR with as many icons as you like, or as few (: This would be a good beginner task, especially if you're wanting to learn about SVG, or the PR process (:
I've seen a mysql tempdb attempt to start up and fail with this in the error log:
2020-06-12T08:35:11.547292Z 0 [ERROR] Can't start server: Bind on TCP/IP port: No such file or directory
2020-06-12T08:35:11.547717Z 0 [ERROR] Do you already have another mysqld server running on port: 49932 ?
Perhaps TempDbMySql could look for mysql-err.log and try to grok this issue; if found, re-randomize the port and try again.
In case, I have ini file and I remove a last section from that file and try to save via Persist(), it fails on trying to remove non existing item.
Persist doesn't throw an exception and the file is empty after the call.
An exception "Exception is "Index was out of range. Must be non-negative and less than the size of the collection." is thrown.
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.RemoveAt(Int32 index)
at PeanutButter.INI.INIFile.GetLinesForCurrentData(PersistStrategies persistStrategy) in C:\source\PeanutButter\source\INI\PeanutButter.INI\INIFile.cs:line 1092
at PeanutButter.INI.INIFile.Persist(String saveToPath, PersistStrategies persistStrategy, Encoding encoding) in C:\source\PeanutButter\source\INI\PeanutButter.INI\INIFile.cs:line 980
at PeanutButter.INI.INIFile.Persist(Encoding encoding) in C:\source\PeanutButter\source\INI\PeanutButter.INI\INIFile.cs:line 919
at PeanutButter.INI.INIFile.Persist() in C:\source\PeanutButter\source\INI\PeanutButter.INI\INIFile.cs:line 913
at PeanutButter.INI.Tests.TestINIFile.Construction.MergingConfigurations.Persistence.PersistEmptyIniWithLineSeparator() in C:\source\PeanutButter\source\INI\PeanutButter.INI.Tests\TestINIFile.cs:line 347
Hi @fluffynuts!
I wanted to try out your TrayIcon component today but noticed that the current PeanutButter.TrayIcon NuGet package unfortunately doesn't contain any assemblies at all.
Then I looked back a bit and I think that version 1.1.44 is the last one that was actually not empty.
Am I missing something or could there be an error in the NuGet build for this package since version 1.2.0?
We are having issues with chinese characters being displayed in Notepad, when PeanutButterINI
creates / saves a file. I use notepad++ in development but the help desk needs open the INI in notepad, which encodes the strings into chinese characters, for some reason.
I have a WPF application in which, i hold the global object
public INIFile dvINI { get; set; }
Before the app is initialized, i'm doing some checks
if (Directory.Exists(assyPath))
{
if (File.Exists(assyPath + "\DVSettings.ini"))
{
dvINI = new INIFile(assyPath + "\DVSettings.ini");
Then Checking and setting some properties:
ex: //If Key doesnt exist, Create it
if (!dvINI.HasSetting("DrawingViewer", "EnableLogging"))
{
dvINI["DrawingViewer"]["EnableLogging"] = "False";
}
enableLogging = Convert.ToBoolean(dvINI["DrawingViewer"]["EnableLogging"]);
I've tried changing the encoding in notepad++ but PBINI only reads UTF-8 correctly.
When the app runs it creates the ini with preset variables with string paths
ex: [Main-WHQ]
DEVPath="\XXXX\XXXXX\XXX\manufacturing"
MaxHistory="60"
Then when the app closes it resaves certain variables.
I tried to save these to a different file, in which at first glance seemed to work, but then
the chinese characters came back.
Is there any fix that i can look at to resolve this issue?
Is there any option to force the encoding to UTF-8?
Ducktyped object's method should invoke the underlying object's method matching the same signature
Invalid Parameter count exception is thrown
Work
Use a customized parser with ' as comment char
class IniFileLineParser : BestEffortLineParser
{
public IniFileLineParser()
{
base.CommentDelimiter = "'";
}
}
Load a file containing one or two ' in the value, not as comment
DATI.TXT
Currently, if you have a class or interface with a property like:
public interface IMooCow
{
Action<string> LogAction { get; set; }
}
Then GenericBuilder
will explode when attempting default randomisation of an entity constructed for this type as you can't Activator.CreateInstance
on an Action or Func.
What should really happen here is that the randomiser should just create an action or func which matches the required call signature and does nothing (in the case of the func should return the default value for the return type).
We have big issues with the BOM at the beginning of the ini-Text-File being added to the first section (or first entry if there is no section header). So finding the sections or entrys fails, because StringComparer.OrdinalIgnoreCase
also takes the BOM into account. Why are you using OrdinalIgnoreCase
?
Could you either check for the BOM character or change the Dictionary to use InvariantCultureIgnoreCase
?
How to set encoding for Persist() method?
The file seems to be written always in UTF-8 but in some occasions I have to save it in ANSI.
Thank you.
Could you add a return value to SetValue() function?
Example: bool
true: succeeded
false: failed
Thank you.
Quotes are added to all values. For example, i cannot save a number without quotes.
It needs to be saved like this:
speed = 6
but it turns out:
speed = "6"
Some projects haven't received updates in a very long time - simply because I'm not using them.
Some of these aren't even on nuget.org, eg:
Other projects are on nuget.org, but are unlikely to receive functional updates because I'm not using them, but I'll support issues, if anyone brings them up. In particular, I'd want to target packages which depend on other nuget packages (thus which should have maintenance updates for dependencies) or packages where the same functionality can be found in actively-maintained packages
In addition, PeantuButter.ServiceShell and PeanutButter.WindowsServiceManagement should probably move off into their own area as they can't build or test on anything but Windows (which is their intended target) and they are relatively stable - so they hold back being able to work on PB on Linux for no real benefit.
There may be others, but the idea should be to make build, test & publish possible cross-platform (this would also require updating to use dotnet
to build and push nuget packages - see #53)
Currently, in-memory storage for INIFile is performed via .net generic dictionaries, which do not guarantee order when enumerating. The feature to rename sections has highlighted the volatility of order. It would be nice to (perhaps optionally? perhaps always?) retain ordering, which would require some custom work -- possibly an internal implementation if IDictionary<TKey, TValue> since OrderedDictionary isn't generic.
i use SimpleHTTPServer.
Can i set allows CORS Policy in response header?
Hi,
neigther the constructor nor the "Install" method of WindowsServiceUtil provide a way to set the exe file path. There is the "ServiceExe" property, but its read only.
Is this a bug? How do you install a service?
C# Windows Forms. I am new to C# and cannot follow how to use this. Do you have simple instructions anywhere for a novice? I have created a test app in C# Win forms. I installed PeanutButterINI using NuGet and have copied the tests to the project. I get many errors about missing namespaces and strings not existing in current context (amongst other errors).
In my project (not the test) I have successfully used Application Settings to save and load user settings for the values of controls on my form. I have a checkbox and code where I can set whether this happens automatically (at application start and close), or not. I also have a menu so I can load them and save them during runtime. This is all using the default user.config.
Does INI read the Application Settings or is it completely separate?
I want to be able to save and load Application settings to different files so I can have multiple Application Setting sets.
Can PeanutButterINI be configured to do this?
Mainly around start-tempdb.sh
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.