RF0105: An indexer cannot be exported
An indexer requires an argument; an exported property needs a distinct name without an index parameter.
For a C# project using Reckfell.NET.Sdk 1.0.0. Fix the first build error first: later messages may be a consequence.
Cause
An indexer requires an argument; an exported property needs a distinct name without an index parameter.
Fix
Export the container itself. Keep the indexer as ordinary unexported C# access.
Failing example
Save the file in a test C# project and run dotnet build. This version intentionally fails to build.
Example.cs
using Reckfell;
namespace DiagnosticExamples.RF0105;
public partial class Example : Entity { [Export] public int this[int index] { get => index; set { } } }Expected messages: RF0105.
Working version
Replace the failing version with these files; do not keep both declarations in the project.
Example.cs
using Reckfell;
namespace DiagnosticExamples.RF0105;
public partial class Example : Entity
{
[Export] public Reckfell.Collections.Array<int> Values { get; set; } = new() { 7 };
public int this[int index] { get => Values[index]; set => Values[index] = value; }
}Result
Assignment through the indexer changes Values[0]; Values is the exported container.
Related material
Reckfell Engine documentationBack to top ↑