victor-dumitrescu/TPCombinators — pull request #1 by tpetricek (2014-08-17 10:23:51+00:00)
Title: Access hiding configuration via declaring type

This fixes the issue when using the hiding combinator with multiple different parameters in a single file did not work.

This is actually tricky. Your original approach of using mutable variables to store the hiding configuration did not work, because the configuration was shared between both of the types whose properties we were hiding. And the compiler does not call the operations in any specific order - so it would first call `ApplyStaticArgs` for one CSV type, then for another CSV type and only *after that*, it would call `TxFilterProperty` (and so the properties would be hidden according to whatever type was checked later).

So, we need some way of passing around (or storing) the configuration that will link it to the specific generated CSV type.

Now, this is not as easy as I thought. My first thought was to just pass it around as an additional argument (just like we are passing declaring type), but that does not work, because the CSV type can also be accessed indirectly. When you write:

for row in sample.Rows do
// ...

.. this is not inside the main type definition. It is accessing the `Row` type indirectly (which is handled in `TxTypeDefinitionReference`) and at this point, we do not know what was the original hiding configuration (because the compiler just calls this directly).

So, what the code below does is that it stores the hiding configuration in the generated CSV type. When we then get to a member (say, `Close`), we recursively search its declaring type. The declaring type of `Close` is `Row` and the declaring type of `Row` is the generated CSV type - `CsvProvider`. And now we can extract the parameters from this type - and we know we should hide the `Close` property.

Technically, I added `TxHidingDefinition` which is called on all types *after* we apply static arguments and we know the hiding configuration. It implements this special interface `IWraps` that represents a type which "stores some additional information" (Andrew has been using this too). When we then want to hide a property, the `FindHidingSetting` method scans the declaring type (and recursively its declaring type..) until it finds a declaring type that has the special hiding configuration. (If it does not find one, it just uses the one passed originally as an argument.)