\documentclass{article}
\usepackage{luacode} % loads luatexbase as well
\usepackage{listings}
\usepackage[framemethod=tikz]{mdframed}
\mdfsetup{roundcorner=5pt,middlelinewidth=2pt,backgroundcolor=gray!10}
\newcommand\mydashedline{%
\par\noindent
\makebox[\linewidth][l]{%
\hspace*{-\mdflength{innerleftmargin}}%
\begin{tikzpicture}%
\pgfmathsetlengthmacro{\tmpl}{20pt+\linewidth}%
\tikz\draw[thick,dashed] (0,0) -- (\tmpl,0);%
\end{tikzpicture}%
}
%
\par\kern\baselineskip\noindent