question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C# generator includes unnecessary usings in Operations files, causing compilation errors

See original GitHub issue

In our IOperations classes, when using an up to date version of AutoRest, I am seeing this change:

-    using System.Linq;
+    using Microsoft.Azure;
+    using Microsoft.Azure.Batch;
     using Microsoft.Rest;
     using Microsoft.Rest.Azure;
+    using Microsoft.Rest.Serialization;
     using Models;
+    using Newtonsoft.Json;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Net;
+    using System.Net.Http;
+    using System.Threading;
+    using System.Threading.Tasks;

The issue is that using Microsoft.Azure and using Microsoft.Azure.Batch were added. By adding these usings (which aren’t needed by the way), we now have ambiguous references in the generated code. Specifically, in the method signature: public async Task<AzureOperationResponse<IPage<NodeAgentSku>,AccountListNodeAgentSkusHeaders>> the NodeAgentSku type is flagged as duplicate because it exists in both the Microsoft.Azure.Batch namespace, and the Models namespace.

This paradigm has worked for us since we started using AutoRest – is there a way to configure the code generator to omit the Microsoft.Azure.Batch using statement (which is causing these issues and isn’t needed)?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dsgoudacommented, Sep 18, 2017

Yes sir!

0reactions
olydiscommented, Sep 18, 2017

@dsgouda closing, I assume you have confirmed that the above specific case is fixed? 🙂 @matthchr this will be available with the next AutoRest release (right after Ignite)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix program errors and improve code - Visual Studio (Windows)
This article describes some basic ways Visual Studio can help you find and fix problems in your code, including build errors, code analysis, ......
Read more >
Detecting superfluous #includes in C/C++? - Stack Overflow
A superfluous include is a file which provides nothing of value to the compilation and does not alter another item which other files...
Read more >
How C++ Works: Understanding Compilation - Toptal
This preprocess and compile process is similar for C language. It follows the C rules for compiling, and the way it includes header...
Read more >
Optimize Options (Using the GNU Compiler Collection (GCC))
This option can cause excessive memory and compile-time usage on large compilation units. It is not enabled by default at any optimization level....
Read more >
Using Templates - OpenAPI Generator
It's easy to work with templates for codegen!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found