Comments (4)
the
Comparer
of theIDictionary
instance
IDictionary<TKey, TValue>
does not have an IEqualityComparer<TKey> Comparer { get; }
.
Dictionary<TKey, TValue>
does, and there is a constructor that lets you give us the exact instance of Dictionary<string, object>
to use, so if you pass in one of those, then we should use its comparer.
I've tried changing the constructor to accept an
IDictionary
again
It's probably too late at this point to try and fix this
It kind-of is, but do you actually have a custom implementation of IDictionary<string, object>
, and does it handle serialization / deserialization properly? There's a lot of hidden complexity in the world where we let you inject any old IDictionary<string, object>
into AttributesTable
, and my judgment was that:
- This complexity is unwarranted: probably the overwhelming majority of callers would be perfectly fine with
Dictionary<string, object>
, and for the rare folks with customIDictionary<string, object>
implementations, they can still make a customIAttributesTable
implementation that may work even better than this. - Given that, the stability of using a built-in type for this serializable member seemed very attractive: the worst-case scenario when copying an instance of
AttributesTable
from one version of an application to another is if theComparer
that you inject can't be deserialized. And even there, probably the overwhelming majority of people who use a non-defaultComparer
would probably just give aStringComparer
anyway (e.g.,StringComparer.OrdinalIgnoreCase
like it sounds like you're doing) which should serialize just fine.
perhaps the best thing to do here is document this change, what do you think?
I don't see anything wrong with that. I've added a section to the NTS wiki page for 1.x-to-2.0 upgrades that deals with the breaking changes in this package.
from nettopologysuite.features.
IDictionary<TKey, TValue>
does not have anIEqualityComparer<TKey> Comparer { get; }
.
I missed this while debugging, it's actually a SortedList<TKey,TValue>
exposed as an IDictionary<TKey, TValue>
(with StringComparer.OrdinalIgnoreCase
as you guessed). I think we can get away with converting it to a Dictionary
, and if not I'll write a custom IAttributesTable
implementation as per your suggestion.
Thank you for your input and for expanding the documentation.
from nettopologysuite.features.
SortedList<TKey,TValue>
exposed as anIDictionary<TKey, TValue>
Hmm, I should have considered that kind of case before making my reply. Sorry about that.
One thing that we could do is allow callers to inject the IEqualityComparer<string>
directly. This doesn't really add any of that "hidden complexity" that I had mentioned before, since it's actually one of the few pieces of "hidden complexity" that this model keeps around.
from nettopologysuite.features.
No problem at all 😄
I'm dealing with conversions of types (related to NetTopologySuite/NetTopologySuite.IO.SqlServerBytes#10) and the source data is a Feature
implementation in an in-house library.
We convert from the in-house Feature
to NTS and back again (with some operations in-between), and after another review I found that I can simply use new Dictionary<string, object>(source.Attributes, StringComparer.OrdinalIgnoreCase)
with NTS as-is, without causing unintended side effects. Or we can make use of the commit you just pushed, that'll work too.
from nettopologysuite.features.
Related Issues (12)
- Setup build HOT 3
- FeatureCollection and XMLFormatter HOT 1
- How to test IAttributesTable for for thread safety issues? HOT 1
- IAttributesTable could support read-only instances better
- `GetOptionalId` is not consistent between implementations HOT 8
- 1.15 Release? HOT 1
- Simplify fetching values for optional attributes in (I)AttributesTable HOT 1
- Update to latest NTS Core HOT 2
- Redesign IFeature / IAttributesTable to better model the different use cases it solves HOT 3
- Remove CRS stuff HOT 2
- Add FeatureCollection ctor with IList<Feature> parameter HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nettopologysuite.features.