.NET

.NET SDK changes in 3.0

Every change an application built on the 2.x .NET SDK meets in 3.0 — uploads with a Bearer header, scoped tokens, API tokens with an expiry, errors, parsing, client identification, IDS checks — and what the 3.0 instance answers differently through it, with what to do for each.

The package is BIM.works_SDK on nuget.org, as before. Upgrade it to the 3.0 package of your instance (.NET). The pre-release packages up to 3.0.0-b.118 still contain the 2.x SDK; use a later one. The package still targets .NET Standard 2.0 and needs System.Text.Json 8.0.5 or later. The request envelope, the WebSocket protocol and the Query2 envelope are unchanged.

This page lists what changes for an application built on the 2.x .NET SDK, and then what the 3.0 instance answers differently through it. The new features are on BIM.works 3.0; changelog/v3-0/from-2-to-3#dotnet has the short version.

Every change has a class:

  • Breaking: 2.x code no longer compiles, fails, or gives a wrong result.
  • Behaviour: the same code runs, but the result differs.
  • Deprecated: still works; use the replacement.
  • Requirement: what the application has to bring or set up.

The SDK#

Change Class
Uploads send Authorization: Bearer <base64 auth> and the connection's endpoint, which the 3.0 instance requires; without them every upload of new bytes gets HTTP 401, and a large file a reset connection Requirement: the reason to upgrade
The Scope enum, with Scopes.ToWire and FromWire; CreateVersionsTokenRequest, CreateNodesTokenRequest and CreateRecursiveNodeTokenRequest have constructors that take an ISet<Scope>, and the task-list constructors are [Obsolete] Deprecated
Admin.CreateApiToken(nodeUuid, name, ISet<Scope>, DateTime? expiresOn); the ApiTokenCredential form remains and gets the instance's default expiry of one month Behaviour
TreeNodeStatus.INDEXING; INDEXEDING is an obsolete alias of the same value Deprecated
Every error value of the instance is in the SDK's enumerations, and BQL errors have their own, BimWorksQueryError. A value or domain the SDK does not know is a BimWorksException with GetEnum() == null, where 2.x threw ArgumentException. GetDomain() and GetErrorType() give the instance's names, GetReference() the reference of the failed request (also in ToString()) Behaviour
BimWorksClient.Execute throws a BimWorksException for an HTTP error status, with the instance's error when the answer has one, else HTTP <status>; 2.x returned null, so the caller got a NullReferenceException Behaviour
AsyncTask.Get() returns also when the request itself fails; the failure is in IsError() and GetException(), and faults GetTask(). 2.x waited for ever when anything in the request threw Behaviour (a fix)
Parsing falls back instead of throwing on a value the SDK does not know: a node type reads as FOLDER or MODEL, TreeNodeStatus and Discipline as UNKNOWN, a version status as ERROR, a deleted status as ACTIVE. Action rows without a query (viewpoints) or without a parent parse, with Query null Behaviour
TreeNodeVersion.Disciplines, Filename and InputFileType; NodeType.WORKSPACE_ROOT; the Discipline and InputFileType values of 3.0 New
Actions.AddFolder, AddQuery and DeleteAction; Info.GetClientInfo(). Fs.UndeleteNode and Tokens.CreateRecursiveNodeToken call the right task; both failed before New, and a fix
IDS validation and IDS checks: client.Checks with ValidateIds, RunIdsCheck (the result tree with every checked object), RunIdsCheckSummary (the status per specification) and ReadTooLargeSummary (reference/dotnet#checks, Run an IDS check via the API). BimWorksException.GetUserSafeMessage() and GetPayload() New
Every request carries X-BIMworks-Client and a bimworks-dotnet/<version> (…) User-Agent, and the WebSocket starts with a hello. BimWorksClientFactory.SetApplication(name, version) adds your application; ExcludePlatformInfo() leaves out the runtime and the operating system Behaviour

What to do:

Still as in 2.x:

  • GenerateUploadToken signs fewer fields than the 3.0 instance checks, so its tokens are refused: the instance binds an upload token to the exact request it signs.
  • QueryDelegated and QueryWithToken set up a table export with a 2.x query object and return no results (reference/dotnet#apis).
  • An upload by URL without filename names the node null: set filename.
  • The SDK writes every partial upload hash and each "New WebSocket Message" to the console.
  • After NODE_GONE on a fleet the SDK does not reconnect by itself.

What the 3.0 instance answers differently#

Through the 3.0 package, the instance answers these calls differently. They apply to every client; From 2 to 3 has them per subject.

Behaviour Class
Uploads of new bytes, a second version onto a model node, and uploads the instance recognises by their hash all work —
Fs.DeleteNodeVersion deletes only the newest version (CAN_ONLY_DELETE_LAST_VERSION). Fs.DeleteNode on a missing node answers NODE_NOT_FOUND where 2.x returned true. Fs.RenameNode checks write rights Breaking (conditional), Behaviour
An upload by URL of a private, loopback or link-local address is refused (UPLOAD_URL_REFUSED). Like any failed upload (a corrupt IFC gives StepParserErrorCode.END_OF_FILE), it leaves the node in ERROR with an error row; 2.x left a node without a version Breaking (conditional), Behaviour
A token with a task list, issued after an API-token login, also carries the issuer's scopes, and reaches calls outside its list that those scopes and its resource rights allow: a [Query2] versions token can call GetNodeVersion, while calls on nodes still need node rights. A task name the instance does not have is refused (INVALID_TASK_NAME, naming the likely intended task). A token with scopes reaches exactly its scopes (changelog/v3-0/from-2-to-3#tokens) Behaviour (security relevant)
API tokens expire, after one month by default. Logged in with an API token, only an organization owner can create an API token Requirement
Fs.ListNodes is refused for nodes and versions tokens. Bim.Query2 with a stored query needs read rights on it. UploadOption.NEW_MODEL takes effect. During a graceful shutdown the instance answers SERVICE_UNAVAILABLE. X-Forwarded-For is believed only from proxies the instance is configured to trust Behaviour
BQL in the 2.x form fails with BimWorksQueryError.SYNTAX_ERROR (IN m3: "missing EOF at 'IN'"); results and counts change as described in changelog/v3-0/from-2-to-3#query-languages Breaking
A call without a login answers NO_AUTHORIZATION; an unknown API token INVALID_API_TOKEN Behaviour