Select to view content in your preferred language

Support multiple version of esri SDK

523
3
05-17-2023 02:50 AM
Labels (3)
ofirrosner
New Contributor III

Hello
currently we are using 100.05 and we want upgrade to 100.15

but our problem that some of the projects have to stay in 100.05
therefore we have to support both version in the same project(we dont to create a different branch for each version) 

we found out that for our needed everything work in both versions without changing anything
except for labels, and to be more specific the where clause


I found out this guide  and it works just fine
but the one problem i found is there's difference in how to set the expression

 

private string expression = "expression"
var labelInfo = new LabelClassInfo(....); //acording to the guide

if(GetVersion() == "100.15.00")
 labelInfo.ArcadeExpression = $"$feature.{expression}";
else if if(GetVersion() == "100.5.00")
 labelInfo.TextExpression = $"[{expression}]";

 

 

this seems to work fine for both versions
my question is if there's a cleaner way to do it?

 

EDIT: this seems to also work just fine for both versions

labelInfo.ArcadeExpression = $"$feature.{expression}";
labelInfo.TextExpression = $"[{expression}]";

 

0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor

You can use preprocessor constants to do this. In a project's csproj you'd add a new constant to a PropertyGroup:
<DefineConstants>$(DefineConstants);ARCGISRUNTIME_100_15</DefineConstants>

Then in code you can do 

 

#if ARCGISRUNTIME_100_15
 labelInfo.ArcadeExpression = $"$feature.{expression}";
#else
 labelInfo.TextExpression = $"[{expression}]";
#endif

 

However you won't be able to compile it into one class library and reuse it, since you can't make this check at runtime. So you'd have to use a shared project or linked file into the project that references the constant.

You'd have to reference 100.15 to write code that access both the new and old properties, but that means a 100.5 project won't be able to reference that project, since it is built with a newer library.

ofirrosner
New Contributor III

Thanks

Just to clarify , i don't to support 100.15 and 100.5 i want to support  100.15 or100.5 with the same code base
i have a map project that currently uses 100.5, this project is injected via a dll to alot of other project(that belong to different clients)
for one of the projects(clients) we want to upgrade 100.15, and for the rest leave it as is

0 Kudos
dotMorten_esri
Esri Notable Contributor

You can do that, but it will _have_ to be two separate builds, or your class library _must_ target 100.5 (and only use 100.5 APIs), and a 100.15 _app_ can reference that library.

If you want to access 100.15 APIs in your class library, you must reference 100.15, but that would mean any app trying to use that library must reference 100.15+ as well. 

0 Kudos