Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

If requesting help, make sure to mention what game you are attempting to use ACT with.
For the best FFXIV support, join Ravahn's Discord Server. Also check out OverlayPlugin's FFXIV FAQ and Setup Guide.

Linq not available (System.Core?)

Me again. Hopefully not many more questions going forwards...

I used Linq in my plugin, but then I get compilation errors when enabling it.

Have the Linq using reference (using System.Linq), and as far as I can tell ACT is running on .net 4.7, and the csproj includes a reference to System.Core, so I'm not sure what I'm missing here.

I can work around it, I've just found Linq to be easier to read/write, and I can't find a good reason it shouldn't work.
Tagged:

Comments

  • Wouldn't you need System.Data.Linq or System.Xml.Linq?

  • Hey Aditu,

    https://learn.microsoft.com/en-us/dotnet/api/system.linq?view=netframework-4.7.2

    System.Linq is a namespace in the System.Core assembly.

    System.Data.Linq is Microsoft's SQL supporting package, which uses Linq language to manage relationships between normalised database entities.

    System.Xml.Linq is similar but for Xml Documents.

    System.Linq itself contains a bunch of helper functions useful for traversing Enumerations.

    In my plugin, I'm referencing System.Linq in a using statement and then trying to use a .Where(x=>x....) clause, but on Enabling the plugin, I'm met with this error:
    'System.Collections.Generic.IList<Advanced_Combat_Tracker.CombatantData>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Collections.Generic.IList<Advanced_Combat_Tracker.CombatantData>' could be found (are you missing a using directive or an assembly reference?)

    I've taken a look into your PluginListingPanel.cs, and can see that the CompilerParameters contains a referenced assembly line for "System.Linq.dll", and I assume ACT itself is using Linq for it's ordering (maybe it doesn't). I don't know if those CompilerParameters also needs to contain a reference to "System.Core.dll"?

    To reproduce, just create a plugin that has the System.Linq using statement, and get it to do some simple Linq statement, such as below, and see what happens when you enable the plugin.

    var list = new List<int> { 1, 2, 3 };
    var evens = list.Where(x => x % 2 == 0).ToList();
  • I don't use LINQ because it wasn't the best performance and was not thread-safe.  (Collection modified exceptions)

    What you saw in PluginListingPanel is only for when ACT compiles .cs files internally.  Could you clarify if you are distributing a .cs or .dll plugin?

    The FFXIV Plugin uses LINQ but that has nothing to do with me.  Their csproj references it, so it is lazy loaded when that plugin is loaded.  ACT itself does not have to know anything about assemblies used in your plugin. (usually)
  • It’s a .cs plugin at the moment, largely to keep the feedback loop small, but also it’s been a long time since I’ve had my PC set up for .net framework development.
  • Because using directives are not 1:1 with loaded assemblies, ACT cannot guess what it needs to load from the .NET Framework or otherwise.

    If you need additional assemblies not already loaded into ACT according to the "View Loaded Assemblies" report, then take a look at this: https://github.com/EQAditu/AdvancedCombatTracker/wiki/Plugin-Creation-Tips#adding-references-not-included-by-act

  • I should also mention that the compiler class that ACT uses from the .NET Framework appears to be stuck on an old C# version.  So modern C# can't be compiled by ACT, even though a compiled version of the same thing would work fine.  I don't know why Microsoft stopped updating it but it is completely absent in .NET Core... so that says something about how they felt about the feature.
Sign In or Register to comment.