<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:02 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-179] Add an Implicit cast from HashTable to BsonDocument to make it easier to use the driver in powershell</title>
                <link>https://jira.mongodb.org/browse/CSHARP-179</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Powershell has great native support for HashTables via the @&lt;/p&gt;
{ &quot;key&quot;=&quot;value; . . .}
&lt;p&gt; syntax.. This simple implicit cast allows you to take adtantage of this notation in Powershell to create MongoDocuments..&lt;/p&gt;

&lt;p&gt;I also documented how to use this syntax in powershell.&lt;/p&gt;

&lt;p&gt;Commit:&lt;br/&gt;
&lt;a href=&quot;https://github.com/zippy1981/mongo-csharp-driver/commit/bae9c497a9f93360b51458f9dc55a71ed7723687&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/zippy1981/mongo-csharp-driver/commit/bae9c497a9f93360b51458f9dc55a71ed7723687&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Screenshots of .chm file compiled with sandcastle:&lt;br/&gt;
&lt;a href=&quot;https://picasaweb.google.com/zippy1981/Screenshots?authkey=Gv1sRgCPvkkdCensaenwE#5580322422059182802&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://picasaweb.google.com/zippy1981/Screenshots?authkey=Gv1sRgCPvkkdCensaenwE#5580322422059182802&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://picasaweb.google.com/zippy1981/Screenshots?authkey=Gv1sRgCPvkkdCensaenwE#5580322419345520482&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://picasaweb.google.com/zippy1981/Screenshots?authkey=Gv1sRgCPvkkdCensaenwE#5580322419345520482&lt;/a&gt;&lt;/p&gt;</description>
                <environment>Windows Powershell 2.0. Not tested in PS 1.0</environment>
        <key id="14999">CSHARP-179</key>
            <summary>Add an Implicit cast from HashTable to BsonDocument to make it easier to use the driver in powershell</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="zippy1981">Justin Dearing</reporter>
                        <labels>
                    </labels>
                <created>Fri, 4 Mar 2011 20:22:35 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:59 +0000</updated>
                            <resolved>Tue, 15 Mar 2011 16:21:56 +0000</resolved>
                                                    <fixVersion>1.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="25975" author="rstam" created="Wed, 16 Mar 2011 03:30:46 +0000"  >&lt;p&gt;I was also wondering if some of the documentation comments could be put in a separate file, but have not looked into it. If you figure it out, let me know. Thanks!&lt;/p&gt;</comment>
                            <comment id="25973" author="zippy1981" created="Wed, 16 Mar 2011 03:09:13 +0000"  >&lt;p&gt;Robert,&lt;/p&gt;

&lt;p&gt;My powershell script runs against the latest code, so yes the changes are ok. If there are any edge cases from changing ToString() to a cast, then the longer syntax will suffice. 99% of the powershell users will have the more convient syntax.&lt;/p&gt;

&lt;p&gt;With regards to the documentation, if its possible to store the examples section in an external XML file, would you be ok with that? Then we could have verbose documentation that doesn&apos;t clutter the .cs files.&lt;/p&gt;

&lt;p&gt;Justin&lt;/p&gt;</comment>
                            <comment id="25928" author="rstam" created="Tue, 15 Mar 2011 16:21:56 +0000"  >&lt;p&gt;I merged in your pull request and made some changes to follow the pattern set by the existing IDictionary overloads.&lt;/p&gt;

&lt;p&gt;1. Two new constructor overloads (one allows you to specify the keys you want to load from the hash table)&lt;br/&gt;
2. Two new Add methods for Hashtable&lt;br/&gt;
3. Added unit tests&lt;/p&gt;

&lt;p&gt;One change that MIGHT affect you is: it is now REQUIRED that the keys of the Hashtable already be strings. In other words, I am casting the keys to string instead of calling ToString. This is consistent with the IDictionary support, where the keys are also required to be strings. Let me know if you think this is a mistake (I think allowing arbitrary key types would be a mistake).&lt;/p&gt;

&lt;p&gt;Also, we haven&apos;t yet figured out the right balance for the amount of information to put in the doc comments. I&apos;m leaning towards keeping the doc comments very lean. This is probably not the place to be putting extensive documentation, or it will make the source files really hard to read and to maintain. In any case, I believe the sample code in the doc comments was not updated to reflect the change from implicit conversion to explicit call of a constructor. I don&apos;t know enough about PowerShell syntax to fix that.&lt;/p&gt;</comment>
                            <comment id="25364" author="zippy1981" created="Sun, 6 Mar 2011 18:32:57 +0000"  >&lt;p&gt;Are those two patches acceptable? While you are still stuck using reflection to use the CRUD moethods in MongoCollection, this makes assembling MongoDocuments much easier.&lt;/p&gt;</comment>
                            <comment id="25287" author="zippy1981" created="Fri, 4 Mar 2011 22:07:52 +0000"  >&lt;p&gt;Updated the pull request. My new additional commit that makes the cast a constructor and improves documentation is here:&lt;br/&gt;
&lt;a href=&quot;https://github.com/zippy1981/mongo-csharp-driver/commit/481b6ac3166a4c7d801207515c79bccfc9e76e6d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/zippy1981/mongo-csharp-driver/commit/481b6ac3166a4c7d801207515c79bccfc9e76e6d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="25280" author="zippy1981" created="Fri, 4 Mar 2011 21:39:31 +0000"  >&lt;p&gt;The constructor seems to work. I am futzing with sandcastle docs and I&apos;ll have new commit in a few.&lt;/p&gt;</comment>
                            <comment id="25276" author="rstam" created="Fri, 4 Mar 2011 21:00:20 +0000"  >&lt;p&gt;Try the constructor. It should be consistent with existing code (which is using constructors and not conversion operators).&lt;/p&gt;</comment>
                            <comment id="25275" author="zippy1981" created="Fri, 4 Mar 2011 20:57:25 +0000"  >&lt;p&gt;Perhaps an alternative would be a duplicate key event that gets fired similar to event that gets fired when validating Xml to an XSD schema via an Xml reader (I&apos;d have )to dig up code if. you don&apos;t know what I am talking about) &lt;/p&gt;

&lt;p&gt;Or, perhaps an option that in the event of a duplicate, make the property an array.&lt;/p&gt;

&lt;p&gt;Also, apparently Powershell will implicitly use explicit casts so changing the keyword from implicit to explicit will work. Is that good enough or should I try the constructor alternatives?&lt;/p&gt;</comment>
                            <comment id="25270" author="rstam" created="Fri, 4 Mar 2011 20:49:08 +0000"  >&lt;p&gt;Allowing duplicate key names usually causes nothing but trouble. The server doesn&apos;t officially support it (though it seems to work). It was primarily put in to allow easy mapping of XML to BSON, but not sure how useful that is if you then can&apos;t put the resulting document into the database anyway.&lt;/p&gt;</comment>
                            <comment id="25269" author="zippy1981" created="Fri, 4 Mar 2011 20:45:30 +0000"  >&lt;p&gt;Robert,&lt;/p&gt;

&lt;p&gt;I&apos;ll see if I can find an alternative like a constructor that concise and pretty in PowerShell (which is my ONLY reason to care about Hashtable).&lt;/p&gt;

&lt;p&gt;Since I don&apos;t understand the point of a bson document with duplicate keys, do you want duplicate keys allowed? I actually prefer making people do that the hard way in powershell if there is a need for duplicate keys.&lt;/p&gt;

&lt;p&gt;Justin&lt;/p&gt;</comment>
                            <comment id="25268" author="rstam" created="Fri, 4 Mar 2011 20:37:58 +0000"  >&lt;p&gt;I would prefer a new constructor like the existing one for BsonDocument(IDictionary&amp;lt;string, object&amp;gt;). Say BsonDocument(IDictionary).&lt;/p&gt;

&lt;p&gt;Implicit conversions often get you in trouble because they can&apos;t be turned off and people often don&apos;t expect them to exist. Not necessarily saying we can&apos;t do it, but would prefer another alternative that was explicit.&lt;/p&gt;</comment>
                            <comment id="25267" author="zippy1981" created="Fri, 4 Mar 2011 20:24:50 +0000"  >&lt;p&gt;Thanks to a git commit--amend to change rthe comment the correct patch is &lt;a href=&quot;https://github.com/zippy1981/mongo-csharp-driver/commit/35d8f1f6b91510775b8d1d3e43d8d414966e7f68&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/zippy1981/mongo-csharp-driver/commit/35d8f1f6b91510775b8d1d3e43d8d414966e7f68&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh98n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14296</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>