{"id":7354,"date":"2014-09-16T12:41:11","date_gmt":"2014-09-16T12:41:11","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/constants-in-a-common-assembly\/"},"modified":"2016-07-28T10:55:36","modified_gmt":"2016-07-28T10:55:36","slug":"constants-in-a-common-assembly","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/constants-in-a-common-assembly\/","title":{"rendered":"Constants in a Common Assembly"},"content":{"rendered":"<p>We were having a discussion about constants and an interesting issue came up.&#160; I&#8217;ve always known that when you use a constant it gets interpreted as a literal when your code compiles, but I never made the connection that this is true of referenced constants as well.&#160; This creates a bit of an issue when you have a common assembly with constants &#8211; if you update the constants in your common assembly and then deploy just the common assembly, the assemblies that reference that common assembly will not get the &#8220;updated&#8221; constant values because it was, in essence, converted into a literal and compiled directly into the assembly.&#160; As such, it may make more sense to use static read-only variables instead of constants if they are referenced from a common assembly.<\/p>\n<p>Of course, if you deploy everything all together you won&#8217;t encounter this issue because all the assemblies will be compiled with the new constants.&#160; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>We were having a discussion about constants and an interesting issue came up.&#160; I&#8217;ve always known that when you use a constant it gets interpreted as a literal when your code compiles, but I never made the connection that this is true of referenced constants as well.&#160; This creates a bit of an issue when&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-7354","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=7354"}],"version-history":[{"count":3,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7354\/revisions"}],"predecessor-version":[{"id":42421,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7354\/revisions\/42421"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=7354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=7354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=7354"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=7354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}