Since I've been working for years, I've made sure to abide by all the companies working policies where I've been employed. I hate it whenever the management calls me in for questioning because I didn't keep the company's policy. If they demand no wearing of shorts, I will never think about putting it on to work.
When you're interested in being in the company or any business for long, there's no other choice left than for you to abide by all the company's rules, regulations and objectives. Once they notice that you're not keeping to the company's objective, there's nothing that going to make them not fire such staff.