{"id":5413,"date":"2007-09-25T18:29:00","date_gmt":"2007-09-25T18:29:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2007\/09\/25\/option-strict-onoffsortof\/"},"modified":"2024-07-05T14:40:34","modified_gmt":"2024-07-05T21:40:34","slug":"option-strict-onoffsortof","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/option-strict-onoffsortof\/","title":{"rendered":"Option Strict [On&#124;Off&#124;SortOf]"},"content":{"rendered":"<p>Yesterday I got a question from a developer asking whether or not we could add something called &#8220;Option Strict Warn&#8221; to the language.&nbsp; This would give a developer a warning when using something like late binding or an implicit conversion, rather than disabling it altogether (through an error).<\/p>\n<p>As it turns out the ability to set custom custom values for Option Strict is actually already in Visual Studio.&nbsp; To test this out double click on &#8220;My Project&#8221; and click on the Compile tab of the Application Designer.<\/p>\n<p>The top 3 lines of the grid (under &#8220;Warning configurations&#8221;) contain the following options:<\/p>\n<p>&#8211; Implicit Conversion<\/p>\n<p>&#8211; Late binding; call could fail at runtime<\/p>\n<p>&#8211; Implicit type; object assumed<\/p>\n<p>When you change Option Strict to On you&#8217;ll see that all 3 of these change to &#8220;Error.&#8221;&nbsp; When you change it to Off they all change to &#8220;None.&#8221;&nbsp; If you change the dropdown to &#8220;Warning&#8221; you&#8217;ll see the Option Strict box updates to &#8220;(custom)&#8221;.<\/p>\n<p>If you open up a .vbproj file you can see how this information gets passed through the project system to the compiler.&nbsp; There&#8217;s a &lt;NoWarn&gt; element that takes a comma-separated list of warnings to disable, which gets passed to the compiler (through the \/nowarn:&lt;number_list&gt; switch).<\/p>\n<p>While we don&#8217;t recommend manually editing the .vbproj file, you can actually use this mechanism to disable other warnings which aren&#8217;t displayed in the grid.&nbsp; Anything inside the &lt;NoWarn&gt; or &lt;WarningsAsErrors&gt; elements will get passed to the compiler.<\/p>\n<p>If you want to find out a warning&#8217;s ID just right-click it in the Error List and click &#8220;Show Error Help.&#8221;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday I got a question from a developer asking whether or not we could add something called &#8220;Option Strict Warn&#8221; to the language.&nbsp; This would give a developer a warning when using something like late binding or an implicit conversion, rather than disabling it altogether (through an error). As it turns out the ability to [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[192,195],"tags":[83,166],"class_list":["post-5413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-visual-basic","tag-jonathan-aneja","tag-vb2008"],"acf":[],"blog_post_summary":"<p>Yesterday I got a question from a developer asking whether or not we could add something called &#8220;Option Strict Warn&#8221; to the language.&nbsp; This would give a developer a warning when using something like late binding or an implicit conversion, rather than disabling it altogether (through an error). As it turns out the ability to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/5413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=5413"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/5413\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=5413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=5413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=5413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}