I remember my first visit to the masjid. It was the day after I said shahadah--I said shahadah over the phone on a Thursday night. And on Friday afternoon, after work, I went by the masjid, wearing a pair of long pants and a loose button-up blouse with elbow-length sleeves. I considered it a more modest outfit than what I could have worn--a knee-length skirt, short-sleeve, low cut blouse--though I know I still wasn't entirely covered.
So a few months after that, after I had begun to practice Islam and started going to MSA events, I remember having a discussion at a meeting about non-Muslims going to the masjid, and how to treat them. A rude remark was made about a woman (theoretical, to my knowledge it's not something that happened) who would visit the masjid for the first time wearing shorts. According to the speaker, such a woman should not be allowed to enter the masjid.
Apparently, she was supposed to know better... "It's the masjid!" Like everyone is automatically aware of Muslim customs, despite the fact they might not have ever had any contact with Muslims? Some people don't know better, is my point.
I wouldn't keep her out of the building, though, as it would be profoundly rude. So the best thing to do is to gently explain that it's appropriate to dress modestly in a house of worship, and take the opportunity to give da'wah.
And if you know someone who wants to visit a mosque, it might be wise to inform them ahead of time that they should wear long pants and sleeves. I think if they are politely told early on, there won't be a shock or any offense when they arrive.
Wondering what to tell someone before they visit a mosque?
Perhaps, that they might be expected to remove their shoes, and that it would be courteous to wear modest clothes. It's also useful to know that men and women usually don't mix or mingle in the masjid--something Muslims try to avoid in general. So to explain that there are separate spaces for men and women early on is useful. Some people want to know why there are footsinks in the bathroom, something else which is easy to explain. It's also polite to be quiet, especially in the prayer hall, where anyone might be praying or reading Qur'an. Because above all, the purpose of the mosque is for worship. Is there anything I left out?