Archipelago.MultiClient.Net.Analyzers
1.2.0
See the version list below for details.
dotnet add package Archipelago.MultiClient.Net.Analyzers --version 1.2.0
NuGet\Install-Package Archipelago.MultiClient.Net.Analyzers -Version 1.2.0
<PackageReference Include="Archipelago.MultiClient.Net.Analyzers" Version="1.2.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Archipelago.MultiClient.Net.Analyzers --version 1.2.0
#r "nuget: Archipelago.MultiClient.Net.Analyzers, 1.2.0"
// Install Archipelago.MultiClient.Net.Analyzers as a Cake Addin #addin nuget:?package=Archipelago.MultiClient.Net.Analyzers&version=1.2.0 // Install Archipelago.MultiClient.Net.Analyzers as a Cake Tool #tool nuget:?package=Archipelago.MultiClient.Net.Analyzers&version=1.2.0
Archipelago.MultiClient.Net.Analyzers
Source analyzers, fixes, and code generation for the Archipelago.MultiClient.Net library.
Analyzers and Diagnostics
MULTICLIENT001 - DataStorageElement assigned outside of DataStorageHelper
This warning is intended to prevent bugs which may be caused by misuse of DataStorageHelper
. The Archipelago
network protocol allows batching several data storage operations in an atomic fashion. In order to support this,
DataStorageHelper
only sends a packet to the server when a DataStorageElement
, containing the batched operations,
is re-assigned back to the DataStorageHelper
. This means that storing a DataStorageElement
into a variable can
cause undesirable side effects on the element, as well as prevent it from being sent to the server at all. Instead,
it is recommended to use a compound assignment operator to apply edits directly to the DataStorageHelper
.
This analyzer also offers a corresponding fix action "Make DataStorage access inline" on variable declarations, which will remove the offending declaration and inline it at all usage sites.
Incorrect Code:
// MULTICLIENT001
DataStorageElement elem = session.DataStorage[Scope.Slot, "MyData"];
elem.Initialize(0);
// This will never make it to the server
elem += 2;
Fixed Code:
session.DataStorage[Scope.Slot, "MyData"].Initialize(0);
// This will make it to the server
session.DataStorage[Scope.Slot, "MyData"] += 2;
Source Generators
Data Storage Properties
Due to the verbosity of DataStorageHelper
's API, it is commonly desirable to assign a DataStorageElement
to a variable
for repeated access. Unfortunately, this does not work for most use cases, and there is an analyzer
to prevent misuse of the API. This package offers a source generator to create a thin wrapper around the data storage API
which is also considered an acceptable use by the MULTICLIENT001 analyzer. Note in the example below that you must have a
session defined in a scope that is available to members of the containing class - again, this is only a thin wrapper so you
have bring your own session.
Example Usage:
partial class MyClass
{
private ArchipelagoSession session;
[DataStorageProperty(nameof(session), Scope.Slot, "MyScopedData")]
private readonly DataStorageElement _myScopedData;
[DataStorageProperty(nameof(session), "MyGlobalData")]
private readonly DataStorageElement _myGlobalData;
public void DoStuff()
{
MyScopedData.Initialize(0);
MyGlobalData += 2;
}
}
Learn more about Target Frameworks and .NET Standard.
This package has 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.