files-community / Files

Building the best file manager for Windows
https://files.community
MIT License
34k stars 2.17k forks source link

Code Quality: Remove INI Parser dependency #15650

Closed yaira2 closed 2 months ago

yaira2 commented 3 months ago

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

Requirements

No response

Comments

No response

0x5bfa commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

Can I work on?

yaira2 commented 3 months ago

I meant that we can use that for the service.