Bug 2272 - C# CodeDomProvider generates assembly attributes before namespace usings
Summary: C# CodeDomProvider generates assembly attributes before namespace usings
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2011-11-30 10:55 UTC by Alex Earl
Modified: 2017-02-10 08:03 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
modified msbuild community task implementation (4.02 KB, text/x-csharp)
2011-11-30 10:55 UTC, Alex Earl
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Alex Earl 2011-11-30 10:55:44 UTC
Created attachment 975 [details]
modified msbuild community task implementation

On MS.NET using the attached test case to generate an AssemblyInfo file generates the following:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.488
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("1.0")]



When running the same application on Linux with mono it generates the following:

// ------------------------------------------------------------------------------$
//  <autogenerated>$
//      This code was generated by a tool.$
//      Mono Runtime Version: 4.0.30319.1$
// $
//      Changes to this file may cause incorrect behavior and will be lost if $
//      the code is regenerated.$
//  </autogenerated>$
// ------------------------------------------------------------------------------$
$
[assembly: AssemblyVersion("1.0")]$
$
using System;$
using System.Reflection;$
using System.Runtime.CompilerServices;$
using System.Runtime.InteropServices;$


This causes a compiler error when the file is compiled because the using's need to come first.

This happens because in mono/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator in the GenerateCompileUnit method, it outputs the assembly attributes before it outputs the namespace info.
Comment 1 Alex Earl 2011-11-30 10:56:22 UTC
Disregard the $ in the mono output, that was a copy paste issue from my terminal.
Comment 2 Marek Safar 2017-02-10 08:03:44 UTC
Fixed in master