MB3 5b: After the Fact, Can You Use Something a Non-Jewish Person Made for You on Shabbos (244:3-5)

If a non-Jew did melacha for a Jew on shabbos under inappropriate circumstances, can the Jew benefit from the work? What if it was done by a Jew?