Skip to content

Add the missing Office 365 geography codes - #1259

Open
svermaak wants to merge 1 commit into
pnp:devfrom
svermaak:fix/office365geography-missing-codes
Open

Add the missing Office 365 geography codes#1259
svermaak wants to merge 1 commit into
pnp:devfrom
svermaak:fix/office365geography-missing-codes

Conversation

@svermaak

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix

Related issue

Fixes #1170

What is in this Pull Request

Office365Geography is the type behind PreferredDataLocation on SiteCollectionCreationInformation, CommunicationSiteCollectionCreationInformation and the UnifiedGroupsUtility group creation overloads. It listed 18 of the 30 codes in the geo location table its own summary links to, so a tenant in one of the other twelve could not be addressed at all:

Cannot convert value "NZL" to type "PnP.Framework.Enums.Office365Geography".
Error: "Unable to match the identifier name NZL to a valid enumerator name."

Missing: AUT Austria, CHL Chile, DNK Denmark, ESP Spain, IDN Indonesia, ISR Israel, ITA Italy, MEX Mexico, MYS Malaysia, NZL New Zealand, POL Poland, TWN Taiwan.

The value reaches the service through ToString() in SiteCollection.cs and UnifiedGroupsUtility.cs, so the member name is the code itself and nothing else has to change. The new members are appended rather than sorted in, so every existing member keeps its numeric value.

Source for the list is the table this enum already points at, geo location codes.

Verification

Binding each documented code to Office365Geography and checking it round trips through ToString(), plus the PreferredDataLocation assignment from the issue.

Before, twelve codes cannot be bound and New Zealand throws:

Before the fix

After, all thirty bind and PreferredDataLocation = NZL is accepted:

After the fix

Builds clean for netstandard2.0, net8.0, net9.0 and net10.0.

Regression test

Office365GeographyTests.EveryDocumentedGeoLocationCodeIsSupported walks the documented code list and reports the ones that are not usable, so the next geography Microsoft adds shows up as a failing test with the codes named rather than as a bind error at runtime. Verified both ways with dotnet test --filter FullyQualifiedName~Office365GeographyTests: on dev it fails listing the twelve, with this change it passes.

No CHANGELOG entry included.

Office365Geography carried 18 of the 30 PreferredDataLocation codes that
Microsoft documents, so a tenant in one of the other twelve could not be
addressed at all. Binding "NZL" fails with "Unable to match the
identifier name NZL to a valid enumerator name", which is what a caller
sees when it sets PreferredDataLocation for a New Zealand tenant.

Adds AUT, CHL, DNK, ESP, IDN, ISR, ITA, MEX, MYS, NZL, POL and TWN,
appended so the existing members keep their values. The value is sent on
with ToString(), so the member name is the code and no mapping is needed.

Adds a test that walks the documented code list, which turns the next
missing geography into a failing test rather than a runtime bind error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PnP.Framework.Enums.Office365Geography does not include New Zealand geolocation (NZL)

1 participant