Skip to content

Add analyzer for FileSystem #3643

@bitsandfoxes

Description

@bitsandfoxes

Problem

Without a strict enforcement mechanism, we risk a regression where file system access might bypass the IFileSystem.

Context

Certain platforms, such as the Nintendo Switch, impose strict limitations on disk access. To support these platforms (i.e. allow the Unity SDK to fallback on preventing disk access OOTB) and prevent user projects from crashing, we introduced an option to opt-out of all disk-writing operations.

Current Implementation

We now route file system access through our IFileSystem wrapper. Depending on the configuration in options, the SDK uses either a ReadOnly or ReadWrite filesystem. This mechanism acts as a fallback to prevent regressions. SDK developers must explicitly check Options.FileWriteDisable before attempting any disk write operation. If a write attempt is made with disk access disabled, the filesystem simply returns false without further context.

Solution

We could/should create an analyzer to ensure that all file system access continues to be routed through the SDK’s custom wrappers.
For reference on creating custom analyzers: How to write a C# analyzer

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions