Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Remove INI Parser dependency #15650

Open
yaira2 opened this issue Jun 23, 2024 · 5 comments · May be fixed by #15654
Open

Code Quality: Remove INI Parser dependency #15650

yaira2 opened this issue Jun 23, 2024 · 5 comments · May be fixed by #15654
Assignees
Labels
codebase quality Issues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability)

Comments

@yaira2
Copy link
Member

yaira2 commented Jun 23, 2024

Description

We currently utilize the INI Parser solely within the Adaptive Layout Helper and can easily replace with other code.

Concerned code

Adaptive layout helper

Gains

  • Less dependencies
  • More control over the code

Requirements

No response

Comments

No response

@yaira2 yaira2 added the codebase quality Issues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability) label Jun 23, 2024
@0x5bfa
Copy link
Member

0x5bfa commented Jun 23, 2024

Why not create a service, WindowsIniService.

public string GetValue(string section = string.Empty, string name = string.Empty);

If section is empty, returns the first item.

I found Win32 API for this but it is for 16-bit compat https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofilestring. But worth taking a look.

https://en.wikipedia.org/wiki/INI_file
image

@yaira2
Copy link
Member Author

yaira2 commented Jun 23, 2024

What we need in Files is very basic so something like this would work (all our work with INI files is read only).

var lines = File.ReadLines(iniPath);
var keys = lines.Select(line => line.Split('='))
	.Where(parts => parts.Length == 2)
	.ToDictionary(parts => parts[0].Trim(), parts => parts[1].Trim());

@0x5bfa
Copy link
Member

0x5bfa commented Jun 23, 2024

yeah but putting this in places where it needs makes you hard to maintain. Also, I like services because I plan to create Unit Tests for services in the future.

@0x5bfa
Copy link
Member

0x5bfa commented Jun 23, 2024

Can I work on?

@yaira2
Copy link
Member Author

yaira2 commented Jun 23, 2024

I meant that we can use that for the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codebase quality Issues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability)
Projects
Status: 🔖 Ready to build
Development

Successfully merging a pull request may close this issue.

2 participants